Skip to content

Commit b8b70c2

Browse files
committed
🎨 - fix: only showing actions if actions present
1 parent a42d951 commit b8b70c2

File tree

1 file changed

+22
-13
lines changed
  • frontend/src/pages/destructionlist

1 file changed

+22
-13
lines changed

frontend/src/pages/destructionlist/hooks.ts

+22-13
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,17 @@ export function useDataGridProps(
8282
);
8383
}, []);
8484

85-
const fields = getFields(searchParams, zaaktypeChoicesState).map((field) => {
86-
const isActiveFromStorage = fieldSelectionState?.[field.name];
87-
const isActive =
88-
typeof isActiveFromStorage === "undefined"
89-
? field.active !== false
90-
: isActiveFromStorage;
91-
return { ...field, active: isActive } as TypedField;
92-
});
85+
const hasAction = paginatedResults.results.some((zaak) => zaak.action);
86+
const fields = getFields(searchParams, zaaktypeChoicesState, hasAction).map(
87+
(field) => {
88+
const isActiveFromStorage = fieldSelectionState?.[field.name];
89+
const isActive =
90+
typeof isActiveFromStorage === "undefined"
91+
? field.active !== false
92+
: isActiveFromStorage;
93+
return { ...field, active: isActive } as TypedField;
94+
},
95+
);
9396

9497
//
9598
// Get object list.
@@ -227,6 +230,7 @@ export function useDataGridProps(
227230
export function getFields(
228231
searchParams: URLSearchParams,
229232
zaaktypeChoices: ZaaktypeChoice[],
233+
hasAction: boolean,
230234
): TypedField[] {
231235
return [
232236
{
@@ -345,10 +349,15 @@ export function getFields(
345349
{ value: "false", label: "Nee" },
346350
],
347351
},
348-
{
349-
name: "action",
350-
type: "action",
351-
filterable: false,
352-
},
352+
// Only show action column if there are actions to show
353+
...(hasAction
354+
? [
355+
{
356+
name: "action",
357+
type: "action",
358+
filterable: false,
359+
},
360+
]
361+
: []),
353362
];
354363
}

0 commit comments

Comments
 (0)