Availability / Single View (#4467)

* Revamped Schedule before type fixes

* Removed t('copy_all'); fake focus state on CopyButton open

* Added skeletons, availability single view (wip, still a bit glitchy)

* Fixed isDefault switch glitchiness

* Fixes changing the default schedule to the created schedule

* Fix some type errors, on create set availability to DEFAULT_SCHEDULE

* Provided missing translation for copy_times_to

* Fix type errors, this may not be possible until v8 RHF

* Fix lint error

* Some responsiveness fixes

Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2022-09-15 05:49:59 +00:00
1 parent a3462657db
commit 33e8b5d227
5 files changed
+372 -369

No files matched your search

@@ -3,23 +3,16 @@ import { useRouter } from "next/router";
import { useForm } from "react-hook-form";
import { Schedule } from "@calcom/features/schedules";
import { DEFAULT_SCHEDULE } from "@calcom/lib/availability";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc, TRPCClientErrorLike } from "@calcom/trpc/react";
import { AppRouter } from "@calcom/trpc/server/routers/_app";
import { Form } from "@calcom/ui/form/fields";
import { Button } from "@calcom/ui/v2";
import { DEFAULT_SCHEDULE } from "@lib/availability";
import type { Schedule as ScheduleType } from "@lib/types/schedule";
interface ISetupAvailabilityProps {
nextStep: () => void;
defaultScheduleId?: number | null;
defaultAvailability?: { schedule?: TimeRanges[][] };
}
interface ScheduleFormValues {
schedule: ScheduleType;
}
const SetupAvailability = (props: ISetupAvailabilityProps) => {
@@ -37,7 +30,9 @@ const SetupAvailability = (props: ISetupAvailabilityProps) => {
}
const availabilityForm = useForm({
defaultValues: { schedule: queryAvailability?.data?.availability || DEFAULT_SCHEDULE },
defaultValues: {
schedule: queryAvailability?.data?.availability || DEFAULT_SCHEDULE,
},
});
const mutationOptions = {
@@ -51,7 +46,7 @@ const SetupAvailability = (props: ISetupAvailabilityProps) => {
const createSchedule = trpc.useMutation("viewer.availability.schedule.create", mutationOptions);
const updateSchedule = trpc.useMutation("viewer.availability.schedule.update", mutationOptions);
return (
<Form<ScheduleFormValues>
<Form
className="w-full bg-white text-black dark:bg-opacity-5 dark:text-white"
form={availabilityForm}
handleSubmit={async (values) => {
@@ -75,7 +70,7 @@ const SetupAvailability = (props: ISetupAvailabilityProps) => {
}
}
}}>
<Schedule />
<Schedule control={availabilityForm.control} name="schedule" weekStart={1} />
<div>
<Button