feat: atoms team booking (#14525)

* feat: setup usePublicEvent with orgSlug and duration

* feat: setup useAvailableSlots with eventTypeSlug and orgSlug

* fix & feat: fix TS issues and allow passing multiple users to Booker

* refactor: dont show [15min] [30min] [60min] [1h30min] picker

* fix: pass orgSlug to handleNewBooking -> loadUsers -> findUsersByUsername to not return empty users[]

* refactor: display attendees in booking confirmation screen

* fix: getting slots get orgSlug from props not event

* revert: Booker username use props instead of hardcoded values

* refactor: setup BookerStore org and use it for selectedTime + isDynamic logic

* refactor: hide 'what is this meeting about' input in final booking step

* fix: TS error

* revert: what is the meeting about field hiding

* revert: make org as org? in booker store

* revert: createNewBooking -> loadUsers -> get forced orgSlug from header not body

* refactor: useHandleBookEvent get orgSlug from booker store not props

* fix: if entity undefined dont access orgSlug

* refactor: add isDynamic prop as queryKey for usePublicEvent

* refactor: remove unused prop

* re-add docs

* fix: typescript error

* fix: force platform orgSlug in handleNewBooking.ts

* fix: remove duplicate setSelectedDuration declaration

* refactor: destructure properies from body instead of req.body

* fix: entity optional and hide event members

---------

Co-authored-by: Morgan <[email protected]>
Co-authored-by: Morgan Vernay <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-05-07 12:51:00 +00:00
1 parent cfcf5b168c
commit a2620a0e50
18 files changed
+148 -33

No files matched your search

@@ -93,12 +93,17 @@ export default function Bookings(props: { calUsername: string; calEmail: string
<p>{booking.user?.email}</p>
</div>
</div>
<div>
<div>
<h4>{`${booking.responses.name}`}</h4>
<p>{`${booking.responses.email}`}</p>
</div>
</div>
{booking.attendees.map((attendee, i) => {
return (
<div key={`${i}-${attendee.name}`}>
<br />
<div>
<h4>{`${attendee.name}`}</h4>
<p>{`${attendee.email}`}</p>
</div>
</div>
);
})}
</div>
</div>
{!!booking.location && booking.location.startsWith("http") && (
@@ -11,10 +11,12 @@ 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 [eventTypeDuration, setEventTypeDuration] = useState<number | null>(null);
const router = useRouter();
const { isLoading: isLoadingEvents, data: eventTypes } = useEventTypesPublic(props.calUsername);
const rescheduleUid = (router.query.rescheduleUid as string) ?? "";
const eventTypeSlugQueryParam = (router.query.eventTypeSlug as string) ?? "";
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`}>
@@ -34,7 +36,10 @@ export default function Bookings(props: { calUsername: string; calEmail: string
return (
<div
onClick={() => setEventTypeSlug(event.slug)}
onClick={() => {
setEventTypeSlug(event.slug);
setEventTypeDuration(event.length);
}}
className="mx-10 w-[80vw] cursor-pointer rounded-md border-[0.8px] border-black px-10 py-4"
key={event.id}>
<h1 className="text-lg font-semibold">{formatEventSlug}</h1>
@@ -51,9 +56,23 @@ export default function Bookings(props: { calUsername: string; calEmail: string
eventSlug={eventTypeSlug}
username={props.calUsername ?? ""}
onCreateBookingSuccess={(data) => {
setBookingTitle(data.data.title);
setBookingTitle(data.data.title ?? "");
router.push(`/${data.data.uid}`);
}}
duration={eventTypeDuration}
customClassNames={{
bookerContainer: "!bg-[#F5F2FE] [&_button:!rounded-full] border-subtle border",
datePickerCustomClassNames: {
datePickerDatesActive: "!bg-[#D7CEF5]",
},
eventMetaCustomClassNames: {
eventMetaTitle: "text-[#7151DC]",
},
availableTimeSlotsCustomClassNames: {
availableTimeSlotsHeaderContainer: "!bg-[#F5F2FE]",
availableTimes: "!bg-[#D7CEF5]",
},
}}
/>
)}
{!bookingTitle && rescheduleUid && eventTypeSlugQueryParam && (
@@ -62,9 +81,14 @@ export default function Bookings(props: { calUsername: string; calEmail: string
eventSlug={eventTypeSlugQueryParam}
username={props.calUsername ?? ""}
onCreateBookingSuccess={(data) => {
setBookingTitle(data.data.title);
setBookingTitle(data.data.title ?? "");
router.push(`/${data.data.uid}`);
}}
duration={eventTypeDuration}
entity={{
orgSlug: "ecorp",
considerUnpublished: false,
}}
/>
)}
{bookingTitle && <p>Booking created: {bookingTitle}</p>}
@@ -30,6 +30,8 @@ export default function Bookings(props: { calUsername: string; calEmail: string
<h1 className="my-4 text-2xl font-semibold">{props.calUsername} Bookings</h1>
{isLoading && <p>Loading...</p>}
{!isLoading &&
pastBookings?.bookings &&
upcomingBookings?.bookings &&
(Boolean(upcomingBookings?.bookings.length) || Boolean(pastBookings?.bookings.length)) &&
[...pastBookings?.bookings, ...upcomingBookings?.bookings].map((booking) => {
const date = dayjs(booking.startTime).toDate();
@@ -62,7 +64,7 @@ export default function Bookings(props: { calUsername: string; calEmail: string
</div>
<div className="px-6">
<p>
{booking.user.name} and {booking.attendees[0].name}
{booking?.user?.name} and {booking.attendees[0].name}
</p>{" "}
<p />
</div>