diff --git a/apps/web/pages/availability/[schedule].tsx b/apps/web/pages/availability/[schedule].tsx
index 9b8673d75e..a410bbd102 100644
--- a/apps/web/pages/availability/[schedule].tsx
+++ b/apps/web/pages/availability/[schedule].tsx
@@ -1,4 +1,5 @@
import type { GetServerSidePropsContext } from "next";
+import { useRouter } from "next/router";
import { Controller, useFieldArray, useForm } from "react-hook-form";
import { z } from "zod";
@@ -22,9 +23,12 @@ import {
Switch,
TimezoneSelect,
Tooltip,
+ Dialog,
+ DialogTrigger,
+ ConfirmationDialogContent,
VerticalDivider,
} from "@calcom/ui";
-import { FiInfo, FiPlus } from "@calcom/ui/components/icon";
+import { FiInfo, FiPlus, FiTrash } from "@calcom/ui/components/icon";
import { HttpError } from "@lib/core/http/error";
@@ -86,6 +90,7 @@ const DateOverride = ({ workingHours }: { workingHours: WorkingHours[] }) => {
export default function Availability({ schedule }: { schedule: number }) {
const { t, i18n } = useLocale();
+ const router = useRouter();
const utils = trpc.useContext();
const me = useMeQuery();
const { timeFormat } = me.data || { timeFormat: null };
@@ -120,6 +125,22 @@ export default function Availability({ schedule }: { schedule: number }) {
},
});
+ const deleteMutation = trpc.viewer.availability.schedule.delete.useMutation({
+ onError: (err) => {
+ if (err instanceof HttpError) {
+ const message = `${err.statusCode}: ${err.message}`;
+ showToast(message, "error");
+ }
+ },
+ onSettled: () => {
+ utils.viewer.availability.list.invalidate();
+ },
+ onSuccess: () => {
+ showToast(t("schedule_deleted_successfully"), "success");
+ router.push("/availability");
+ },
+ });
+
return (
+
+
+
diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json
index 6d6aa02533..feeb16f2b4 100644
--- a/apps/web/public/static/locales/en/common.json
+++ b/apps/web/public/static/locales/en/common.json
@@ -860,6 +860,7 @@
"add_new_calendar": "Add a new calendar",
"set_calendar": "Set where to add new events to when you're booked.",
"delete_schedule": "Delete schedule",
+ "delete_schedule_description":"Deleting a schedule will remove it from all event types. This action cannot be undone.",
"schedule_created_successfully": "{{scheduleName}} schedule created successfully",
"availability_updated_successfully": "{{scheduleName}} schedule updated successfully",
"schedule_deleted_successfully": "Schedule deleted successfully",
diff --git a/packages/features/schedules/components/NewScheduleButton.tsx b/packages/features/schedules/components/NewScheduleButton.tsx
index 980b16184d..31d02e7d7b 100644
--- a/packages/features/schedules/components/NewScheduleButton.tsx
+++ b/packages/features/schedules/components/NewScheduleButton.tsx
@@ -12,6 +12,7 @@ import {
DialogFooter,
DialogTrigger,
Form,
+ InputField,
showToast,
} from "@calcom/ui";
import { FiPlus } from "@calcom/ui/components/icon";
@@ -68,21 +69,14 @@ export function NewScheduleButton({ name = "new-schedule" }: { name?: string })
handleSubmit={(values) => {
createMutation.mutate(values);
}}>
-
-
-
-
-
-
+