Skip to content

Commit 752569c

Browse files
#497 - feat: automatically update status when co review is completed
1 parent 25df141 commit 752569c

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

frontend/src/components/DestructionListReviewer/DestructionListReviewer.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export function DestructionListReviewer({
190190
},
191191
};
192192
}, {}),
193-
[assignedCoReviewers],
193+
[assignedCoReviewers, coReviews],
194194
);
195195

196196
return (

frontend/src/hooks/useCoReviews.ts

+8-10
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useEffect, useState } from "react";
33
import { CoReview, listCoReviews } from "../lib/api/coReview";
44
import { DestructionList } from "../lib/api/destructionLists";
55
import { useAlertOnError } from "./useAlertOnError";
6+
import { usePoll } from "./usePoll";
67

78
/**
89
* Hook resolving co reviews
@@ -13,16 +14,13 @@ export function useCoReviews(destructionList?: DestructionList): CoReview[] {
1314
);
1415

1516
const [valueState, setValueState] = useState<CoReview[]>([]);
16-
useEffect(() => {
17-
if (!destructionList) {
18-
setValueState([]);
19-
return;
20-
}
21-
22-
listCoReviews({ destructionList__uuid: destructionList.uuid })
23-
.then((v) => setValueState(v))
24-
.catch(alertOnError);
25-
}, [destructionList?.uuid]);
17+
usePoll(
18+
() =>
19+
listCoReviews({ destructionList__uuid: destructionList?.uuid })
20+
.then((v) => setValueState(v))
21+
.catch(alertOnError),
22+
[destructionList?.uuid],
23+
);
2624

2725
return valueState;
2826
}

frontend/src/pages/destructionlist/review/DestructionListReview.action.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { ActionFunctionArgs, redirect } from "react-router-dom";
22

33
import { TypedAction } from "../../../hooks";
4-
import { CoReview, createCoReview } from "../../../lib/api/coReview";
4+
import {
5+
CoReview,
6+
CoReviewBase,
7+
createCoReview,
8+
} from "../../../lib/api/coReview";
59
import {
610
Review,
711
ZaakReview,
@@ -152,7 +156,7 @@ export async function destructionListCompleteCoReviewAction({
152156
const { comment, destructionList } =
153157
payload as ReviewDestructionListCompleteCoReviewPayload;
154158

155-
const data: CoReview = {
159+
const data: CoReviewBase = {
156160
destructionList: destructionList,
157161
listFeedback: comment,
158162
};

0 commit comments

Comments
 (0)