diff --git a/src/scenes/Dashboard/ProgressReportsWidget/ProgressReportsExpandedGrid.tsx b/src/scenes/Dashboard/ProgressReportsWidget/ProgressReportsExpandedGrid.tsx index b1d93e004..a0489cd65 100644 --- a/src/scenes/Dashboard/ProgressReportsWidget/ProgressReportsExpandedGrid.tsx +++ b/src/scenes/Dashboard/ProgressReportsWidget/ProgressReportsExpandedGrid.tsx @@ -8,6 +8,7 @@ import { useGridApiRef, } from '@mui/x-data-grid-pro'; import { entries } from '@seedcompany/common'; +import { merge } from 'lodash'; import { useMemo } from 'react'; import { extendSx } from '~/common'; import { @@ -29,6 +30,7 @@ import { ProgressReportsColumnMap, ProgressReportsGrid, ProgressReportsGridProps, + useProgressReportsDataGrid, } from './ProgressReportsGrid'; const COLLAPSED_ROW_HEIGHT = 54; @@ -116,18 +118,24 @@ export const ProgressReportsExpandedGrid = ( props: Omit ) => { const apiRef = useGridApiRef(); - const { expanded, onMouseDown, onRowClick } = useExpandedSetup(); - const slotProps = useMemo( - (): DataGridProps['slotProps'] => ({ - row: { - onMouseDown, - }, - }), + const dataGridProps = useProgressReportsDataGrid({ + ...props, + apiRef, + columns, + }); + + const mouseSlotProps = useMemo( + (): DataGridProps['slotProps'] => ({ row: { onMouseDown } }), [onMouseDown] ); + const slotProps = useMemo( + () => merge({}, dataGridProps.slotProps, mouseSlotProps), + [dataGridProps.slotProps, mouseSlotProps] + ); + return ( { + const source = useMemo(() => { + return { + query: ProgressReportsDocument, + variables: { + input: { + filter: { + start: { + afterInclusive: quarter.startOf('quarter'), + }, + end: { + beforeInclusive: quarter.endOf('quarter'), + }, + }, + }, + }, + listAt: 'progressReports', + initialInput: { + sort: 'status', + order: 'DESC', + }, + } as const; + }, [quarter]); + const [dataGridProps] = useDataGridSource({ + ...source, + apiRef: props.apiRef, + }); + + return dataGridProps; +}; + export const ProgressReportsColumnMap = { project: { headerName: 'Project', @@ -179,32 +213,7 @@ export const ProgressReportsGrid = ({ quarter, ...props }: ProgressReportsGridProps) => { - const source = useMemo(() => { - return { - query: ProgressReportsDocument, - variables: { - input: { - filter: { - start: { - afterInclusive: quarter.startOf('quarter'), - }, - end: { - beforeInclusive: quarter.endOf('quarter'), - }, - }, - }, - }, - listAt: 'progressReports', - initialInput: { - sort: 'status', - order: 'DESC', - }, - } as const; - }, [quarter]); - const [dataGridProps] = useDataGridSource({ - ...source, - apiRef: props.apiRef, - }); + const dataGridProps = useProgressReportsDataGrid({ quarter, ...props }); const slots = useMemo( () =>