feat: v2 api endpoints and hooks to list private and public event types of user (#14192)
* refactor: extract getEventTypeByViewer for private user dashboard event types * refactor: extract getEventTypesPublic for public event types to book * refactor: group event-types lib functions in single folder * refactor: rename getEventTypeByViewer to getEventTypesByViewer * feat: add event type helpers from lib to platform libraries * feat: v2 endpoint for private event types * driveby:fix: fixed date in docs instead of being re-generated * feature: endpoint to fetch public endpoints * fix: getting private event types * tests: fetch private event types * tests: fetch private event types * feat: hooks for public and private events * fix: yarn test * tests: IMO better mocking * refactor: track dynamic prop in react query * fix: distinct query key for public events * fix: username in query key and example app demo * fix: swagger for endpoint get public event input --------- Co-authored-by: Morgan Vernay <[email protected]> Co-authored-by: Morgan <[email protected]>
This commit is contained in:
24 files changed
+680
-410
No files matched your search
@@ -2,19 +2,39 @@ import { Navbar } from "@/components/Navbar";
|
||||
import { Inter } from "next/font/google";
|
||||
import { useState } from "react";
|
||||
|
||||
import { Booker } from "@calcom/atoms";
|
||||
import { Booker, useEventTypesPublic } from "@calcom/atoms";
|
||||
|
||||
const inter = Inter({ subsets: ["latin"] });
|
||||
|
||||
export default function Bookings(props: { calUsername: string; calEmail: string }) {
|
||||
const [bookingTitle, setBookingTitle] = useState<string | null>(null);
|
||||
const [eventTypeSlug, setEventTypeSlug] = useState<string | null>(null);
|
||||
|
||||
const { isLoading: isLoadingEvents, data: eventTypes } = useEventTypesPublic(props.calUsername);
|
||||
console.log(isLoadingEvents, eventTypes);
|
||||
return (
|
||||
<main
|
||||
className={`flex min-h-screen flex-col ${inter.className} main text-default flex min-h-full w-full flex-col items-center overflow-visible`}>
|
||||
<Navbar username={props.calUsername} />
|
||||
<div>
|
||||
<h1 className="my-4 text-2xl font-semibold">{props.calUsername} Public Booking Page</h1>
|
||||
{!bookingTitle && (
|
||||
|
||||
{isLoadingEvents && !eventTypeSlug && <p>Loading...</p>}
|
||||
|
||||
{!isLoadingEvents && !eventTypeSlug && Boolean(eventTypes?.length) && (
|
||||
<div className="flex flex-row gap-4">
|
||||
{eventTypes?.map((event: { id: number; slug: string; title: string }) => (
|
||||
<button
|
||||
key={event.id}
|
||||
className="rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700"
|
||||
onClick={() => setEventTypeSlug(event.slug)}>
|
||||
{event.slug}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!bookingTitle && eventTypeSlug && (
|
||||
<Booker
|
||||
eventSlug="sixty-minutes-video"
|
||||
username={props.calUsername ?? ""}
|
||||
|
||||
Reference in new issue
Block a user