update props and add schedule list item to view
parent
7a4f1fc098
commit
9d3b512ef6
|
@ -4,17 +4,24 @@ import type { HttpError } from "@calcom/lib/http-error";
|
||||||
import { Clock } from "@calcom/ui/components/icon";
|
import { Clock } from "@calcom/ui/components/icon";
|
||||||
|
|
||||||
import { EmptyScreen } from "./EmptyScreen";
|
import { EmptyScreen } from "./EmptyScreen";
|
||||||
|
import ScheduleListItem from "./ScheduleListItem";
|
||||||
import type { Schedule } from ".prisma/client";
|
import type { Schedule } from ".prisma/client";
|
||||||
|
|
||||||
export function AvailabilityList({
|
export function AvailabilityList({
|
||||||
schedules,
|
schedules,
|
||||||
onCreateMutation,
|
onCreateMutation,
|
||||||
|
updateMutation,
|
||||||
|
duplicateMutation,
|
||||||
|
deleteMutation,
|
||||||
}: {
|
}: {
|
||||||
schedules: Schedule[] | [];
|
schedules: Schedule[] | [];
|
||||||
onCreateMutation: (values: {
|
onCreateMutation: (values: {
|
||||||
onSucess: (schedule: Schedule) => void;
|
onSucess: (schedule: Schedule) => void;
|
||||||
onError: (err: HttpError) => void;
|
onError: (err: HttpError) => void;
|
||||||
}) => void;
|
}) => void;
|
||||||
|
updateMutation: ({ scheduleId, isDefault }: { scheduleId: number; isDefault: boolean }) => void;
|
||||||
|
duplicateMutation: ({ scheduleId }: { scheduleId: number }) => void;
|
||||||
|
deleteMutation: ({ scheduleId }: { scheduleId: number }) => void;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -29,15 +36,19 @@ export function AvailabilityList({
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div>
|
<div className="border-subtle bg-default mb-16 overflow-hidden rounded-md border">
|
||||||
Render availability list here
|
<ul className="divide-subtle divide-y" data-testid="schedules">
|
||||||
<div>
|
|
||||||
{schedules.map((schedule) => (
|
{schedules.map((schedule) => (
|
||||||
<h1 key={schedule?.id}>
|
<ScheduleListItem
|
||||||
<h1>{schedule?.name}</h1>
|
key={schedule.id}
|
||||||
</h1>
|
schedule={schedule}
|
||||||
|
isDeletable={schedules.length !== 1}
|
||||||
|
updateDefault={updateMutation}
|
||||||
|
deleteFunction={deleteMutation}
|
||||||
|
duplicateFunction={duplicateMutation}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|
Loading…
Reference in New Issue