From e59cf42352cc33621cb99a577ced023300299d03 Mon Sep 17 00:00:00 2001 From: Sven van de Scheur Date: Tue, 1 Oct 2024 17:46:35 +0200 Subject: [PATCH] :bug: - fix: fix a bug where the edit destructionlist button was shown on incorrect places. --- .../DestructionListEdit.tsx | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/frontend/src/pages/destructionlist/detail/components/DestructionListEdit/DestructionListEdit.tsx b/frontend/src/pages/destructionlist/detail/components/DestructionListEdit/DestructionListEdit.tsx index ffad2a48..87ee9bf9 100644 --- a/frontend/src/pages/destructionlist/detail/components/DestructionListEdit/DestructionListEdit.tsx +++ b/frontend/src/pages/destructionlist/detail/components/DestructionListEdit/DestructionListEdit.tsx @@ -23,13 +23,8 @@ import { useSecondaryNavigation } from "../../hooks/useSecondaryNavigation"; * Allows viewing, adding and removing destruction list items. */ export function DestructionListEdit() { - const { - destructionList, - destructionListItems, - review, - selectableZaken, - storageKey, - } = useLoaderData() as DestructionListDetailContext; + const { destructionList, destructionListItems, selectableZaken, storageKey } = + useLoaderData() as DestructionListDetailContext; const [selectionClearedState, setSelectionClearedState] = useState(false); const { state } = useNavigation(); @@ -39,8 +34,10 @@ export function DestructionListEdit() { // Whether the list is in edit mode. const editingState = useMemo( - () => !review && Boolean(urlSearchParams.get("is_editing")), - [review, urlSearchParams], + () => + destructionList.status === "new" && + Boolean(urlSearchParams.get("is_editing")), + [destructionList.status, urlSearchParams], ); // The initially select items. @@ -116,18 +113,20 @@ export function DestructionListEdit() { onClick: () => handleSetEditing(false), }, ] - : [ - { - children: ( - <> - - Bewerken - - ), - wrap: false, - onClick: () => handleSetEditing(true), - }, - ], + : destructionList.status === "new" + ? [ + { + children: ( + <> + + Bewerken + + ), + wrap: false, + onClick: () => handleSetEditing(true), + }, + ] + : [], [editingState, state], );