Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b12194b
finally pushing the changes containing filterColor functionality and …
TaariqMansurie Aug 10, 2025
18e83d1
pushing the changes for filter Color and Select All Functionality
TaariqMansurie Aug 31, 2025
21e9055
Merge development into taariq_fixing_angads_filter_branch_frontend an…
TaariqMansurie Aug 31, 2025
f542bd7
adding the package-lock.json and yarn.lock files
TaariqMansurie Aug 31, 2025
5330b26
Solving merge conflics while merging development into my branch
TaariqMansurie Sep 6, 2025
a8a41e2
fixing lint issues and merging development into my branch
TaariqMansurie Sep 6, 2025
a28d80a
fix: fixed the merge conflicts and pushing the code now
TaariqMansurie Sep 27, 2025
ccac7b6
fix:Fixed the endpoint of userProfile for filterColor functionality
TaariqMansurie Oct 9, 2025
80087bf
fix: resolving the merge conflicts with the development branch
TaariqMansurie Oct 16, 2025
2d83ca7
merging with the latest development branch
TaariqMansurie Oct 22, 2025
ca5d64a
pushing the formatted Report file to pass the sonar qube scan
TaariqMansurie Oct 22, 2025
931e386
pushing the formatted Report file to pass the sonar qube scan analysis
TaariqMansurie Oct 22, 2025
4e459c4
pushing the weekly summaries action file to pass the sonar qube scan
TaariqMansurie Oct 22, 2025
43553c2
pushing the weekly summaries action file to pass the sonar qube scan
TaariqMansurie Oct 22, 2025
9e71aa6
fix: fixed the errors that were preventing the page to load correctly
TaariqMansurie Oct 25, 2025
22b38f6
fix: fixing the merge conflicts with development branch
TaariqMansurie Oct 26, 2025
1151935
fix: resolved the merge conflicts and testing it out on my local
TaariqMansurie Nov 1, 2025
bb6c962
fix: adding the yarn.lock file
TaariqMansurie Nov 1, 2025
6a003a3
fix: resolving merge conflicts and passing the failing tests
TaariqMansurie Nov 9, 2025
7cc40e6
chore: adding the yarn.lock and package-lock.json file
TaariqMansurie Nov 9, 2025
91c75e8
fix: fixing few buggy things and pushing the code now for it to be me…
TaariqMansurie Nov 16, 2025
e046357
fix: resolving the merge conflicts
TaariqMansurie Dec 2, 2025
83f3d55
fix: resolved merge conflicts
TaariqMansurie Dec 10, 2025
11cee9c
fix: syncing yarn.lock and reinstalling package-lock.json
TaariqMansurie Dec 10, 2025
c367f5b
fix: resolving merge conflicts
TaariqMansurie Jan 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22,148 changes: 22,148 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@react-leaflet/core": "^2.1.0",
"@reduxjs/toolkit": "^2.4.0",
"@sentry/browser": "^9.15.0",
"@tanstack/react-query": "^5.85.3",
"@tanstack/react-query": "^5.90.3",
"@tinymce/miniature": "^6.0.0",
"@tinymce/tinymce-react": "^6.1.0",
"ajv": "^8.0.0",
Expand Down Expand Up @@ -184,7 +184,7 @@
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-testing-library": "^7.11.0",
"eslint-plugin-vitest": "^0.5.4",
"husky": "^7.0.4",
"husky": "^9.1.7",
"joi-browser": "^13.4.0",
"jsdom": "^26.1.0",
"lint-staged": "^16.1.5",
Expand Down
216 changes: 215 additions & 1 deletion src/actions/weeklySummaries.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import axios from 'axios';
import { toast } from 'react-toastify';
import * as actions from '../constants/weeklySummaries';
import * as reportActions from '../constants/weeklySummariesReport';
import { ENDPOINTS } from '~/utils/URL';
import { getUserProfileActionCreator } from './userProfile';

