Skip to content

Commit

Permalink
fix:total-org-summary-filers
Browse files Browse the repository at this point in the history
  • Loading branch information
hbodgal committed Sep 20, 2024
1 parent d68be25 commit 18d4d1c
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/actions/totalOrgSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const getTotalOrgSummary = (startDate, endDate) => {
try {
const response = await axios.get(url);
dispatch(fetchTotalOrgSummaryReportSuccess(response.data));
return {status: response.status, data: response.data};
return { status: response.status, data: response.data };
} catch (error) {
dispatch(fetchTotalOrgSummaryReportError(error));
return error.response.status;
Expand Down
108 changes: 103 additions & 5 deletions src/components/TotalOrgSummary/TotalOrgSummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { getAllUsersTimeEntries } from 'actions/allUsersTimeEntries';
import { getTimeEntryForOverDate } from 'actions/index';
import { getTaskAndProjectStats } from 'actions/totalOrgSummary';

// import Select from 'react-select';
import SkeletonLoading from '../common/SkeletonLoading';
import '../Header/DarkMode.css';
import './TotalOrgSummary.css';
Expand Down Expand Up @@ -65,7 +66,24 @@ const fromDate = calculateFromDate();
const toDate = calculateToDate();
const fromOverDate = calculateFromOverDate();
const toOverDate = calculateToOverDate();

// const comparisionOptions = [
// {
// label: 'last week',
// value: 'lastweek',
// },
// {
// label: 'Same week last month',
// value: 'lastmonth',
// },
// {
// label: 'Same week last year',
// value: 'lastyear',
// },
// {
// label: 'Do not show comparision data',
// value: 'nocomparision',
// },
// ];
const aggregateTimeEntries = userTimeEntries => {
const aggregatedEntries = {};

Expand Down Expand Up @@ -99,12 +117,21 @@ const aggregateTimeEntries = userTimeEntries => {
};

function TotalOrgSummary(props) {
// const { darkMode, loading, error, allUserProfiles, volunteerstats } = props;
const { darkMode, loading, error, allUserProfiles } = props;

const [usersId, setUsersId] = useState([]);
const [usersTimeEntries, setUsersTimeEntries] = useState([]);
const [usersOverTimeEntries, setUsersOverTimeEntries] = useState([]);
const [taskProjectHours, setTaskProjectHours] = useState([]);
// const [selectedWeek, setDate] = useState({
// startDate: new Date(),
// endDate: new Date(),
// key: 'selection',
// // endDate: new Date().toISOString().split('T')[0],
// });
// const [comparisionWeek, setComparisionWeek] = useState({ startDate: '', endDate: '' });
// console.log(volunteerstats);

const dispatch = useDispatch();

Expand Down Expand Up @@ -178,6 +205,55 @@ function TotalOrgSummary(props) {
fetchData();
}, [fromDate, toDate, fromOverDate, toOverDate]);

// useEffect(() => {
// props.getTotalOrgSummary(selectedWeek.startDate, selectedWeek.endDate);
// props.hasPermission('');
// }, [selectedWeek]);

// useEffect(() => {
// if (comparisionWeek.startDate !== '') {
// props.getTotalOrgSummary(comparisionWeek.startDate, comparisionWeek.endDate);
// }
// }, [comparisionWeek]);

// this is called on date change and it sets the date range in State
// const handleChange = ranges => {
// setDate(ranges.selection);
// };

// sets comparision date based on comparision option and time period selection
// const handleComparisionPeriodChange = option => {
// const { startDate, endDate } = selectedWeek;
// const commonStartDate = new Date(startDate);
// const commonEndDate = new Date(endDate);
// switch (option.value) {
// case 'lastweek':
// // Calculate last week's start and end dates
// commonStartDate.setDate(commonStartDate.getDate() - 7 * 2); // Move back 2 weeks
// commonEndDate.setDate(commonEndDate.getDate() - 7 * 2); // Move back 2 weeks
// break;

// case 'lastmonth':
// // Set dates to last month
// commonStartDate.setMonth(commonStartDate.getMonth() - 1);
// commonEndDate.setMonth(commonEndDate.getMonth() - 1);
// break;

// case 'lastyear':
// // Set dates to last year
// commonStartDate.setFullYear(commonStartDate.getFullYear() - 1);
// commonEndDate.setFullYear(commonEndDate.getFullYear() - 1);
// break;

// default:
// throw new Error('Invalid option selected');
// }
// setComparisionWeek({
// startDate: commonStartDate.toISOString().split('T')[0],
// endDate: commonEndDate.toISOString().split('T')[0],
// });
// };

if (error) {
return (
<Container className={`container-wsr-wrapper ${darkMode ? 'bg-oxford-blue' : ''}`}>
Expand Down Expand Up @@ -213,9 +289,30 @@ function TotalOrgSummary(props) {
}`}
>
<Row>
<Col lg={{ size: 12 }}>
<Col lg={{ size: 6 }}>
<h3 className="mt-3 mb-5">Total Org Summary</h3>
</Col>
<Col lg={{ size: 2 }}>
<h3 className="mt-3 mb-5">
{/* <DateRangePicker
className="dateRange"
ranges={[selectedWeek]}
onChangse={handleChange}
/> */}
{/* DATE SELECTOR COMPONENT GOES HERE */}
{/* use selectedWeek to store dates and handleChange to update dates */}
</h3>
</Col>
<Col lg={{ size: 2 }} style={{ paddingTop: '20px' }}>
{/* <Select
options={comparisionOptions}
onChange={option => handleComparisionPeriodChange(option)}
default
/> */}
</Col>
<Col lg={{ size: 2 }}>
<h3 className="mt-3 mb-5">PDF Button</h3>
</Col>
</Row>
<hr />
<AccordianWrapper title="Volunteer Status">
Expand Down Expand Up @@ -326,22 +423,23 @@ function TotalOrgSummary(props) {
</Container>
);
}

// totalOrgSummary: state.totalOrgSummary,
const mapStateToProps = state => ({
error: state.error,
loading: state.loading,
totalOrgSummary: state.totalOrgSummary,
volunteerstats: state.totalOrgSummary.volunteerstats,
role: state.auth.user.role,
auth: state.auth,
darkMode: state.theme.darkMode,
allUserProfiles: state.allUserProfiles,
});

const mapDispatchToProps = dispatch => ({
getTotalOrgSummary: () => dispatch(getTotalOrgSummary(fromDate, toDate)),
// getTotalOrgSummary: () => dispatch(getTotalOrgSummary(fromDate, toDate)),
getTaskAndProjectStats: () => dispatch(getTaskAndProjectStats(fromDate, toDate)),
hasPermission: permission => dispatch(hasPermission(permission)),
getAllUserProfile: () => dispatch(getAllUserProfile()),
getTotalOrgSummary: (startDate, endDate) => dispatch(getTotalOrgSummary(startDate, endDate)),
});

export default connect(mapStateToProps, mapDispatchToProps)(TotalOrgSummary);
14 changes: 7 additions & 7 deletions src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import { infoCollectionsReducer } from './informationReducer';
import { weeklySummariesAIPromptReducer } from './weeklySummariesAIPromptReducer';
import { mouseoverTextReducer } from './mouseoverTextReducer';
import notificationReducer from './notificationReducer';
import { weeklySummaryRecipientsReducer } from "./weeklySummaryRecipientsReducer";
import { followUpReducer } from "./followUpReducer";
import { weeklySummaryRecipientsReducer } from './weeklySummaryRecipientsReducer';
import { followUpReducer } from './followUpReducer';
import { BlueSquareEmailAssignment } from './blueSquareEmailBcc';
import {userProjectsByUserNameReducer} from './userProjectsByUserNameReducer';
import { userProjectsByUserNameReducer } from './userProjectsByUserNameReducer';

// bm dashboard
import { materialsReducer } from './bmdashboard/materialsReducer';
Expand All @@ -46,7 +46,7 @@ import { bmInvUnitReducer } from './bmdashboard/inventoryUnitReducer';
import { consumablesReducer } from './bmdashboard/consumablesReducer';
import { toolReducer } from './bmdashboard/toolReducer';
import { equipmentReducer } from './bmdashboard/equipmentReducer';
import { timeOffRequestsReducer } from "./timeOffRequestReducer";
import { timeOffRequestsReducer } from './timeOffRequestReducer';
import { totalOrgSummaryReducer } from './totalOrgSummaryReducer';
import { allUsersTimeEntriesReducer } from './allUsersTimeEntriesReducer';

Expand All @@ -73,9 +73,9 @@ const localReducers = {
ownerMessage: ownerMessageReducer,
infoCollections: infoCollectionsReducer,
mouseoverText: mouseoverTextReducer,
weeklySummaryRecipients:weeklySummaryRecipientsReducer,
weeklySummaryRecipients: weeklySummaryRecipientsReducer,
notification: notificationReducer,
userFollowUp : followUpReducer,
userFollowUp: followUpReducer,
userProjectsByUserNameReducer: userProjectsByUserNameReducer,
blueSquareEmailAssignment : BlueSquareEmailAssignment,
totalOrgSummary: totalOrgSummaryReducer,
Expand All @@ -93,7 +93,7 @@ const localReducers = {
bmEquipments: equipmentReducer,
bmInvUnits: bmInvUnitReducer,
bmConsumables: consumablesReducer,
bmReusables: reusablesReducer
bmReusables: reusablesReducer,
};

const sessionReducers = {
Expand Down

0 comments on commit 18d4d1c

Please sign in to comment.