diff --git a/public/locale/en.json b/public/locale/en.json index f4de7ad0663..421e00b2339 100644 --- a/public/locale/en.json +++ b/public/locale/en.json @@ -391,6 +391,7 @@ "archived_reason": "Archived reason", "are_non_editable_fields": "are non-editable fields", "are_you_still_watching": "Are you still watching?", + "are_you_sure": "Are you sure?", "are_you_sure_want_to_delete": "Are you sure you want to delete {{name}}?", "are_you_sure_want_to_delete_this_record": "Are you sure want to delete this record?", "are_you_sure_want_to_remove": "Are you sure you want to remove {{name}} from the patient? This action cannot be undone", @@ -2109,6 +2110,7 @@ "third_party_software_licenses": "Third Party Software Licenses", "this_action_is_irreversible": "This action is irreversible. Once a file is archived it cannot be unarchived.", "this_file_has_been_archived": "This file has been archived and cannot be unarchived.", + "this_will_permanently_remove_the_template": "This will permanently remove the {{data}} and cannot be undone", "thread_already_exists": "Thread with this title already exists", "time": "Time", "time_slot": "Time Slot", diff --git a/src/pages/Appointments/AppointmentDetail.tsx b/src/pages/Appointments/AppointmentDetail.tsx index d83295d6a73..aba1a48ec53 100644 --- a/src/pages/Appointments/AppointmentDetail.tsx +++ b/src/pages/Appointments/AppointmentDetail.tsx @@ -33,7 +33,7 @@ import { AlertDialogTrigger, } from "@/components/ui/alert-dialog"; import { Badge, BadgeProps } from "@/components/ui/badge"; -import { Button } from "@/components/ui/button"; +import { Button, buttonVariants } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Separator } from "@/components/ui/separator"; import { @@ -543,6 +543,7 @@ const AppointmentActions = ({ {t("cancel")} cancelAppointment({ reason: "cancelled" })} + className={cn(buttonVariants({ variant: "destructive" }))} > {t("confirm")} @@ -573,6 +574,7 @@ const AppointmentActions = ({ {t("cancel")} cancelAppointment({ reason: "entered_in_error" })} + className={cn(buttonVariants({ variant: "destructive" }))} > {t("confirm")} diff --git a/src/pages/Scheduling/ScheduleExceptions.tsx b/src/pages/Scheduling/ScheduleExceptions.tsx index 96e97fa177e..cf3faf104ed 100644 --- a/src/pages/Scheduling/ScheduleExceptions.tsx +++ b/src/pages/Scheduling/ScheduleExceptions.tsx @@ -1,5 +1,6 @@ import { useMutation, useQueryClient } from "@tanstack/react-query"; import { format, parseISO } from "date-fns"; +import { useState } from "react"; import { useTranslation } from "react-i18next"; import { toast } from "sonner"; @@ -8,7 +9,19 @@ import { cn } from "@/lib/utils"; import ColoredIndicator from "@/CAREUI/display/ColoredIndicator"; import CareIcon from "@/CAREUI/icons/CareIcon"; -import { Button } from "@/components/ui/button"; +import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogTrigger, +} from "@/components/ui/alert-dialog"; +import { Button, buttonVariants } from "@/components/ui/button"; import Loading from "@/components/Common/Loading"; @@ -63,6 +76,7 @@ const ScheduleExceptionItem = ( ) => { const { t } = useTranslation(); const queryClient = useQueryClient(); + const [open, setOpen] = useState(false); const { mutate: deleteException, isPending } = useMutation({ mutationFn: mutate(scheduleApis.exceptions.delete, { @@ -112,15 +126,43 @@ const ScheduleExceptionItem = ( - + + + + + + + {t("are_you_sure")} + + + {t("warning")} + + {t("this_will_permanently_remove_the_template", { + data: "exception", + })} + + + + + + setOpen(false)}> + {t("cancel")} + + { + deleteException(); + setOpen(false); + }} + > + {t("confirm")} + + + + {/* TODO: Add this information */} {/*
diff --git a/src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx b/src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx index daee952132e..6e43bfc4d52 100644 --- a/src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx +++ b/src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx @@ -3,19 +3,34 @@ import { useMutation, useQueryClient } from "@tanstack/react-query"; import { isAfter, isBefore, parse } from "date-fns"; import { ArrowRightIcon } from "lucide-react"; import { useQueryParams } from "raviger"; +import { useState } from "react"; import { useForm } from "react-hook-form"; import { useTranslation } from "react-i18next"; import { Trans } from "react-i18next"; import { toast } from "sonner"; import * as z from "zod"; +import { cn } from "@/lib/utils"; + import Callout from "@/CAREUI/display/Callout"; import CareIcon from "@/CAREUI/icons/CareIcon"; import WeekdayCheckbox, { DayOfWeek, } from "@/CAREUI/interactive/WeekdayCheckbox"; -import { Button } from "@/components/ui/button"; +import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogTrigger, +} from "@/components/ui/alert-dialog"; +import { Button, buttonVariants } from "@/components/ui/button"; import { DatePicker } from "@/components/ui/date-picker"; import { Form, @@ -235,6 +250,9 @@ export default function CreateScheduleTemplateSheet({ ); }; + const [openDialog, setOpenDialog] = useState(false); + const [removeIndex, setRemoveIndex] = useState(null); + return (
- + + + + + + + {t("are_you_sure")} + + + + {t("warning")} + + {t( + "this_will_permanently_remove_the_template", + { + data: "session", + }, + )} + + + + + + { + setOpenDialog(false); + setRemoveIndex(null); + }} + > + {t("cancel")} + + { + const availabilities = + form.getValues("availabilities"); + if (removeIndex !== null) { + availabilities.splice(removeIndex, 1); + form.setValue( + "availabilities", + availabilities, + ); + } + setOpenDialog(false); + setRemoveIndex(null); + }} + > + {t("confirm")} + + + +
diff --git a/src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx b/src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx index 16d62abc1dc..2236f7de917 100644 --- a/src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx +++ b/src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx @@ -9,13 +9,27 @@ import { Trans } from "react-i18next"; import { toast } from "sonner"; import * as z from "zod"; +import { cn } from "@/lib/utils"; + import Callout from "@/CAREUI/display/Callout"; import CareIcon from "@/CAREUI/icons/CareIcon"; import WeekdayCheckbox, { DayOfWeek, } from "@/CAREUI/interactive/WeekdayCheckbox"; -import { Button } from "@/components/ui/button"; +import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogTrigger, +} from "@/components/ui/alert-dialog"; +import { Button, buttonVariants } from "@/components/ui/button"; import { DatePicker } from "@/components/ui/date-picker"; import { Form, @@ -126,6 +140,7 @@ const ScheduleTemplateEditor = ({ }) => { const { t } = useTranslation(); const queryClient = useQueryClient(); + const [isDialogOpen, setDialogOpen] = useState(false); const templateFormSchema = z .object({ @@ -250,16 +265,51 @@ const ScheduleTemplateEditor = ({
- + + + + + + {t("are_you_sure")} + + + {t("warning")} + + {t("this_will_permanently_remove_the_template", { + data: "scheduled teplate", + })} + + + + + + setDialogOpen(false)}> + {t("cancel")} + + { + deleteTemplate(); + setDialogOpen(false); + }} + > + {t("confirm")} + + + +
- + + + + + + {t("are_you_sure")} + + + {t("warning")} + + {t("this_will_permanently_remove_the_template", { + data: "available session", + })} + + + + + + setOpenDialog(false)}> + {t("cancel")} + + { + deleteAvailability(); + setOpenDialog(false); + }} + > + {t("confirm")} + + + +