Skip to content

Commit

Permalink
fix(web): Fix sidebar list edit dialog not working. Fixes #447
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedBassem committed Oct 6, 2024
1 parent 1e5c575 commit 09e0659
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions apps/web/components/dashboard/lists/EditListModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ export function EditListModal({
const isEdit = !!list;
const isPending = isCreating || isEditing;

const onSubmit = form.handleSubmit((value: z.infer<typeof formSchema>) => {
value.parentId = value.parentId === "" ? null : value.parentId;
isEdit ? editList({ ...value, listId: list.id }) : createList(value);
});

return (
<Dialog
open={open}
Expand All @@ -167,14 +172,7 @@ export function EditListModal({
{children && <DialogTrigger asChild>{children}</DialogTrigger>}
<DialogContent>
<Form {...form}>
<form
onSubmit={form.handleSubmit((value) => {
value.parentId = value.parentId === "" ? null : value.parentId;
isEdit
? editList({ ...value, listId: list.id })
: createList(value);
})}
>
<form onSubmit={onSubmit}>
<DialogHeader>
<DialogTitle>{isEdit ? "Edit" : "New"} List</DialogTitle>
</DialogHeader>
Expand Down Expand Up @@ -264,7 +262,11 @@ export function EditListModal({
Close
</Button>
</DialogClose>
<ActionButton type="submit" loading={isPending}>
<ActionButton
type="submit"
onClick={onSubmit}
loading={isPending}
>
{list ? "Save" : "Create"}
</ActionButton>
</DialogFooter>
Expand Down

0 comments on commit 09e0659

Please sign in to comment.