Skip to content

Commit 0f027fe

Browse files
♻️ - refactor: clean up some code
1 parent 13be273 commit 0f027fe

File tree

8 files changed

+28
-25
lines changed

8 files changed

+28
-25
lines changed

frontend/src/fixtures/destructionList.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
import { DestructionList } from "../lib/api/destructionLists";
1+
import {
2+
DestructionList,
3+
DestructionListRead,
4+
} from "../lib/api/destructionLists";
25
import { createObjectFactory } from "./factory";
36
import { defaultAssignees } from "./reviewers";
47
import { userFactory } from "./user";
58

6-
const FIXTURE_DESTRUCTION_LIST: DestructionList = {
9+
const FIXTURE_DESTRUCTION_LIST: DestructionListRead = {
710
pk: 1,
811
uuid: "00000000-0000-0000-0000-000000000000",
912
name: "My First Destruction List",
@@ -18,7 +21,7 @@ const FIXTURE_DESTRUCTION_LIST: DestructionList = {
1821
statusChanged: "2024-07-11:16:57",
1922
};
2023

21-
const destructionListFactory = createObjectFactory<DestructionList>(
24+
const destructionListFactory = createObjectFactory<DestructionListRead>(
2225
FIXTURE_DESTRUCTION_LIST,
2326
);
2427

frontend/src/fixtures/reviewers.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import { DestructionListAssigneeRead } from "../lib/api/destructionLists";
12
import { beoordelaarFactory, recordManagerFactory } from "./user";
23

3-
const defaultAssignees = [
4+
const defaultAssignees: DestructionListAssigneeRead[] = [
45
{
56
user: recordManagerFactory(),
6-
role: "record_manager",
7+
role: "author",
78
},
89
{
910
user: beoordelaarFactory(),

frontend/src/lib/api/destructionLists.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export async function createDestructionList(
109109
*/
110110
export async function getDestructionList(uuid: string) {
111111
const response = await request("GET", `/destruction-lists/${uuid}/`);
112-
const promise: Promise<DestructionList> = response.json();
112+
const promise: Promise<DestructionListRead> = response.json();
113113
return promise;
114114
}
115115

frontend/src/lib/api/reviewResponse.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export async function getLatestReviewResponse(
5050
| {
5151
review?: Review["pk"];
5252
},
53-
) {
53+
): Promise<ReviewResponse | undefined> {
5454
const reviews = await listReviewResponses({
5555
...params,
5656
});

frontend/src/pages/destructionlist/detail/DestructionListDetail.loader.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { listArchivists } from "../../../lib/api/archivist";
55
import { AuditLogItem, listAuditLog } from "../../../lib/api/auditLog";
66
import { User, whoAmI } from "../../../lib/api/auth";
77
import {
8-
DestructionList,
8+
DestructionListRead,
99
getDestructionList,
1010
} from "../../../lib/api/destructionLists";
1111
import {
@@ -19,6 +19,10 @@ import {
1919
getLatestReview,
2020
listReviewItems,
2121
} from "../../../lib/api/review";
22+
import {
23+
ReviewResponse,
24+
getLatestReviewResponse,
25+
} from "../../../lib/api/reviewResponse";
2226
import { listReviewers } from "../../../lib/api/reviewers";
2327
import { PaginatedZaken, listZaken } from "../../../lib/api/zaken";
2428
import {
@@ -34,7 +38,7 @@ import {
3438
export interface DestructionListDetailContext {
3539
storageKey: string;
3640

37-
destructionList: DestructionList;
41+
destructionList: DestructionListRead;
3842
destructionListItems: PaginatedDestructionListItems;
3943
logItems: AuditLogItem[];
4044

@@ -47,6 +51,7 @@ export interface DestructionListDetailContext {
4751

4852
review: Review | null;
4953
reviewItems: ReviewItemWithZaak[] | null;
54+
reviewResponse?: ReviewResponse;
5055

5156
selectieLijstKlasseChoicesMap: Record<string, Option[]> | null;
5257
}
@@ -162,6 +167,7 @@ export const destructionListDetailLoader = loginRequired(
162167

163168
const [
164169
destructionListItems,
170+
reviewResponse,
165171
logItems,
166172
zaakSelection,
167173
allZaken,
@@ -171,6 +177,10 @@ export const destructionListDetailLoader = loginRequired(
171177
selectieLijstKlasseChoicesMap,
172178
] = await Promise.all([
173179
getDestructionListItems(),
180+
review &&
181+
getLatestReviewResponse({
182+
review: review.pk,
183+
}),
174184
listAuditLog(destructionList.uuid),
175185
getZaakSelection(storageKey),
176186
getSelectableZaken(),
@@ -203,6 +213,7 @@ export const destructionListDetailLoader = loginRequired(
203213

204214
review: review,
205215
reviewItems: reviewItemsWithZaak,
216+
reviewResponse,
206217

207218
selectieLijstKlasseChoicesMap,
208219
};

frontend/src/pages/destructionlist/detail/components/DestructionListAuditLog/DestructionListAuditLog.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ import { useLoaderData } from "react-router-dom";
44
import { AuditLogItem } from "../../../../../lib/api/auditLog";
55
import { formatDate } from "../../../../../lib/format/date";
66
import { formatUser } from "../../../../../lib/format/user";
7+
import { DestructionListDetailContext } from "../../DestructionListDetail.loader";
78

89
/**
910
* Toolbar on top of destruction list page providing meta information.
1011
* @constructor
1112
*/
1213
export function DestructionListAuditLog() {
13-
const { logItems } = useLoaderData() as {
14-
logItems: AuditLogItem[];
15-
};
14+
const { logItems } = useLoaderData() as DestructionListDetailContext;
1615

1716
const objectList = logItems.map((logItem) => ({
1817
Datum: formatDate(logItem.timestamp),

frontend/src/pages/destructionlist/detail/components/DestructionListToolbar/DestructionListToolbar.tsx

+2-12
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,13 @@ import {
1212
import { useLoaderData } from "react-router-dom";
1313

1414
import { ProcessingStatusBadge } from "../../../../../components";
15-
import { AuditLogItem } from "../../../../../lib/api/auditLog";
16-
import { User } from "../../../../../lib/api/auth";
17-
import { DestructionListRead } from "../../../../../lib/api/destructionLists";
18-
import { Review } from "../../../../../lib/api/review";
19-
import { ReviewResponse } from "../../../../../lib/api/reviewResponse";
2015
import { formatDate } from "../../../../../lib/format/date";
2116
import { formatUser } from "../../../../../lib/format/user";
2217
import {
2318
REVIEW_DECISION_LEVEL_MAPPING,
2419
REVIEW_DECISION_MAPPING,
2520
} from "../../../../constants";
21+
import { DestructionListDetailContext } from "../../DestructionListDetail.loader";
2622
import { DestructionListAuditLog } from "../DestructionListAuditLog";
2723
import { DestructionListReviewer } from "../index";
2824

@@ -36,13 +32,7 @@ export type DestructionListToolbarProps = {
3632
*/
3733
export function DestructionListToolbar({ title }: DestructionListToolbarProps) {
3834
const { destructionList, logItems, review, reviewers, reviewResponse } =
39-
useLoaderData() as {
40-
destructionList: DestructionListRead;
41-
logItems: AuditLogItem[];
42-
review: Review;
43-
reviewers: User[];
44-
reviewResponse?: ReviewResponse;
45-
};
35+
useLoaderData() as DestructionListDetailContext;
4636

4737
const properties = (
4838
<Grid>

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

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export function useSecondaryNavigation(): ToolbarItem[] {
4848
archivists,
4949
review,
5050
reviewItems,
51-
zaakSelection, // FIXME Remove the use of full selection.
5251
} = useLoaderData() as DestructionListDetailContext;
5352

5453
const confirm = useConfirm();

0 commit comments

Comments
 (0)