* Fix breadcrumb colors * HorizontalTabs * Team List Item WIP * Horizontal Tabs * Cards * Remove team list item WIP * Login Page * Add welcome back i118n * EventType page work * Update EventType Icons * WIP Availability * Horizontal Tab Work * Add build command for in root * Update build DIr/command * Add Edit Button + change buttons to v2 * Availablitiy page * Fix IPAD * Make mobile look a little nicer * WIP bookingshell * Remove list items from breaking build * Mian bulk of Booking Page. * Few updates to components * Fix chormatic feedback * Fix banner * Fix Empty Screen * Text area + embded window fixes * Semi fix avatar * Troubleshoot container + Active on count * Improve mobile * NITS * Fix padding on input * Fix icons * Starting to move event types settings to tabs * Begin migration to single page form * Single page tabs * Limits Page * Advanced tab * Add RHF to dependancies * Most of advanced tab * Solved RHF mismtach * Build fixes * RHF conditionals fixes * Improved legibility * Major refactor/organisation into optional V2 UI * Portal EditLocationModal * Fix dialoug form * Update imports * Auto Animate + custom inputs WIP * Custom Inputs * WIP Apps * Fixing stories imports * Stripe app * Remove duplicate dialog * Remove duplicate dialog * Fix embed URL * Fix app toggles + number of active apps * Fix container padding on disabledBorder prop * Removes strict * EventType Team page WIP * Fix embed * NIT * Add Darkmode gray color * V2 Shell WIP * Fix headings on shell V2 * Fix mobile layout with V2 shell * V2 create event type button * Checked Team Select * Hidden to happen on save - not on toggle * Team Attendee Select animation * Fix scheduling type and remove multi select label * Fix overflow on teams url * Even Type move order handles * Fix Embed TS errors * Fix TS errors * Fix Eslint errors * Fix TS errors for UI * Fix ESLINT error * added SidebarCard for promo to v2 and storybook (#3906) Co-authored-by: Julian Benegas <julianbenegas99@gmail.com> Co-authored-by: Alan <alannnc@gmail.com> Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com> * Tooltip Provider - Wrapper due to dep upgrade * public event type list darkmode * V2 Color changes to public booking * Remove unused component * Fix typecheck * Removed extra buttons on create ET dialog * ET edit page refactoring * Avoids form wrapping the whole Shell * Nitpicks Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: zomars <zomars@me.com> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com> Co-authored-by: Julian Benegas <julianbenegas99@gmail.com> Co-authored-by: Alan <alannnc@gmail.com>
151 lines
5.9 KiB
TypeScript
151 lines
5.9 KiB
TypeScript
import Link from "next/link";
|
|
import { useRouter } from "next/router";
|
|
import { FC, useEffect, useState } from "react";
|
|
|
|
import dayjs, { Dayjs } from "@calcom/dayjs";
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { nameOfDay } from "@calcom/lib/weekday";
|
|
import type { Slot } from "@calcom/trpc/server/routers/viewer/slots";
|
|
import { SkeletonContainer, SkeletonText } from "@calcom/ui";
|
|
|
|
import classNames from "@lib/classNames";
|
|
import { timeZone } from "@lib/clock";
|
|
|
|
type AvailableTimesProps = {
|
|
timeFormat: string;
|
|
eventTypeId: number;
|
|
recurringCount: number | undefined;
|
|
eventTypeSlug: string;
|
|
date: Dayjs;
|
|
seatsPerTimeSlot?: number | null;
|
|
slots?: Slot[];
|
|
isLoading: boolean;
|
|
};
|
|
|
|
const AvailableTimes: FC<AvailableTimesProps> = ({
|
|
slots = [],
|
|
isLoading,
|
|
date,
|
|
eventTypeId,
|
|
eventTypeSlug,
|
|
recurringCount,
|
|
timeFormat,
|
|
seatsPerTimeSlot,
|
|
}) => {
|
|
const { t, i18n } = useLocale();
|
|
const router = useRouter();
|
|
const { rescheduleUid } = router.query;
|
|
|
|
const [brand, setBrand] = useState("#292929");
|
|
|
|
useEffect(() => {
|
|
setBrand(getComputedStyle(document.documentElement).getPropertyValue("--brand-color").trim());
|
|
}, []);
|
|
|
|
return (
|
|
<div className="dark:bg-darkgray-200 mt-8 flex flex-col px-4 text-center sm:mt-0 sm:w-1/3 sm:p-5 md:-mb-4">
|
|
<div className="mb-4 text-left text-base">
|
|
<span className="text-bookingdarker mb-8 w-1/2 break-words font-semibold text-gray-900 dark:text-white">
|
|
{nameOfDay(i18n.language, Number(date.format("d")))}
|
|
</span>
|
|
<span className="text-bookinglight font-medium">
|
|
{date.format(", D ")}
|
|
{date.toDate().toLocaleString(i18n.language, { month: "long" })}
|
|
</span>
|
|
</div>
|
|
<div className="grid flex-grow grid-cols-2 gap-x-2 overflow-y-auto sm:block md:h-[364px]">
|
|
{slots.length > 0 &&
|
|
slots.map((slot) => {
|
|
type BookingURL = {
|
|
pathname: string;
|
|
query: Record<string, string | number | string[] | undefined>;
|
|
};
|
|
const bookingUrl: BookingURL = {
|
|
pathname: "book",
|
|
query: {
|
|
...router.query,
|
|
date: dayjs(slot.time).format(),
|
|
type: eventTypeId,
|
|
slug: eventTypeSlug,
|
|
/** Treat as recurring only when a count exist and it's not a rescheduling workflow */
|
|
count: recurringCount && !rescheduleUid ? recurringCount : undefined,
|
|
},
|
|
};
|
|
|
|
if (rescheduleUid) {
|
|
bookingUrl.query.rescheduleUid = rescheduleUid as string;
|
|
}
|
|
|
|
// If event already has an attendee add booking id
|
|
if (slot.bookingUid) {
|
|
bookingUrl.query.bookingUid = slot.bookingUid;
|
|
}
|
|
|
|
return (
|
|
<div key={dayjs(slot.time).format()}>
|
|
{/* Current there is no way to disable Next.js Links */}
|
|
{seatsPerTimeSlot && slot.attendees && slot.attendees >= seatsPerTimeSlot ? (
|
|
<div
|
|
className={classNames(
|
|
"text-primary-500 dark:bg-darkgray-200 dark:text-darkgray-900 mb-2 block rounded-sm border bg-white py-4 font-medium opacity-25 dark:border-transparent ",
|
|
brand === "#fff" || brand === "#ffffff" ? "border-brandcontrast" : "border-brand"
|
|
)}>
|
|
{dayjs(slot.time).tz(timeZone()).format(timeFormat)}
|
|
{!!seatsPerTimeSlot && <p className="text-sm">{t("booking_full")}</p>}
|
|
</div>
|
|
) : (
|
|
<Link href={bookingUrl} prefetch={false}>
|
|
<a
|
|
className={classNames(
|
|
"text-primary-500 hover:bg-brand hover:text-brandcontrast dark:hover:bg-darkmodebrand",
|
|
"dark:hover:text-darkmodebrandcontrast dark:bg-darkgray-50 dark:hover:border-darkgray-900 mb-2 block rounded-md border-2 bg-white py-4 text-sm font-medium hover:text-white dark:border-transparent dark:text-neutral-200",
|
|
brand === "#fff" || brand === "#ffffff" ? "border-brandcontrast" : "border-brand"
|
|
)}
|
|
data-testid="time">
|
|
{dayjs(slot.time).tz(timeZone()).format(timeFormat)}
|
|
{!!seatsPerTimeSlot && (
|
|
<p
|
|
className={`${
|
|
slot.attendees && slot.attendees / seatsPerTimeSlot >= 0.8
|
|
? "text-rose-600"
|
|
: slot.attendees && slot.attendees / seatsPerTimeSlot >= 0.33
|
|
? "text-yellow-500"
|
|
: "text-emerald-400"
|
|
} text-sm`}>
|
|
{slot.attendees ? seatsPerTimeSlot - slot.attendees : seatsPerTimeSlot} /{" "}
|
|
{seatsPerTimeSlot} {t("seats_available")}
|
|
</p>
|
|
)}
|
|
</a>
|
|
</Link>
|
|
)}
|
|
</div>
|
|
);
|
|
})}
|
|
|
|
{!isLoading && !slots.length && (
|
|
<div className="-mt-4 flex h-full w-full flex-col content-center items-center justify-center">
|
|
<h1 className="my-6 text-xl text-black dark:text-white">{t("all_booked_today")}</h1>
|
|
</div>
|
|
)}
|
|
|
|
{isLoading && !slots.length && (
|
|
<>
|
|
<SkeletonContainer className="mb-2">
|
|
<SkeletonText width="full" height="20" />
|
|
</SkeletonContainer>
|
|
<SkeletonContainer className="mb-2">
|
|
<SkeletonText width="full" height="20" />
|
|
</SkeletonContainer>
|
|
<SkeletonContainer className="mb-2">
|
|
<SkeletonText width="full" height="20" />
|
|
</SkeletonContainer>
|
|
</>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default AvailableTimes;
|