-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[ENG-783] Added popup to indicate appointment clash/duplication #16589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,168 @@ | ||
| import { format } from "date-fns"; | ||
| import { MessageCircleWarning, X } from "lucide-react"; | ||
| import { Trans, useTranslation } from "react-i18next"; | ||
|
|
||
| import { Button } from "@/components/ui/button"; | ||
|
|
||
| import { ScheduleResourceIcon } from "@/components/Schedule/ScheduleResourceIcon"; | ||
| import { | ||
| Appointment, | ||
| formatScheduleResourceName, | ||
| SchedulableResourceType, | ||
| ScheduleResource, | ||
| TokenSlot, | ||
| } from "@/types/scheduling/schedule"; | ||
|
|
||
| export type AppointmentConflictType = "duplicate" | "clash"; | ||
|
|
||
| interface AppointmentConflictAlertProps { | ||
| type: AppointmentConflictType; | ||
| conflictingAppointment: Appointment; | ||
| newSlot: Pick<TokenSlot, "start_datetime" | "end_datetime">; | ||
| newResource?: ScheduleResource; | ||
| onPickAnotherSlot: () => void; | ||
| onContinueAnyway: () => void; | ||
| onClose: () => void; | ||
| } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In the parent, both props are wired to |
||
| export const AppointmentConflictAlert = ({ | ||
| type, | ||
| conflictingAppointment, | ||
| newSlot, | ||
| newResource, | ||
| onPickAnotherSlot, | ||
| onContinueAnyway, | ||
| onClose, | ||
| }: AppointmentConflictAlertProps) => { | ||
| const { t } = useTranslation(); | ||
|
|
||
| const existingStart = new Date( | ||
| conflictingAppointment.token_slot.start_datetime, | ||
| ); | ||
| const newStart = new Date(newSlot.start_datetime); | ||
|
|
||
| return ( | ||
| <div className="flex flex-col gap-3 p-4"> | ||
| <div className="flex items-start justify-between gap-2"> | ||
| <div className="flex items-center gap-2.5"> | ||
| <div className="flex items-center justify-center size-9 rounded-full bg-yellow-100 shrink-0"> | ||
| <MessageCircleWarning className="size-5 text-yellow-700" /> | ||
| </div> | ||
| <span className="font-semibold text-gray-950"> | ||
| {type === "duplicate" | ||
| ? t("multiple_appointment_alert") | ||
| : t("timing_clash_alert")} | ||
| </span> | ||
| </div> | ||
| <button | ||
| type="button" | ||
| onClick={onClose} | ||
| aria-label={t("close")} | ||
| className="text-gray-400 hover:text-gray-600 shrink-0" | ||
| > | ||
| <X className="size-4" /> | ||
| </button> | ||
|
shivankacker marked this conversation as resolved.
coderabbitai[bot] marked this conversation as resolved.
|
||
| </div> | ||
|
|
||
| <div className="border-t border-gray-200" /> | ||
|
|
||
| <p className="text-sm text-gray-950"> | ||
| {t("patient_already_has_appointment_on")}{" "} | ||
| <span className="font-semibold"> | ||
| {format(existingStart, "dd MMM yyyy")} ·{" "} | ||
| {format(existingStart, "hh:mm a")} | ||
| </span> | ||
| </p> | ||
|
|
||
| <div className="flex items-center justify-between gap-2 rounded-md bg-gray-50 p-2"> | ||
| <div className="flex items-center gap-2 min-w-0"> | ||
| <ScheduleResourceIcon | ||
| resource={conflictingAppointment} | ||
| className="size-8" | ||
| /> | ||
| <div className="flex flex-col min-w-0"> | ||
| <span className="text-sm font-medium text-gray-950 truncate"> | ||
| {formatScheduleResourceName(conflictingAppointment)} | ||
| </span> | ||
| {conflictingAppointment.resource_type === | ||
| SchedulableResourceType.Practitioner && ( | ||
| <span className="text-xs text-gray-600"> | ||
| {t(conflictingAppointment.resource.user_type)} | ||
| </span> | ||
| )} | ||
| </div> | ||
| </div> | ||
| {type === "duplicate" && ( | ||
| <span className="text-sm font-medium text-green-700 whitespace-nowrap"> | ||
| {format(existingStart, "hh:mm a")} | ||
| </span> | ||
| )} | ||
| </div> | ||
|
|
||
| {type === "duplicate" ? ( | ||
| <p className="text-sm text-gray-950"> | ||
| <Trans | ||
| i18nKey="trying_to_book_another_slot_same_doctor" | ||
| components={{ bold: <span className="font-semibold" /> }} | ||
| />{" "} | ||
| <span className="font-semibold"> | ||
| {format(newStart, "dd MMM yyyy")} · {format(newStart, "hh:mm a")} | ||
| </span> | ||
|
shivankacker marked this conversation as resolved.
|
||
| </p> | ||
| ) : ( | ||
| <> | ||
| <p className="text-sm text-gray-950"> | ||
| <Trans | ||
| i18nKey="clash_new_slot_overlaps" | ||
| values={{ | ||
| resourceName: newResource | ||
| ? formatScheduleResourceName(newResource) | ||
| : "", | ||
| time: format(newStart, "hh:mm a"), | ||
| }} | ||
| components={{ bold: <span className="font-semibold" /> }} | ||
| /> | ||
| </p> | ||
|
|
||
| {newResource && ( | ||
| <div className="flex items-center gap-2 rounded-md bg-gray-50 p-2"> | ||
| <ScheduleResourceIcon resource={newResource} className="size-8" /> | ||
| <div className="flex flex-col min-w-0"> | ||
| <span className="text-sm font-medium text-gray-950 truncate"> | ||
| {formatScheduleResourceName(newResource)} | ||
| </span> | ||
| {newResource.resource_type === | ||
| SchedulableResourceType.Practitioner && ( | ||
| <span className="text-xs text-gray-600"> | ||
| {t(newResource.resource.user_type)} | ||
| </span> | ||
| )} | ||
| </div> | ||
| </div> | ||
| )} | ||
| </> | ||
| )} | ||
|
|
||
| <p className="text-sm font-medium text-gray-950"> | ||
| {t("what_would_you_like_to_do")} | ||
| </p> | ||
|
|
||
| <Button | ||
| type="button" | ||
| variant="primary" | ||
| className="w-full" | ||
| onClick={onPickAnotherSlot} | ||
| > | ||
| {t("pick_another_slot")} | ||
| </Button> | ||
|
|
||
| <button | ||
| type="button" | ||
| onClick={onContinueAnyway} | ||
| className="text-sm font-semibold text-gray-950 underline text-center mx-auto" | ||
| > | ||
| {t("continue_anyway")} | ||
| </button> | ||
| </div> | ||
| ); | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.