import { ClockIcon, XIcon } from "@heroicons/react/outline"; import dayjs from "dayjs"; import { Dispatch, SetStateAction } from "react"; import { useState } from "react"; import { useMutation } from "react-query"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import logger from "@calcom/lib/logger"; import showToast from "@calcom/lib/notification"; import Button from "@calcom/ui/Button"; import { Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader } from "@calcom/ui/Dialog"; interface IConfirmDialogWipe { isOpenDialog: boolean; setIsOpenDialog: Dispatch>; trpc: any; } interface IWipeMyCalAction { initialDate: string; endDate: string; } const wipeMyCalAction = async (props: IWipeMyCalAction) => { const { initialDate, endDate } = props; const body = { initialDate, endDate, }; try { const endpoint = "/api/integrations/wipemycalother/wipe"; return fetch(`${process.env.NEXT_PUBLIC_WEBAPP_URL}` + endpoint, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(body), }); } catch (error: unknown) { if (error instanceof Error) { showToast("Error ocurred while trying to cancel bookings", "error"); } } }; export const ConfirmDialog = (props: IConfirmDialogWipe) => { const { t } = useLocale(); const { isOpenDialog, setIsOpenDialog, trpc } = props; const [isLoading, setIsLoading] = useState(false); const today = dayjs(); const initialDate = today.startOf("day"); const endDate = today.endOf("day"); const dateFormat = "ddd, MMM D, YYYY h:mm A"; const utils = trpc.useContext(); const rescheduleApi = useMutation( async () => { setIsLoading(true); try { const result = await wipeMyCalAction({ initialDate: initialDate.toISOString(), endDate: endDate.toISOString(), }); if (result) { showToast(t("reschedule_request_sent"), "success"); setIsOpenDialog(false); } } catch (error) { showToast(t("unexpected_error_try_again"), "error"); // @TODO: notify sentry } setIsLoading(false); }, { async onSettled() { await utils.invalidateQueries(["viewer.bookings"]); }, } ); return ( e.preventDefault()}>

This will cancel all upcoming meetings from:
{" "} {initialDate.format(dateFormat)} - {endDate.format(dateFormat)}

Are you sure? This can't be undone

); };