Skip to content

Commit

Permalink
Reset the state on both cancel and confirm.
Browse files Browse the repository at this point in the history
  • Loading branch information
modamaan committed Feb 7, 2025
1 parent e92c37d commit 36bcbd3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/pages/Scheduling/ScheduleExceptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ const ScheduleExceptionItem = (
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>{t("cancel")}</AlertDialogCancel>
<AlertDialogCancel onClick={() => setOpen(false)}>
{t("cancel")}
</AlertDialogCancel>
<AlertDialogAction
variant="destructive"
onClick={() => {
Expand Down
15 changes: 13 additions & 2 deletions src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,10 @@ export default function CreateScheduleTemplateSheet({
</div>
<AlertDialog
open={openDialog}
onOpenChange={setOpenDialog}
onOpenChange={(open) => {
setOpenDialog(open);
if (!open) setRemoveIndex(null);
}}
>
<AlertDialogTrigger asChild>
<Button
Expand Down Expand Up @@ -402,7 +405,14 @@ export default function CreateScheduleTemplateSheet({
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>{t("cancel")}</AlertDialogCancel>
<AlertDialogCancel
onClick={() => {
setOpenDialog(false);
setRemoveIndex(null);
}}
>
{t("cancel")}
</AlertDialogCancel>
<AlertDialogAction
variant={"destructive"}
onClick={() => {
Expand All @@ -416,6 +426,7 @@ export default function CreateScheduleTemplateSheet({
);
}
setOpenDialog(false);
setRemoveIndex(null);
}}
>
{t("confirm")}
Expand Down
18 changes: 14 additions & 4 deletions src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,10 @@ const ScheduleTemplateEditor = ({
</div>

<div className="flex justify-end gap-2">
<AlertDialog open={isDialogOpen} onOpenChange={setDialogOpen}>
<AlertDialog
open={isDialogOpen}
onOpenChange={(open) => setDialogOpen(open)}
>
<AlertDialogTrigger asChild>
<Button
type="button"
Expand All @@ -288,7 +291,9 @@ const ScheduleTemplateEditor = ({
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>{t("cancel")}</AlertDialogCancel>
<AlertDialogCancel onClick={() => setDialogOpen(false)}>
{t("cancel")}
</AlertDialogCancel>
<AlertDialogAction
variant="destructive"
onClick={() => {
Expand Down Expand Up @@ -393,7 +398,10 @@ const AvailabilityEditor = ({
</span>
</div>

<AlertDialog open={openDialog} onOpenChange={setOpenDialog}>
<AlertDialog
open={openDialog}
onOpenChange={(open) => setOpenDialog(open)}
>
<AlertDialogTrigger asChild>
<Button
variant="ghost"
Expand All @@ -417,7 +425,9 @@ const AvailabilityEditor = ({
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>{t("cancel")}</AlertDialogCancel>
<AlertDialogCancel onClick={() => setOpenDialog(false)}>
{t("cancel")}
</AlertDialogCancel>
<AlertDialogAction
variant="destructive"
onClick={() => {
Expand Down

0 comments on commit 36bcbd3

Please sign in to comment.