Skip to content

Commit

Permalink
Fix usePrintContext and edit page
Browse files Browse the repository at this point in the history
  • Loading branch information
ericboucher committed Sep 17, 2024
1 parent 3f42368 commit b75055b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
24 changes: 15 additions & 9 deletions apps/frontend/components/DisasterTable/DisasterTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ export const DisasterTable = ({
return () => obs.disconnect();
}, []);

// TODO - Activate column and data filtering
// This has implications on the print mechanism as well as the
// form EDIT page. We also need to confirm that this is wanted by the users.

// Generate column visibility model and hide empty columns by default.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const generateColumnVisibilityModel = (
inputColumns: GridColDef[],
inputData: Record<string, string | number | undefined>[],
Expand All @@ -110,17 +115,18 @@ export const DisasterTable = ({
}, {} as Record<string, boolean>);
};

const columnVisibilityModel = generateColumnVisibilityModel(columns, data);
const columnVisibilityModel = {}; // generateColumnVisibilityModel(columns, data);

const nonEmptyData = isEditable
? data
: data.filter(row =>
columns.some(column => {
const value = row[column.field];
const nonEmptyData = data;
// isEditable
// ? data
// : data.filter(row =>
// columns.some(column => {
// const value = row[column.field];

return value !== undefined && value !== '';
}),
);
// return value !== undefined && value !== '';
// }),
// );

const hasGroups = columnGroup.length > 0;
const withTopCellDef = columnGroup.map(x => ({
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/components/PrintWrapper/PrintWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const PrintContext = createContext<boolean | undefined>(undefined);
export const usePrintContext = () => {
const context = useContext(PrintContext);
if (context === undefined) {
throw new Error('usePrintContext must be used within a PrintProvider');
return false;
}

return context;
Expand Down

0 comments on commit b75055b

Please sign in to comment.