Skip to content

Scheduling infrastructure for absolutely everyone.

Availability uiux improvements (#7466)

sean-brydonf4c3ab64310f
diff --git a/apps/web/pages/availability/[schedule].tsx b/apps/web/pages/availability/[schedule].tsx
index 9b8673d75e9..a410bbd102a 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 (
<Shell
backPath="/availability"
@@ -166,6 +187,24 @@ export default function Availability({ schedule }: { schedule: number }) {
/>
</div>
+ <VerticalDivider />
+ <Dialog>
+ <DialogTrigger asChild>
+ <Button StartIcon={FiTrash} variant="icon" color="destructive" aria-label={t("delete")} />
+ </DialogTrigger>
+ <ConfirmationDialogContent
+ isLoading={deleteMutation.isLoading}
+ variety="danger"
+ title={t("delete_schedule")}
+ confirmBtnText={t("delete")}
+ loadingText={t("delete")}
+ onConfirm={() => {
+ deleteMutation.mutate({ scheduleId: schedule });
+ }}>
+ {t("delete_schedule_description")}
+ </ConfirmationDialogContent>
+ </Dialog>
+
<VerticalDivider />
<div className="border-l-2 border-gray-300" />
diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json
index 6d6aa02533e..feeb16f2b4e 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 980b16184d0..31d02e7d7b8 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);
}}>
- <div className="space-y-2">
- <label htmlFor="label" className="block text-sm font-medium text-gray-700">
- {t("name")}
- </label>
- <div className="mt-1">
- <input
- type="text"
- id="name"
- required
- className="block w-full rounded-sm border-gray-300 text-sm"
- placeholder={t("default_schedule_name")}
- {...register("name")}
- />
- </div>
- </div>
+ <InputField
+ label={t("name")}
+ type="text"
+ id="name"
+ required
+ placeholder={t("default_schedule_name")}
+ {...register("name")}
+ />
<DialogFooter>
<DialogClose />
<Button type="submit" loading={createMutation.isLoading}>
diff --git a/packages/features/schedules/components/ScheduleListItem.tsx b/packages/features/schedules/components/ScheduleListItem.tsx
index c3e21c527b3..67799ae0ad4 100644
--- a/packages/features/schedules/components/ScheduleListItem.tsx
+++ b/packages/features/schedules/components/ScheduleListItem.tsx
@@ -14,7 +14,7 @@ import {
DropdownItem,
DropdownMenuTrigger,
} from "@calcom/ui";
-import { FiGlobe, FiMoreHorizontal, FiTrash } from "@calcom/ui/components/icon";
+import { FiGlobe, FiMoreHorizontal, FiTrash, FiClock } from "@calcom/ui/components/icon";
export function ScheduleListItem({
schedule,
@@ -87,6 +87,7 @@ export function ScheduleListItem({
{!schedule.isDefault && (
<DropdownItem
type="button"
+ StartIcon={FiClock}
onClick={() => {
updateDefault({
scheduleId: schedule.id,