Skip to content

Commit

Permalink
Add cumulative progress column
Browse files Browse the repository at this point in the history
  • Loading branch information
atGit2021 authored and CarsonF committed Oct 14, 2024
1 parent 785560f commit 3d4a6f6
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const initialState = {
'varianceExplanation.reasons': false,
'engagement.project.isMember': false,
'engagement.project.pinned': false,
cumulativeSummary: false,
},
},
} satisfies DataGridProps['initialState'];
Expand Down
47 changes: 47 additions & 0 deletions src/scenes/Dashboard/ProgressReportsWidget/ProgressReportsGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
useDataGridSource,
} from '~/components/Grid';
import { Link } from '~/components/Routing';
import { ProgressSummaryFragment } from '../../ProgressReports/Detail/ProgressReportDetail.graphql';
import { ExpansionCell } from './ExpansionCell';
import {
ProgressReportsDataGridRowFragment as ProgressReport,
Expand Down Expand Up @@ -97,6 +98,13 @@ export const ProgressReportsColumnMap = {
filterable: false,
valueGetter: (_, row) => row.varianceExplanation.scheduleStatus,
},
cumulativeSummary: {
headerName: 'Cumulative Progress',
minWidth: 200,
sortable: false,
filterable: false,
renderCell: ({ value }) => <CumulativeProgressColumn value={value} />,
},
teamNews: {
headerName: 'Team News',
width: 400,
Expand Down Expand Up @@ -213,3 +221,42 @@ export const ProgressReportsGrid = ({
/>
);
};

const CumulativeProgressColumn = ({
value,
}: {
value: ProgressSummaryFragment | null;
}) => {
const progressData = {
Planned: value?.planned,
Actual: value?.actual,
Variance: value?.variance,
};

return (
<Box
sx={{
my: 1,
display: 'flex',
justifyContent: 'space-between',
alignItems: 'left',
gap: 2,
}}
>
{Object.entries(progressData).map(([label, data]) =>
cumulativeProgressData(label, data)
)}
</Box>
);
};

const cumulativeProgressData = (label: string, data: number | undefined) => {
const displayValue = data === undefined ? '—' : `${(data * 100).toFixed(1)}%`;

return (
<Box sx={{ textAlign: 'left' }}>
<Typography variant="body2">{displayValue}</Typography>
<Typography variant="body2">{label}</Typography>
</Box>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ fragment progressReportsDataGridRow on ProgressReport {
value
}
}
cumulativeSummary {
...ProgressSummary
}
teamNews {
items {
id
Expand Down

0 comments on commit 3d4a6f6

Please sign in to comment.