Expand Down Expand Up @@ -36,7 +38,7 @@ export const fetchWeeklySummariesError = error => ({
* @param {ObjectId} userId The user id.
*/
export const getWeeklySummaries = userId => {
const url = ENDPOINTS.USER_PROFILE(userId);
const url = ENDPOINTS.USER_PROFILE_FIXED(userId);
return async dispatch => {
dispatch(fetchWeeklySummariesBegin());
try {
Expand Down Expand Up @@ -112,3 +114,215 @@ export const updateWeeklySummaries = (userId, weeklySummariesData) => {
}
};
};

// ========== WEEKLY SUMMARIES REPORT (from your old file) ==========

/**
* Action to set the 'loading' flag to true for reports.
*/
export const fetchWeeklySummariesReportBegin = () => ({
type: reportActions.FETCH_SUMMARIES_REPORT_BEGIN,
});

/**
* This action is used to set the weekly summaries reports in store.
*
* @param {array} weeklySummariesData An array of all active users.
*/
export const fetchWeeklySummariesReportSuccess = weeklySummariesData => ({
type: reportActions.FETCH_SUMMARIES_REPORT_SUCCESS,
payload: { weeklySummariesData },
});

/**
* Handle the error case for reports.
*
* @param {Object} error The error object.
*/
export const fetchWeeklySummariesReportError = error => ({
type: reportActions.FETCH_SUMMARIES_REPORT_ERROR,
payload: { error },
});

/**
* Update one summary report
*
* @param {Object} updatedField the updated field object, dynamic
*/
export const updateSummaryReport = ({ _id, updatedField }) => ({
type: reportActions.UPDATE_SUMMARY_REPORT,
payload: { _id, updatedField },
});

// write server-truth user object into the store
export const updateSummaryReportFromServerAction = (user) => ({
type: reportActions.UPDATE_SUMMARY_REPORT,
payload: { _id: user._id, updatedField: user },
});
/**
* Gets all active users' summaries + a few other selected fields from the userProfile that
* might be useful for the weekly summary report.
*/
export const getWeeklySummariesReport = (weekIndex = null) => {
return async dispatch => {
dispatch(fetchWeeklySummariesReportBegin());
try {
// Use the APIEndpoint from ENDPOINTS
let url = ENDPOINTS.WEEKLY_SUMMARIES_REPORT();

const timestamp = `ts=${Date.now()}`;
const separator = url.includes('?') ? '&' : '?';

if (weekIndex === null) {
url = `${url}${separator}${timestamp}`;
} else {
const separator = url.includes('?') ? '&' : '?';
url = `${url}${separator}week=${weekIndex}&${timestamp}`;
}

const response = await axios.get(url, {
headers: {
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: '0',
},
});
// Adding this debug log to check if filterColors are coming back
// eslint-disable-next-line no-console
console.log('API Response:', response.data);
// eslint-disable-next-line no-console
console.log('FilterColors in response:', response.data.map(user => ({
id: user._id,
name: user.firstName + ' ' + user.lastName,
filterColor: user.filterColor
})));
dispatch(fetchWeeklySummariesReportSuccess(response.data));
return { status: response.status, data: response.data };
} catch (error) {
dispatch(fetchWeeklySummariesReportError(error));
return error.response ? error.response.status : 500;
}
};
};

// working
// export const updateOneSummaryReport = (userId, fullUserPayload) => {
// // const url = ENDPOINTS.USER_PROFILE(userId);
// // return async dispatch => {
// // const { data: userProfile } = await axios.get(url);
// // const payload = { ...userProfile, ...updatedField };
// // // eslint-disable-next-line no-console
// // console.log('🛰 PUT payload being sent:', payload);
// // const res = await axios.put(url, {
// // ...userProfile,
// // ...updatedField,
// // });

// // // 🔹 Step 4 debug: log backend response explicitly
// // // eslint-disable-next-line no-console
// // console.log('🔍 Backend returned after PUT:', res.data);
// // // eslint-disable-next-line no-console
// // console.log('✅ PUT response:', res.data);

// // if (res.status === 200) {
// // dispatch(updateSummaryReport({ _id: userId, updatedField }));
// // // eslint-disable-next-line no-console
// // console.log('🟢 Redux state updated with:', updatedField);
// // return res;
// // }

// // throw new Error(`An error occurred while attempting to save the changes to the profile.`);
// // };
// const url = ENDPOINTS.USER_PROFILE(userId);
// return async dispatch => {
// // try {
// // // Optional: fetch current user profile if needed
// // // const { data: userProfile } = await axios.get(url);
// // const state = getState();
// // const allUsers = Array.isArray(state.weeklySummariesReport?.summaries)
// // ? state.weeklySummariesReport.summaries
// // : [];
// // const currentUser = allUsers.find(u => u._id === userId);

// // if (!currentUser) throw new Error('User not found in state');

// // // Merge updatedField (like filterColor) into the full user object
// // const payload = { ...currentUser, ...updatedField };

// // // Send the PUT and get server response (server should return the saved user)
// // // const res = await axios.put(url, {
// // // ...updatedField, // send only updated fields (you already normalized on client)
// // // });
// // const res = await axios.put(url, payload);
// // // Log for debugging
// // // eslint-disable-next-line no-console
// // console.log('✅ PUT response (updateOneSummaryReport):', res.data);

// // if (res.status === 200) {
// // // Dispatch the server-truth into the store.
// // // IMPORTANT: payload should be the full user object (or at least fields the UI needs)
// // dispatch(updateSummaryReport({ _id: userId, updatedField: res.data }));

// // // Return the server response so callers can use res.data
// // return res;
// // }

// // throw new Error('Failed to save profile');
// // } catch (err) {
// // // rethrow so caller's try/catch can handle revert
// // throw err;
// // }
// //above was good byt not working code
// const res = await axios.put(url, fullUserPayload);
// if (res.status === 200) {
// dispatch(updateSummaryReport({ _id: userId, updatedField: res.data }));
// return res;
// }
// throw new Error('Failed to save profile');
// };
// };
export const updateOneSummaryReport = (userId, payload) => {
const url = ENDPOINTS.USER_PROFILE(userId);
return async dispatch => {
const res = await axios.put(url, payload);
if (res.status === 200) {
dispatch(updateSummaryReport({ _id: userId, updatedField: res.data }));
return res;
}
throw new Error('Failed to save profile');
};
};

/**
* Toggle the user's bio status (posted, requested, default).
*/
export const toggleUserBio = (userId, bioPosted) => {
const url = ENDPOINTS.TOGGLE_BIO_STATUS(userId);
return async dispatch => {
try {
const res = await axios.patch(url, { bioPosted });

if (res.status === 200) {
const updatedField = { bioPosted };

// Dispatch an action to update the store
dispatch(updateSummaryReport({ _id: userId, updatedField }));

toast.success(`Bio status updated to "${bioPosted}"`);
}

return res;
} catch (error) {
toast.error('An error occurred while updating bio status.');
throw error;
}
};
};

/**
* Optimistically update filterColor for all users in selected team codes.
*/
export const updateBulkFilterColors = ({ color, teamCodes, newState }) => ({
type: reportActions.UPDATE_BULK_FILTER_COLORS,
payload: { color, teamCodes, newState },
});
16 changes: 13 additions & 3 deletions src/actions/weeklySummariesReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,31 @@ export const updateSummaryReport = ({ _id, updatedField }) => ({
* Gets all active users' summaries + a few other selected fields from the userProfile that
* might be useful for the weekly summary report.
*/
export const getWeeklySummariesReport = (weekIndex = null) => {
export const getWeeklySummariesReport = (weekIndex = null, options = {}) => {
return async dispatch => {
dispatch(fetchWeeklySummariesReportBegin());
try {
// Use the APIEndpoint from ENDPOINTS
let url = ENDPOINTS.WEEKLY_SUMMARIES_REPORT();

const timestamp = options.forceRefresh ? `ts=${Date.now()}` : '';
// Add the week parameter if provided
if (weekIndex !== null) {
// Check if the URL already has parameters
const separator = url.includes('?') ? '&' : '?';
url = `${url}${separator}week=${weekIndex}`;
url = `${url}${separator}week=${weekIndex}${timestamp ? '&' + timestamp : ''}`;
} else if (timestamp) {
const separator = url.includes('?') ? '&' : '?';
url = `${url}${separator}${timestamp}`;
}

const response = await axios.get(url);
const response = await axios.get(url, {
headers: {
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: '0',
},
});
dispatch(fetchWeeklySummariesReportSuccess(response.data));
return { status: response.status, data: response.data };
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-alert */
import React, { useState, useEffect } from 'react';
import { useSelector } from 'react-redux';
import { PieChart, Pie, Cell, Tooltip, ResponsiveContainer } from 'recharts';
Expand Down
1 change: 1 addition & 0 deletions src/components/Timelog/__tests__/TimelogNavbar.test.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-named-as-default */
import React from 'react';
import { BrowserRouter as Router , Route } from 'react-router-dom';
import { Provider } from 'react-redux';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-alert */
import TinyBarChart from '../TinyBarChart';
import Loading from '../../common/Loading';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import '@testing-library/jest-dom/extend-expect';
import moment from 'moment';
import { Provider } from 'react-redux';
// eslint-disable import/no-named-as-default
// eslint-disable-next-line import/no-named-as-default
import configureStore from 'redux-mock-store';
import SetUpFinalDayPopUp from '../SetUpFinalDayPopUp.jsx';
const mockStore = configureStore([]);
Expand Down
Loading