Skip to content

Commit 902dea6

Browse files
committed
fixed date filtering logic and added a Leaflet api to fetch location based on lat and long
2 parents 3cba957 + 9461992 commit 902dea6

387 files changed

Lines changed: 39097 additions & 8956 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

config-overrides.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// eslint-disable-next-line import/no-extraneous-dependencies
12
const webpack = require('webpack');
23

34
module.exports = function override(config) {

package-lock.json

Lines changed: 1137 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
},
99
"private": true,
1010
"dependencies": {
11+
"@ant-design/charts": "^2.6.4",
12+
"@ant-design/icons": "^6.0.1",
1113
"@babel/runtime": "^7.27.6",
1214
"@babel/runtime-corejs3": "^7.27.6",
1315
"@changey/react-leaflet-markercluster": "^4.0.0-rc1",
@@ -32,7 +34,8 @@
3234
"@tinymce/tinymce-react": "^6.1.0",
3335
"ajv": "^8.0.0",
3436
"ajv-keywords": "^5.1.0",
35-
"antd": "^5.27.4",
37+
"ant-design": "^1.0.0",
38+
"antd": "^5.27.6",
3639
"assert": "^2.1.0",
3740
"axios": "^1.11.0",
3841
"axios-mock-adapter": "^1.22.0",

public/index.css

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,21 @@ body.bm-dashboard-dark .table {
171171
}
172172

173173
body.dark-mode .table th,
174-
body.dark-mode .table td,
174+
body.dark-mode .table td {
175+
color: #ffffff !important;
176+
border-color: #3a506b;
177+
}
178+
175179
body.bm-dashboard-dark .table th,
176180
body.bm-dashboard-dark .table td {
177181
color: #ffffff !important;
178182
border-color: #3a506b;
179183
}
180184

185+
body.bm-dashboard-dark .table th{
186+
background-color: #2e5061 !important;
187+
}
188+
181189
body.dark-mode .table-striped > tbody > tr:nth-of-type(odd),
182190
body.bm-dashboard-dark .table-striped > tbody > tr:nth-of-type(odd) {
183191
background-color: rgba(46, 80, 97, 0.5);
@@ -234,10 +242,6 @@ body.bm-dashboard-dark .nav-link {
234242
color: #ffffff !important;
235243
}
236244

237-
body.dark-mode .navbar,
238-
body.bm-dashboard-dark .navbar {
239-
background-color: #1b2a41 !important;
240-
}
241245

242246
body.dark-mode .navbar-brand,
243247
body.bm-dashboard-dark .navbar-brand {

src/actions/__tests__/authActions.js.test.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
setCurrentUser, // Import setCurrentUser action
1414
setHeaderData, // Import setHeaderData action
1515
} from '../authActions'; // Import actions from authActions
16-
import { SET_CURRENT_USER, SET_HEADER_DATA } from '../../constants/auth'; // Import constants
16+
import { SET_CURRENT_USER, SET_HEADER_DATA, STOP_FORCE_LOGOUT } from '../../constants/auth'; // Import constants
1717

1818

1919
const middlewares = [thunk]; // Define middlewares
@@ -35,7 +35,10 @@ describe('authActions', () => {
3535
httpService.post.mockResolvedValue({ data: { token } }); // Mock the httpService post method
3636
jwtDecode.mockReturnValue(decodedToken); // Mock the jwtDecode function
3737

38-
const expectedActions = [{ type: SET_CURRENT_USER, payload: decodedToken }]; // Define expected actions
38+
const expectedActions = [
39+
{ type: STOP_FORCE_LOGOUT }, // Ensure any existing timers are cleared
40+
{ type: SET_CURRENT_USER, payload: decodedToken },
41+
]; // Define expected actions
3942

4043
await store.dispatch(loginUser(credentials)); // Dispatch the loginUser action
4144
expect(store.getActions()).toEqual(expectedActions); // Assert the actions
@@ -68,7 +71,10 @@ describe('authActions', () => {
6871

6972
it('creates SET_CURRENT_USER with null when logoutUser is called', () => {
7073
const store = mockStore({}); // Create a mock store
71-
const expectedActions = [{ type: SET_CURRENT_USER, payload: null }]; // Define expected actions
74+
const expectedActions = [
75+
{ type: STOP_FORCE_LOGOUT }, // Clear any active force-logout timer
76+
{ type: SET_CURRENT_USER, payload: null },
77+
]; // Define expected actions
7278

7379
store.dispatch(logoutUser()); // Dispatch the logoutUser action
7480
expect(store.getActions()).toEqual(expectedActions); // Assert the actions

src/actions/__tests__/userManagement.test.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const mockStore = configureMockStore(middlewares);
1414

1515
describe('User Management Actions', () => {
1616
let store;
17-
17+
1818
beforeEach(() => {
1919
store = mockStore({});
2020
vi.clearAllMocks();
@@ -46,7 +46,7 @@ describe('User Management Actions', () => {
4646

4747
it('should update user to active status', async () => {
4848
const reactivationDate = null;
49-
49+
5050
axios.patch.mockResolvedValueOnce({ data: {} });
5151

5252
await store.dispatch(actions.updateUserStatus(mockUser, UserStatus.Active, reactivationDate));
@@ -143,7 +143,7 @@ describe('User Management Actions', () => {
143143
);
144144
});
145145

146-
146+
147147
});
148148

149149
describe('updateUserFinalDayStatus', () => {
@@ -205,6 +205,7 @@ describe('User Management Actions', () => {
205205
{ id: 1, name: 'John Doe', email: 'john@example.com' },
206206
{ id: 2, name: 'Jane Smith', email: 'jane@example.com' }
207207
];
208+
const mockSource = 'Report';
208209

209210
axios.get.mockResolvedValueOnce({ data: mockBasicInfo });
210211

@@ -213,20 +214,20 @@ describe('User Management Actions', () => {
213214
{ type: 'RECEIVE_USER_PROFILE_BASIC_INFO', payload: mockBasicInfo }
214215
];
215216

216-
await store.dispatch(actions.getUserProfileBasicInfo());
217+
await store.dispatch(actions.getUserProfileBasicInfo({source: mockSource}));
217218
expect(store.getActions()).toEqual(expectedActions);
218-
expect(axios.get).toHaveBeenCalledWith(ENDPOINTS.USER_PROFILE_BASIC_INFO);
219+
expect(axios.get).toHaveBeenCalledWith(ENDPOINTS.USER_PROFILE_BASIC_INFO(mockSource));
219220
});
220221

221222
it('should handle errors when fetching basic info', async () => {
222223
axios.get.mockRejectedValueOnce(new Error('Network error'));
223-
224+
const mockSource = '';
224225
const expectedActions = [
225226
{ type: 'FETCH_USER_PROFILE_BASIC_INFO' },
226227
{ type: 'FETCH_USER_PROFILE_BASIC_INFO_ERROR' }
227228
];
228229

229-
await store.dispatch(actions.getUserProfileBasicInfo());
230+
await store.dispatch(actions.getUserProfileBasicInfo({ source: mockSource }));
230231
expect(store.getActions()).toEqual(expectedActions);
231232
});
232233
});
@@ -276,4 +277,4 @@ describe('User Management Actions', () => {
276277
expect(store.getActions()).toContainEqual(expectedAction);
277278
});
278279
});
279-
});
280+
});

src/actions/allTeamsAction.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ export const getAllUserTeams = () => {
122122
.then(res => {
123123
dispatch(teamMembersFectchACtion(res.data));
124124
return res.data;
125-
// console.log("getAllUserTeams: res:", res.data)
126125
})
127126
.catch(() => {
128127
dispatch(teamMembersFectchACtion(undefined));

src/actions/authActions.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
SET_CURRENT_USER,
99
SET_HEADER_DATA,
1010
START_FORCE_LOGOUT,
11+
STOP_FORCE_LOGOUT,
1112
} from '../constants/auth';
1213

1314
const { tokenKey } = config;
@@ -22,6 +23,21 @@ export const setHeaderData = data => ({
2223
payload: data,
2324
});
2425

26+
/**
27+
* Stops any active force logout timer and clears related state
28+
*/
29+
export const stopForceLogout = () => (dispatch, getState) => {
30+
const { auth } = getState();
31+
if (auth?.timerId) {
32+
try {
33+
clearTimeout(auth.timerId);
34+
} catch (e) {
35+
// Timer already cleared or invalid
36+
}
37+
}
38+
dispatch({ type: STOP_FORCE_LOGOUT });
39+
};
40+
2541
export const loginUser = credentials => dispatch => {
2642
return httpService
2743
.post(ENDPOINTS.LOGIN, credentials)
@@ -33,6 +49,8 @@ export const loginUser = credentials => dispatch => {
3349
localStorage.setItem(tokenKey, res.data.token);
3450
httpService.setjwt(res.data.token);
3551
const decoded = jwtDecode(res.data.token);
52+
// Ensure any existing timers from a previous session are cleared
53+
dispatch(stopForceLogout());
3654
dispatch(setCurrentUser(decoded));
3755
return { success: true };
3856
})
@@ -98,6 +116,8 @@ export const getHeaderData = userId => {
98116
};
99117

100118
export const logoutUser = () => dispatch => {
119+
// Clear any active force-logout timer before logging out
120+
dispatch(stopForceLogout());
101121
localStorage.removeItem(tokenKey);
102122
httpService.setjwt(false);
103123
dispatch(setCurrentUser(null));
@@ -134,6 +154,9 @@ export const startForceLogout = (delayMs = 20000) => (dispatch, getState) => {
134154
// eslint-disable-next-line no-console
135155
console.error('Error acknowledging permissions during force logout:', error);
136156
} finally {
157+
// Set flag to indicate user was force logged out due to permission changes
158+
// This helps distinguish "force logged out" vs "first login after permission change"
159+
sessionStorage.setItem('wasForceLoggedOut', 'true');
137160
dispatch(logoutUser());
138161
}
139162
}, delayMs);

0 commit comments

Comments
 (0)