-
Notifications
You must be signed in to change notification settings - Fork 9
3604 maintenence tracking spending on project overview #3638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a646f11
60954c7
a6d160d
d404ea8
0e5d66f
309ee76
22f2487
2b97432
cf2047d
c8aa259
4abc205
6d9e8bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,247 @@ | ||||||||||||||
| import React, { useMemo } from 'react'; | ||||||||||||||
| import { Box, Typography, Link, LinearProgress } from '@mui/material'; | ||||||||||||||
| import { GridColDef, GridRenderCellParams } from '@mui/x-data-grid'; | ||||||||||||||
| import { useAllReimbursementRequests } from '../../hooks/finance.hooks'; | ||||||||||||||
| import { useSingleProject } from '../../hooks/projects.hooks'; | ||||||||||||||
| import { WbsNumber, ReimbursementRequest, WBSElementData, equalsWbsNumber, ReimbursementStatusType } from 'shared'; | ||||||||||||||
| import LoadingIndicator from '../../components/LoadingIndicator'; | ||||||||||||||
| import { createReimbursementRequestRowData, cleanReimbursementRequestStatus } from '../../utils/reimbursement-request.utils'; | ||||||||||||||
| import NERDataGrid, { MapRowResult } from '../../components/NERDataGrid'; | ||||||||||||||
| import { routes } from '../../utils/routes'; | ||||||||||||||
| import { fullNamePipe, centsToDollar, datePipe } from '../../utils/pipes'; | ||||||||||||||
|
|
||||||||||||||
| interface ProjectSpendingHistoryProps { | ||||||||||||||
| wbsNum: WbsNumber; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| const getStatusColor = (status: ReimbursementStatusType): string => { | ||||||||||||||
| switch (status) { | ||||||||||||||
| case 'REIMBURSED': | ||||||||||||||
| return '#549d49'; | ||||||||||||||
| case 'DENIED': | ||||||||||||||
| return '#dd514c'; | ||||||||||||||
| case 'PENDING_FINANCE': | ||||||||||||||
| case 'SABO_SUBMITTED': | ||||||||||||||
| case 'PENDING_SABO_SUBMISSION': | ||||||||||||||
| case 'PENDING_LEADERSHIP_APPROVAL': | ||||||||||||||
| case 'LEADERSHIP_APPROVED': | ||||||||||||||
| case 'ADVISOR_APPROVED': | ||||||||||||||
| return '#997b3e'; | ||||||||||||||
| default: | ||||||||||||||
| return '#797a7a'; | ||||||||||||||
| } | ||||||||||||||
| }; | ||||||||||||||
|
|
||||||||||||||
| const columns: GridColDef[] = [ | ||||||||||||||
| { | ||||||||||||||
| field: 'identifier', | ||||||||||||||
| headerName: 'RR #', | ||||||||||||||
| flex: 0.4, | ||||||||||||||
| minWidth: 80, | ||||||||||||||
| renderCell: (params: GridRenderCellParams) => ( | ||||||||||||||
| <Link | ||||||||||||||
| href={`${routes.REIMBURSEMENT_REQUESTS}/all-requests/${(params.row as any).reimbursementRequestId}`} | ||||||||||||||
| underline="hover" | ||||||||||||||
| color="primary" | ||||||||||||||
| onClick={(e) => e.stopPropagation()} | ||||||||||||||
| > | ||||||||||||||
| #{params.value} | ||||||||||||||
| </Link> | ||||||||||||||
| ) | ||||||||||||||
| }, | ||||||||||||||
| { | ||||||||||||||
| field: 'submitter', | ||||||||||||||
| headerName: 'Submitter', | ||||||||||||||
| flex: 1, | ||||||||||||||
| minWidth: 150, | ||||||||||||||
| valueGetter: (params: any) => fullNamePipe(params.row.submitter) | ||||||||||||||
| }, | ||||||||||||||
| { | ||||||||||||||
| field: 'products', | ||||||||||||||
| headerName: 'Products', | ||||||||||||||
| flex: 2, | ||||||||||||||
| minWidth: 250, | ||||||||||||||
| valueGetter: (params: any) => params.row.reimbursementProducts?.map((p: any) => p.name).join(', ') || 'No products' | ||||||||||||||
| }, | ||||||||||||||
| { | ||||||||||||||
| field: 'dateSubmitted', | ||||||||||||||
| headerName: 'Date Submitted', | ||||||||||||||
| flex: 0.7, | ||||||||||||||
| minWidth: 130, | ||||||||||||||
| valueGetter: (params: any) => datePipe(params.row.dateSubmitted) | ||||||||||||||
| }, | ||||||||||||||
| { | ||||||||||||||
| field: 'status', | ||||||||||||||
| headerName: 'Status', | ||||||||||||||
| flex: 1, | ||||||||||||||
| minWidth: 220, | ||||||||||||||
| renderCell: (params: GridRenderCellParams) => ( | ||||||||||||||
| <Box | ||||||||||||||
| sx={{ | ||||||||||||||
| padding: '3px 8px', | ||||||||||||||
| display: 'inline-flex', | ||||||||||||||
| borderRadius: '8px', | ||||||||||||||
| backgroundColor: getStatusColor(params.value as ReimbursementStatusType), | ||||||||||||||
| fontWeight: 700, | ||||||||||||||
| whiteSpace: 'nowrap' | ||||||||||||||
| }} | ||||||||||||||
| > | ||||||||||||||
| {cleanReimbursementRequestStatus(params.value as ReimbursementStatusType)} | ||||||||||||||
| </Box> | ||||||||||||||
| ) | ||||||||||||||
| }, | ||||||||||||||
| { | ||||||||||||||
| field: 'amount', | ||||||||||||||
| headerName: 'Total Amount', | ||||||||||||||
| flex: 0.5, | ||||||||||||||
| minWidth: 110, | ||||||||||||||
| valueGetter: (params: any) => `$${centsToDollar(params.row.amount as number)}` | ||||||||||||||
| } | ||||||||||||||
| ]; | ||||||||||||||
|
|
||||||||||||||
| const ProjectSpendingHistory: React.FC<ProjectSpendingHistoryProps> = ({ wbsNum }) => { | ||||||||||||||
| const { data: allReimbursementRequests, isLoading: rrLoading, isError: rrError } = useAllReimbursementRequests(); | ||||||||||||||
| const { data: project, isLoading: projectLoading } = useSingleProject(wbsNum); | ||||||||||||||
|
|
||||||||||||||
| const reimbursementRequests = useMemo(() => { | ||||||||||||||
| if (!allReimbursementRequests || !project) return []; | ||||||||||||||
| return allReimbursementRequests.filter((rr) => | ||||||||||||||
| rr.reimbursementProducts.some((product) => { | ||||||||||||||
| const reason = product.reimbursementProductReason; | ||||||||||||||
| if ((reason as WBSElementData).wbsNum) { | ||||||||||||||
| return equalsWbsNumber((reason as WBSElementData).wbsNum, { ...wbsNum, workPackageNumber: 0 }); | ||||||||||||||
|
||||||||||||||
| return equalsWbsNumber((reason as WBSElementData).wbsNum, { ...wbsNum, workPackageNumber: 0 }); | |
| const reasonWbs = (reason as WBSElementData).wbsNum; | |
| return ( | |
| reasonWbs.carNumber === wbsNum.carNumber && | |
| reasonWbs.projectNumber === wbsNum.projectNumber | |
| ); |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The project dependency in the useMemo is unnecessary since project is only used for a null check and doesn't affect the filtering logic. The filter only depends on allReimbursementRequests and wbsNum. Removing the project dependency would prevent unnecessary recalculation when project data changes but the reimbursement requests haven't changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tab ordering logic is incorrect. Tab index 7 is mapped to PartsReviewPage but should be mapped to ProjectSpendingHistory based on the tab array order. The new Budget tab is at index 7 (8th position starting from 0), but the conditional checks tab === 7 and renders PartsReviewPage instead. The correct logic should check tab === 7 for ProjectSpendingHistory and tab === 6 should remain for PartsReviewPage. Currently, the Budget tab (index 7) will incorrectly show PartsReviewPage.