Load schedule from event slug

feat/troubleshooter-v2
Sean Brydon 2023-10-25 14:18:55 +01:00
parent 6b6e9dba2b
commit a9bf0d625f
1 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,29 @@
import { trpc } from "@calcom/trpc/react";
import { Label } from "@calcom/ui";
import { useTroubleshooterStore } from "../store";
import { TroubleshooterListItemHeader } from "./TroubleshooterListItemContainer";
export function EventScheduleItem() {
const selectedEventType = useTroubleshooterStore((state) => state.eventSlug);
const { data: schedule, isLoading } = trpc.viewer.availability.schedule.getScheduleByEventSlug.useQuery(
{
eventSlug: selectedEventType as string, // Only enabled when selectedEventType is not null
},
{
enabled: !!selectedEventType,
}
);
return (
<div>
<Label>Availability Schedule</Label>
<TroubleshooterListItemHeader
className="rounded-md border-b " // Target paragraph inside nested children to make medium (saves us from creating a new component)
prefixSlot={<div className="w-4 rounded-[4px] bg-black" />}
title={schedule?.name ?? "Loading"}
/>
</div>
);
}