Feature/parallel booking availability (#3087)

This commit is contained in:
Omar López authored and GitHub committed 2022-06-19 16:02:00 +01:00
1 parent 7599f2384e
commit 2d28ca61a4
21 files changed
+242 -121

No files matched your search

+7 -14
View File
@@ -34,19 +34,15 @@ export type DatePickerProps = {
isLoading?: boolean;
};
const Day = ({
export const Day = ({
date,
active,
...props
}: JSX.IntrinsicElements["button"] & { active: boolean; date: Date }) => {
return (
<button
style={props.disabled ? {} : {}}
className={classNames(
"absolute top-0 left-0 right-0 bottom-0 mx-auto w-full rounded-sm border border-transparent text-center",
props.disabled
? "text-bookinglighter cursor-default font-light"
: "hover:border-brand font-medium dark:hover:border-white",
"hover:border-brand disabled:text-bookinglighter absolute top-0 left-0 right-0 bottom-0 mx-auto w-full rounded-sm border border-transparent text-center font-medium disabled:cursor-default disabled:border-transparent disabled:font-light dark:hover:border-white disabled:dark:border-transparent",
active
? "bg-brand text-brandcontrast dark:bg-darkmodebrand dark:text-darkmodebrandcontrast"
: !props.disabled
@@ -68,9 +64,11 @@ const Days = ({
includedDates = [],
browsingDate,
weekStart,
DayComponent = Day,
selected,
...props
}: Omit<DatePickerProps, "locale" | "className" | "weekStart"> & {
DayComponent?: React.FC<React.ComponentProps<typeof Day>>;
browsingDate: Date;
weekStart: number;
}) => {
@@ -90,16 +88,11 @@ const Days = ({
return (
<>
{days.map((day, idx) => (
<div
key={day === null ? `e-${idx}` : `day-${day}`}
style={{
paddingTop: "100%",
}}
className="relative w-full">
<div key={day === null ? `e-${idx}` : `day-${day}`} className="relative w-full pt-[100%]">
{day === null ? (
<div key={`e-${idx}`} />
) : (
<Day
<DayComponent
date={day}
onClick={() => props.onChange(day)}
disabled={
@@ -139,7 +132,7 @@ const DatePicker = ({
onMonthChange,
isLoading = false,
...passThroughProps
}: DatePickerProps) => {
}: DatePickerProps & Partial<React.ComponentProps<typeof Days>>) => {
const [month, setMonth] = useState(selected ? selected.getMonth() : new Date().getMonth());
const changeMonth = (newMonth: number) => {