Skip to content

Commit cd7de98

Browse files
authored
fix: Set mobile availability (#11027)
1 parent 3f51858 commit cd7de98

File tree

2 files changed

+104
-38
lines changed

2 files changed

+104
-38
lines changed

apps/web/pages/availability/[schedule].tsx

Lines changed: 103 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import dayjs from "@calcom/dayjs";
66
import { DateOverrideInputDialog, DateOverrideList } from "@calcom/features/schedules";
77
import Schedule from "@calcom/features/schedules/components/Schedule";
88
import Shell from "@calcom/features/shell/Shell";
9+
import { classNames } from "@calcom/lib";
910
import { availabilityAsString } from "@calcom/lib/availability";
1011
import { useLocale } from "@calcom/lib/hooks/useLocale";
1112
import { HttpError } from "@calcom/lib/http-error";
@@ -17,11 +18,6 @@ import {
1718
ConfirmationDialogContent,
1819
Dialog,
1920
DialogTrigger,
20-
Dropdown,
21-
DropdownItem,
22-
DropdownMenuContent,
23-
DropdownMenuSeparator,
24-
DropdownMenuTrigger,
2521
Form,
2622
Label,
2723
showToast,
@@ -32,7 +28,7 @@ import {
3228
Tooltip,
3329
VerticalDivider,
3430
} from "@calcom/ui";
35-
import { Info, MoreHorizontal, Plus, Trash } from "@calcom/ui/components/icon";
31+
import { Info, MoreVertical, ArrowLeft, Plus, Trash } from "@calcom/ui/components/icon";
3632

3733
import PageWrapper from "@components/PageWrapper";
3834
import { SelectSkeletonLoader } from "@components/availability/SkeletonLoader";
@@ -95,7 +91,7 @@ export default function Availability() {
9591
const scheduleId = searchParams?.get("schedule") ? Number(searchParams.get("schedule")) : -1;
9692
const fromEventType = searchParams?.get("fromEventType");
9793
const { timeFormat } = me.data || { timeFormat: null };
98-
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
94+
const [openSidebar, setOpenSidebar] = useState(false);
9995
const { data: schedule, isLoading } = trpc.viewer.availability.schedule.get.useQuery(
10096
{ scheduleId },
10197
{
@@ -225,33 +221,60 @@ export default function Availability() {
225221
</ConfirmationDialogContent>
226222
</Dialog>
227223
<VerticalDivider className="hidden sm:inline" />
228-
<Dropdown>
229-
<DropdownMenuTrigger asChild>
230-
<Button className="sm:hidden" StartIcon={MoreHorizontal} variant="icon" color="secondary" />
231-
</DropdownMenuTrigger>
232-
<DropdownMenuContent style={{ minWidth: "200px" }}>
233-
<DropdownItem
234-
type="button"
235-
color="destructive"
236-
StartIcon={Trash}
237-
onClick={() => setDeleteDialogOpen(true)}>
238-
{t("delete")}
239-
</DropdownItem>
240-
<Dialog open={deleteDialogOpen} onOpenChange={setDeleteDialogOpen}>
241-
<ConfirmationDialogContent
242-
isLoading={deleteMutation.isLoading}
243-
variety="danger"
244-
title={t("delete_schedule")}
245-
confirmBtnText={t("delete")}
246-
loadingText={t("delete")}
247-
onConfirm={() => {
248-
schedule !== undefined && deleteMutation.mutate({ scheduleId: schedule.id });
249-
}}>
250-
{t("delete_schedule_description")}
251-
</ConfirmationDialogContent>
252-
</Dialog>
253-
<DropdownMenuSeparator />
254-
<div className="flex h-9 flex-row items-center justify-between px-4 py-2 hover:bg-gray-100">
224+
<div
225+
className={classNames(
226+
openSidebar
227+
? "fadeIn fixed inset-0 z-50 bg-neutral-800 bg-opacity-70 transition-opacity dark:bg-opacity-70 sm:hidden"
228+
: ""
229+
)}>
230+
<div
231+
className={classNames(
232+
"bg-default fixed right-0 z-20 flex h-screen w-80 flex-col space-y-2 overflow-x-hidden rounded-md px-2 pb-3 transition-transform",
233+
openSidebar ? "translate-x-0 opacity-100" : "translate-x-full opacity-0"
234+
)}>
235+
<div className="flex flex-row items-center pt-5">
236+
<Button StartIcon={ArrowLeft} color="minimal" onClick={() => setOpenSidebar(false)} />
237+
<p className="-ml-2">{t("availability_settings")}</p>
238+
<Dialog>
239+
<DialogTrigger asChild>
240+
<Button
241+
StartIcon={Trash}
242+
variant="icon"
243+
color="destructive"
244+
aria-label={t("delete")}
245+
className="ml-16 inline"
246+
disabled={schedule?.isLastSchedule}
247+
tooltip={schedule?.isLastSchedule ? t("requires_at_least_one_schedule") : t("delete")}
248+
/>
249+
</DialogTrigger>
250+
<ConfirmationDialogContent
251+
isLoading={deleteMutation.isLoading}
252+
variety="danger"
253+
title={t("delete_schedule")}
254+
confirmBtnText={t("delete")}
255+
loadingText={t("delete")}
256+
onConfirm={() => {
257+
scheduleId && deleteMutation.mutate({ scheduleId });
258+
setOpenSidebar(false);
259+
}}>
260+
{t("delete_schedule_description")}
261+
</ConfirmationDialogContent>
262+
</Dialog>
263+
</div>
264+
<div className="flex flex-col px-2 py-2">
265+
<Skeleton as={Label}>{t("name")}</Skeleton>
266+
<Controller
267+
control={form.control}
268+
name="name"
269+
render={({ field }) => (
270+
<input
271+
className="hover:border-emphasis dark:focus:border-emphasis border-default bg-default placeholder:text-muted text-emphasis focus:ring-brand-default disabled:bg-subtle disabled:hover:border-subtle mb-2 block h-9 w-full rounded-md border px-3 py-2 text-sm leading-4 focus:border-neutral-300 focus:outline-none focus:ring-2 disabled:cursor-not-allowed"
272+
{...field}
273+
/>
274+
)}
275+
/>
276+
</div>
277+
<div className="flex h-9 flex-row-reverse items-center justify-end gap-3 px-2">
255278
<Skeleton
256279
as={Label}
257280
htmlFor="hiddenSwitch"
@@ -267,9 +290,44 @@ export default function Availability() {
267290
}}
268291
/>
269292
</div>
270-
</DropdownMenuContent>
271-
</Dropdown>
272293

294+
<div className="min-w-40 col-span-3 space-y-2 px-2 py-4 lg:col-span-1">
295+
<div className="xl:max-w-80 w-full pr-4 sm:ml-0 sm:mr-36 sm:p-0">
296+
<div>
297+
<Skeleton as={Label} htmlFor="timeZone" className="mb-0 inline-block leading-none">
298+
{t("timezone")}
299+
</Skeleton>
300+
<Controller
301+
control={form.control}
302+
name="timeZone"
303+
render={({ field: { onChange, value } }) =>
304+
value ? (
305+
<TimezoneSelect
306+
value={value}
307+
className="focus:border-brand-default border-default mt-1 block w-72 rounded-md text-sm"
308+
onChange={(timezone) => onChange(timezone.value)}
309+
/>
310+
) : (
311+
<SelectSkeletonLoader className="mt-1 w-72" />
312+
)
313+
}
314+
/>
315+
</div>
316+
<hr className="border-subtle my-7" />
317+
<div className="rounded-md md:block">
318+
<Skeleton as="h3" className="mb-0 inline-block text-sm font-medium">
319+
{t("something_doesnt_look_right")}
320+
</Skeleton>
321+
<div className="mt-3 flex">
322+
<Skeleton as={Button} href="/availability/troubleshoot" color="secondary">
323+
{t("launch_troubleshooter")}
324+
</Skeleton>
325+
</div>
326+
</div>
327+
</div>
328+
</div>
329+
</div>
330+
</div>
273331
<div className="border-default border-l-2" />
274332
<Button
275333
className="ml-4 lg:ml-0"
@@ -278,6 +336,13 @@ export default function Availability() {
278336
loading={updateMutation.isLoading}>
279337
{t("save")}
280338
</Button>
339+
<Button
340+
className="ml-3 sm:hidden"
341+
StartIcon={MoreVertical}
342+
variant="icon"
343+
color="secondary"
344+
onClick={() => setOpenSidebar(true)}
345+
/>
281346
</div>
282347
}>
283348
<div className="mt-4 w-full md:mt-0">
@@ -313,7 +378,7 @@ export default function Availability() {
313378
{schedule?.workingHours && <DateOverride workingHours={schedule.workingHours} />}
314379
</div>
315380
</div>
316-
<div className="min-w-40 col-span-3 space-y-2 lg:col-span-1">
381+
<div className="min-w-40 col-span-3 hidden space-y-2 md:block lg:col-span-1">
317382
<div className="xl:max-w-80 w-full pr-4 sm:ml-0 sm:mr-36 sm:p-0">
318383
<div>
319384
<Skeleton as={Label} htmlFor="timeZone" className="mb-0 inline-block leading-none">
@@ -335,7 +400,7 @@ export default function Availability() {
335400
/>
336401
</div>
337402
<hr className="border-subtle my-6 mr-8" />
338-
<div className="hidden rounded-md md:block">
403+
<div className="rounded-md">
339404
<Skeleton as="h3" className="mb-0 inline-block text-sm font-medium">
340405
{t("something_doesnt_look_right")}
341406
</Skeleton>

apps/web/public/static/locales/en/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@
266266
"nearly_there_instructions": "Last thing, a brief description about you and a photo really helps you get bookings and let people know who they’re booking with.",
267267
"set_availability_instructions": "Define ranges of time when you are available on a recurring basis. You can create more of these later and assign them to different calendars.",
268268
"set_availability": "Set your availability",
269+
"availability_settings": "Availability Settings",
269270
"continue_without_calendar": "Continue without calendar",
270271
"connect_your_calendar": "Connect your calendar",
271272
"connect_your_video_app": "Connect your video apps",

0 commit comments

Comments
 (0)