update props and add schedule list item to view

availability-list
Ryukemeister 2023-10-16 15:21:32 +05:30
parent 7a4f1fc098
commit 9d3b512ef6
1 changed files with 18 additions and 7 deletions

View File

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