Files
calendar/packages/features/bookings/Booker/components/HavingTroubleFindingTime.tsx
853f9bc436 perf: do not import from @calcom/ui barrel file (#20184)
* Icon and IconName

* Button and ButtonGroup

* UserAvatar

* AvatarGroup

* Avatar

* WizardLayout

* Dialogs

* EmptyScreen

* showToast and TextField

* Editor

* Skeleton

* Skeleton

* TopBanner and showToast

* Button again

* more

* perf: Remove app-store reference from @calcom/ui

* more

* Fixing types

* Icon

* Fixed casing

* dropdown

* more

* Select

* more

* Badge

* List

* more

* Divider

* more

* fix

* fix type check

* refactor

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix type check

* fix

* fix

* fix

* fix

* more

* more

* more

* more

* add index file to components/command

* fix

* fix

* fix

* fix imports

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix build errors

* fix build errors

* fix

---------

Co-authored-by: Keith Williams <[email protected]>
2025-03-19 19:00:55 -03:00

49 lines
1.8 KiB
TypeScript

import { useState } from "react";
import { BOOKER_NUMBER_OF_DAYS_TO_LOAD } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Icon } from "@calcom/ui/components/icon";
type Props = {
onButtonClick: () => void;
dayCount: number | null;
visible: boolean;
isScheduleLoading: boolean;
};
export function HavingTroubleFindingTime(props: Props) {
const { t } = useLocale();
const [internalClick, setInternalClick] = useState(false);
if (!props.visible) return null;
// Easiest way to detect if its not enabled
if (
(process.env.NEXT_PUBLIC_BOOKER_NUMBER_OF_DAYS_TO_LOAD == "0" && BOOKER_NUMBER_OF_DAYS_TO_LOAD == 0) ||
!process.env.NEXT_PUBLIC_BOOKER_NUMBER_OF_DAYS_TO_LOAD
)
return null;
// If we have clicked this internally - and the schedule above is not loading - hide this banner as there is no use of being able to go backwards
if (internalClick && !props.isScheduleLoading) return null;
if (props.isScheduleLoading || !props.dayCount) return null;
return (
<div className="bg-default border-subtle mt-6 flex w-1/2 min-w-0 items-center justify-between rounded-[32px] border p-3 text-sm leading-none shadow-sm lg:w-1/3">
<div className="flex items-center gap-2 overflow-x-hidden">
<Icon name="info" className="text-default h-4 w-4" />
<p className="w-full leading-none">{t("having_trouble_finding_time")}</p>
</div>
{/* TODO: we should give this more of a touch target on mobile */}
<button
className="inline-flex items-center gap-2 font-medium"
onClick={(e) => {
e.preventDefault();
props.onButtonClick();
setInternalClick(true);
}}>
{t("show_more")} <Icon name="arrow-right" className="h-4 w-4" />
</button>
</div>
);
}