diff --git a/src/actions/bmdashboard/injuryActions.js b/src/actions/bmdashboard/injuryActions.js index 549486366f..ecdda38db9 100644 --- a/src/actions/bmdashboard/injuryActions.js +++ b/src/actions/bmdashboard/injuryActions.js @@ -1,8 +1,8 @@ import axios from 'axios'; -import { - FETCH_INJURIES_REQUEST, - FETCH_INJURIES_SUCCESS, - FETCH_INJURIES_FAILURE +import { + FETCH_INJURIES_REQUEST, + FETCH_INJURIES_SUCCESS, + FETCH_INJURIES_FAILURE, } from './types'; import { ENDPOINTS } from '../../utils/URL'; @@ -133,30 +133,21 @@ export const fetchInjuries = (projectId, startDate, endDate) => async dispatch = dispatch({ type: FETCH_INJURIES_REQUEST }); try { - // Build query parameters - const params = {}; - if (projectId && projectId !== 'all') { - params.projectId = projectId; - } - if (startDate) params.startDate = startDate; - if (endDate) params.endDate = endDate; - - // API call - const response = await axios.get(ENDPOINTS.INJURIES, { params }); + const data = await getInjuryData(projectId, startDate, endDate); dispatch({ type: FETCH_INJURIES_SUCCESS, - payload: response.data + payload: data, }); - return response; + return data; } catch (error) { dispatch({ type: FETCH_INJURIES_FAILURE, payload: { message: error.response?.data?.message || 'Failed to fetch injury data', - status: error.response?.status - } + status: error.response?.status, + }, }); throw error; @@ -165,7 +156,6 @@ export const fetchInjuries = (projectId, startDate, endDate) => async dispatch = // Function to get injury data (non-Redux version for direct component use) export const getInjuryData = async (projectId, startDate, endDate) => { - // Build query parameters const params = {}; if (projectId && projectId !== 'all') { params.projectId = projectId; @@ -173,9 +163,7 @@ export const getInjuryData = async (projectId, startDate, endDate) => { if (startDate) params.startDate = startDate; if (endDate) params.endDate = endDate; - // API call const response = await axios.get(ENDPOINTS.INJURIES, { params }); - // Return the data directly return response.data; }; diff --git a/src/components/BMDashboard/InjuryChart/InjuryChartForm.jsx b/src/components/BMDashboard/InjuryChart/InjuryChartForm.jsx index 23c75d15a0..6af4750210 100644 --- a/src/components/BMDashboard/InjuryChart/InjuryChartForm.jsx +++ b/src/components/BMDashboard/InjuryChart/InjuryChartForm.jsx @@ -120,13 +120,13 @@ function InjuryChartForm({ dark }) { {/* Filter Form */}
-
-
+
0 && (
@@ -276,7 +276,11 @@ function InjuryChartForm({ dark }) { {/* No Data Display */} {!error && !loading && (!chartData || chartData.length === 0) && ( -
+

No injury data available for the selected criteria.

)} diff --git a/src/components/BMDashboard/InjuryChart/InjuryChartForm.module.css b/src/components/BMDashboard/InjuryChart/InjuryChartForm.module.css index f4d2ec0c58..d3fade0d66 100644 --- a/src/components/BMDashboard/InjuryChart/InjuryChartForm.module.css +++ b/src/components/BMDashboard/InjuryChart/InjuryChartForm.module.css @@ -37,6 +37,10 @@ margin-right: 0.3rem; } +.lightBackground { + background-color: #fff; +} + .wrapperDark { background-color: #1b2a41; color: #f5f7fa;