Skip to content

Commit

Permalink
🐛 - fix: fix a bug where the edit destructionlist button was shown on…
Browse files Browse the repository at this point in the history
… incorrect places.
  • Loading branch information
svenvandescheur committed Oct 1, 2024
1 parent 0a5d4b3 commit e426801
Showing 1 changed file with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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.
Expand Down Expand Up @@ -116,18 +113,20 @@ export function DestructionListEdit() {
onClick: () => handleSetEditing(false),
},
]
: [
{
children: (
<>
<Solid.PencilIcon />
Bewerken
</>
),
wrap: false,
onClick: () => handleSetEditing(true),
},
],
: destructionList.status === "new"
? [
{
children: (
<>
<Solid.PencilIcon />
Bewerken
</>
),
wrap: false,
onClick: () => handleSetEditing(true),
},
]
: [],
[editingState, state],
);

Expand Down

0 comments on commit e426801

Please sign in to comment.