Skip to content

Commit 8a142aa

Browse files
🐛 - fix: fix a bug that caused the secondary navigation to show the wrong button
1 parent 0f027fe commit 8a142aa

File tree

2 files changed

+58
-67
lines changed

2 files changed

+58
-67
lines changed

frontend/src/pages/destructionlist/detail/DestructionListDetail.stories.tsx

+2-12
Original file line numberDiff line numberDiff line change
@@ -571,26 +571,16 @@ export const CancelPlannedDestruction: Story = {
571571
},
572572
play: async (context) => {
573573
const canvas = within(context.canvasElement);
574-
const vernietigingStarten = await canvas.findByText<HTMLButtonElement>(
575-
"Vernietigen starten",
576-
);
577-
expect(vernietigingStarten).toBeDisabled();
578574
await clickButton({
579575
...context,
580576
parameters: {
581577
...context.parameters,
582578
name: "Vernietigen annuleren",
583579
},
584580
});
585-
await userEvent.click(document.activeElement as HTMLInputElement, {
586-
delay: 10,
587-
});
588-
userEvent.type(document.activeElement as HTMLInputElement, "Test Comment", {
581+
const input = await canvas.findByLabelText("Opmerking");
582+
userEvent.type(input, "Test Comment", {
589583
delay: 10,
590584
});
591-
const submit = await canvas.findByText<HTMLButtonElement>(
592-
"Vernietigen annuleren",
593-
);
594-
expect(submit).not.toBeDisabled();
595585
},
596586
};

frontend/src/pages/destructionlist/detail/hooks/useSecondaryNavigation.tsx

+56-55
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,8 @@ export function useSecondaryNavigation(): ToolbarItem[] {
178178

179179
/**
180180
* Returns whether `destructionList` is bound to be destroyed in the near future.
181-
* @param destructionList
182181
*/
183-
const isPlannedForDestruction = (destructionList: DestructionList) => {
182+
const isPlannedForDestruction = () => {
184183
return (
185184
destructionList.status === "ready_to_delete" &&
186185
!!destructionList.plannedDestructionDate &&
@@ -288,63 +287,65 @@ export function useSecondaryNavigation(): ToolbarItem[] {
288287
}
289288

290289
if (canTriggerDestruction(user, destructionList)) {
291-
return [
292-
destructionList.processingStatus === "new" ? (
293-
<></>
294-
) : (
295-
<ProcessingStatusBadge
296-
key={destructionList.pk}
297-
processingStatus={destructionList.processingStatus}
298-
/>
299-
),
300-
"spacer",
301-
["new", "failed"].includes(destructionList.processingStatus) ? (
302-
{
303-
bold: true,
304-
children: (
305-
<>
306-
<Solid.TrashIcon />
307-
{destructionList.processingStatus === "new"
308-
? "Vernietigen starten"
309-
: "Vernietigen herstarten"}
310-
</>
311-
),
312-
variant: "danger",
313-
pad: "h",
314-
onClick: () =>
315-
formDialog(
316-
"Zaken definitief vernietigen",
317-
`U staat op het punt om ${destructionListItems.count} zaken definitief te vernietigen`,
318-
[
290+
if (!isPlannedForDestruction()) {
291+
return [
292+
destructionList.processingStatus === "new" ? (
293+
<></>
294+
) : (
295+
<ProcessingStatusBadge
296+
key={destructionList.pk}
297+
processingStatus={destructionList.processingStatus}
298+
/>
299+
),
300+
"spacer",
301+
["new", "failed"].includes(destructionList.processingStatus) ? (
302+
{
303+
bold: true,
304+
children: (
305+
<>
306+
<Solid.TrashIcon />
307+
{destructionList.processingStatus === "new"
308+
? "Vernietigen starten"
309+
: "Vernietigen herstarten"}
310+
</>
311+
),
312+
variant: "danger",
313+
pad: "h",
314+
onClick: () =>
315+
formDialog(
316+
"Zaken definitief vernietigen",
317+
`U staat op het punt om ${destructionListItems.count} zaken definitief te vernietigen`,
318+
[
319+
{
320+
label: "Type naam van de lijst ter bevestiging",
321+
name: "name",
322+
placeholder: "Naam van de vernietigingslijst",
323+
required: true,
324+
},
325+
],
326+
`${destructionListItems.count} zaken vernietigen`,
327+
"Annuleren",
328+
handleDestroy,
329+
undefined,
330+
undefined,
319331
{
320-
label: "Type naam van de lijst ter bevestiging",
321-
name: "name",
322-
placeholder: "Naam van de vernietigingslijst",
323-
required: true,
332+
buttonProps: {
333+
variant: "danger",
334+
},
335+
validate: validateDestroy,
336+
validateOnChange: true,
337+
role: "form",
324338
},
325-
],
326-
`${destructionListItems.count} zaken vernietigen`,
327-
"Annuleren",
328-
handleDestroy,
329-
undefined,
330-
undefined,
331-
{
332-
buttonProps: {
333-
variant: "danger",
334-
},
335-
validate: validateDestroy,
336-
validateOnChange: true,
337-
role: "form",
338-
},
339-
),
340-
}
341-
) : (
342-
<></>
343-
),
344-
];
339+
),
340+
}
341+
) : (
342+
<></>
343+
),
344+
];
345+
}
345346
}
346347

347-
if (isPlannedForDestruction(destructionList)) {
348+
if (isPlannedForDestruction()) {
348349
return [
349350
{
350351
bold: true,

0 commit comments

Comments
 (0)