Skip to content

Commit e59cf42

Browse files
🐛 - fix: fix a bug where the edit destructionlist button was shown on incorrect places.
1 parent ca707d9 commit e59cf42

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

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

+20-21
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,8 @@ import { useSecondaryNavigation } from "../../hooks/useSecondaryNavigation";
2323
* Allows viewing, adding and removing destruction list items.
2424
*/
2525
export function DestructionListEdit() {
26-
const {
27-
destructionList,
28-
destructionListItems,
29-
review,
30-
selectableZaken,
31-
storageKey,
32-
} = useLoaderData() as DestructionListDetailContext;
26+
const { destructionList, destructionListItems, selectableZaken, storageKey } =
27+
useLoaderData() as DestructionListDetailContext;
3328

3429
const [selectionClearedState, setSelectionClearedState] = useState(false);
3530
const { state } = useNavigation();
@@ -39,8 +34,10 @@ export function DestructionListEdit() {
3934

4035
// Whether the list is in edit mode.
4136
const editingState = useMemo(
42-
() => !review && Boolean(urlSearchParams.get("is_editing")),
43-
[review, urlSearchParams],
37+
() =>
38+
destructionList.status === "new" &&
39+
Boolean(urlSearchParams.get("is_editing")),
40+
[destructionList.status, urlSearchParams],
4441
);
4542

4643
// The initially select items.
@@ -116,18 +113,20 @@ export function DestructionListEdit() {
116113
onClick: () => handleSetEditing(false),
117114
},
118115
]
119-
: [
120-
{
121-
children: (
122-
<>
123-
<Solid.PencilIcon />
124-
Bewerken
125-
</>
126-
),
127-
wrap: false,
128-
onClick: () => handleSetEditing(true),
129-
},
130-
],
116+
: destructionList.status === "new"
117+
? [
118+
{
119+
children: (
120+
<>
121+
<Solid.PencilIcon />
122+
Bewerken
123+
</>
124+
),
125+
wrap: false,
126+
onClick: () => handleSetEditing(true),
127+
},
128+
]
129+
: [],
131130
[editingState, state],
132131
);
133132

0 commit comments

Comments
 (0)