Skip to content

Commit ec2927c

Browse files
♻️ - refactor: move destruction list status badge to secondary navigation
1 parent 86c88ce commit ec2927c

File tree

6 files changed

+109
-11
lines changed

6 files changed

+109
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { Meta, StoryObj } from "@storybook/react";
2+
import { within } from "@storybook/test";
3+
4+
import { destructionListFactory } from "../../fixtures/destructionList";
5+
import { DestructionListStatusBadge } from "./DestructionListStatusBadge";
6+
7+
const meta: Meta<typeof DestructionListStatusBadge> = {
8+
title: "Components/DestructionListStatusBadge",
9+
component: DestructionListStatusBadge,
10+
};
11+
12+
export default meta;
13+
type Story = StoryObj<typeof meta>;
14+
15+
export const DestructionListStatusNew: Story = {
16+
args: {
17+
destructionList: destructionListFactory({ status: "new" }),
18+
},
19+
play: async ({ canvasElement }) => {
20+
await within(canvasElement).findByText("Nieuw");
21+
},
22+
};
23+
24+
export const DestructionListStatusChangesRequested: Story = {
25+
args: {
26+
destructionList: destructionListFactory({ status: "changes_requested" }),
27+
},
28+
play: async ({ canvasElement }) => {
29+
await within(canvasElement).findByText("Wijzigingen aangevraagd");
30+
},
31+
};
32+
33+
export const DestructionListStatusReadyToReview: Story = {
34+
args: {
35+
destructionList: destructionListFactory({ status: "ready_to_review" }),
36+
},
37+
play: async ({ canvasElement }) => {
38+
await within(canvasElement).findByText("Klaar voor beoordeling");
39+
},
40+
};
41+
42+
export const DestructionListStatusInternallyReviewed: Story = {
43+
args: {
44+
destructionList: destructionListFactory({ status: "internally_reviewed" }),
45+
},
46+
play: async ({ canvasElement }) => {
47+
await within(canvasElement).findByText("Intern beoordeeld");
48+
},
49+
};
50+
51+
export const DestructionListStatusReadyForArchivist: Story = {
52+
args: {
53+
destructionList: destructionListFactory({ status: "ready_for_archivist" }),
54+
},
55+
play: async ({ canvasElement }) => {
56+
await within(canvasElement).findByText("Klaar voor archivaris");
57+
},
58+
};
59+
60+
export const DestructionListStatusReadyToDelete: Story = {
61+
args: {
62+
destructionList: destructionListFactory({ status: "ready_to_delete" }),
63+
},
64+
play: async ({ canvasElement }) => {
65+
await within(canvasElement).findByText("Klaar om te vernietigen");
66+
},
67+
};
68+
69+
export const DestructionListStatusDeleted: Story = {
70+
args: {
71+
destructionList: destructionListFactory({ status: "deleted" }),
72+
},
73+
play: async ({ canvasElement }) => {
74+
await within(canvasElement).findByText("Vernietigd");
75+
},
76+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Badge, ucFirst } from "@maykin-ui/admin-ui";
2+
import React from "react";
3+
4+
import { DestructionList } from "../../lib/api/destructionLists";
5+
import { STATUS_LEVEL_MAPPING, STATUS_MAPPING } from "../../pages/constants";
6+
7+
type DestructionListStatusBadgeProps = {
8+
destructionList: DestructionList;
9+
};
10+
11+
export const DestructionListStatusBadge: React.FC<
12+
DestructionListStatusBadgeProps
13+
> = ({ destructionList }) => {
14+
return (
15+
<Badge key="status" level={STATUS_LEVEL_MAPPING[destructionList.status]}>
16+
{ucFirst(STATUS_MAPPING[destructionList.status])}
17+
</Badge>
18+
);
19+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./DestructionListStatusBadge";

frontend/src/components/DestructionListToolbar/DestructionListToolbar.tsx

-8
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,6 @@ export function DestructionListToolbar({
7272
label: "Bevat gevoelige informatie",
7373
value: destructionList.containsSensitiveInfo,
7474
},
75-
status: {
76-
label: "Status",
77-
value: (
78-
<Badge level={STATUS_LEVEL_MAPPING[destructionList.status]}>
79-
{ucFirst(STATUS_MAPPING[destructionList.status])}
80-
</Badge>
81-
),
82-
},
8375
aangemaakt: {
8476
label: "Aangemaakt",
8577
value: formatDate(new Date(destructionList.created)),

frontend/src/components/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from "./DestructionListAuditLog";
22
export * from "./DestructionListReviewer";
33
export * from "./DestructionListToolbar";
4+
export * from "./DestructionListStatusBadge";
45
export * from "./ProcessingStatusBadge";

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

+12-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import {
88
import { useContext, useMemo } from "react";
99
import { useNavigation, useRouteLoaderData } from "react-router-dom";
1010

11-
import { ProcessingStatusBadge } from "../../../../components";
11+
import {
12+
DestructionListStatusBadge,
13+
ProcessingStatusBadge,
14+
} from "../../../../components";
1215
import { ZaakSelectionContext } from "../../../../contexts";
1316
import { useSubmitAction } from "../../../../hooks";
1417
import { ReviewItemResponse } from "../../../../lib/api/reviewResponse";
@@ -19,7 +22,7 @@ import {
1922
canTriggerDestruction,
2023
} from "../../../../lib/auth/permissions";
2124
import { formatUser } from "../../../../lib/format/user";
22-
import { getFilteredZaakSelection } from "../../../../lib/zaakSelection/zaakSelection";
25+
import { getFilteredZaakSelection } from "../../../../lib/zaakSelection";
2326
import {
2427
UpdateDestructionListAction,
2528
UpdateDestructionListProcessReviewAction,
@@ -382,6 +385,11 @@ export function useSecondaryNavigation(): ToolbarItem[] {
382385
// LEFT
383386
//
384387

388+
<DestructionListStatusBadge
389+
key="status"
390+
destructionList={destructionList}
391+
/>,
392+
385393
// Status: "ready_to_delete", badge and spacer
386394
getPermittedToolbarItem(
387395
<ProcessingStatusBadge
@@ -392,7 +400,8 @@ export function useSecondaryNavigation(): ToolbarItem[] {
392400
canTriggerDestruction(user, destructionList) &&
393401
destructionList.processingStatus !== "new",
394402
),
395-
getPermittedToolbarItem("spacer", canTriggerDestruction),
403+
404+
"spacer",
396405

397406
//
398407
// Right

0 commit comments

Comments
 (0)