2022-12-14 13:36:10 +00:00
|
|
|
import { useId } from "react";
|
|
|
|
|
2023-04-05 18:14:46 +00:00
|
|
|
import type dayjs from "@calcom/dayjs";
|
2023-06-15 09:59:58 +00:00
|
|
|
import { useTimePreferences } from "@calcom/features/bookings/lib";
|
2022-12-14 13:36:10 +00:00
|
|
|
|
|
|
|
export const HorizontalLines = ({
|
|
|
|
hours,
|
|
|
|
numberOfGridStopsPerCell,
|
|
|
|
containerOffsetRef,
|
|
|
|
}: {
|
|
|
|
hours: dayjs.Dayjs[];
|
|
|
|
numberOfGridStopsPerCell: number;
|
|
|
|
containerOffsetRef: React.RefObject<HTMLDivElement>;
|
|
|
|
}) => {
|
2023-06-15 09:59:58 +00:00
|
|
|
const { timeFormat } = useTimePreferences();
|
|
|
|
// We need to force the minute to zero, because otherwise in ex GMT+5.5, it would show :30 minute times (but at the positino of :00)
|
|
|
|
const finalHour = hours[hours.length - 1].add(1, "hour").minute(0).format(timeFormat);
|
2022-12-14 13:36:10 +00:00
|
|
|
const id = useId();
|
|
|
|
return (
|
|
|
|
<div
|
2023-06-09 09:38:18 +00:00
|
|
|
className=" divide-default pointer-events-none relative z-[60] col-start-1 col-end-2 row-start-1 grid divide-y"
|
2022-12-14 13:36:10 +00:00
|
|
|
style={{
|
2023-06-09 09:38:18 +00:00
|
|
|
gridTemplateRows: `repeat(${hours.length}, minmax(var(--gridDefaultSize),1fr)`,
|
2022-12-14 13:36:10 +00:00
|
|
|
}}>
|
2023-06-15 09:59:58 +00:00
|
|
|
<div className="row-end-1 h-[--calendar-offset-top] " ref={containerOffsetRef} />
|
2022-12-14 13:36:10 +00:00
|
|
|
{hours.map((hour) => (
|
2023-06-15 09:59:58 +00:00
|
|
|
<div key={`${id}-${hour.get("hour")}`}>
|
2023-06-22 22:25:37 +00:00
|
|
|
<div className="text-muted sticky left-0 z-20 -ml-14 -mt-2.5 w-14 pr-2 text-right text-xs leading-5">
|
2023-06-15 09:59:58 +00:00
|
|
|
{/* We need to force the minute to zero, because otherwise in ex GMT+5.5, it would show :30 minute times (but at the positino of :00) */}
|
|
|
|
{hour.minute(0).format(timeFormat)}
|
2022-12-14 13:36:10 +00:00
|
|
|
</div>
|
2023-06-15 09:59:58 +00:00
|
|
|
</div>
|
2022-12-14 13:36:10 +00:00
|
|
|
))}
|
|
|
|
<div key={`${id}-${finalHour}`}>
|
2023-06-22 22:25:37 +00:00
|
|
|
<div className="text-muted sticky left-0 z-20 -ml-14 -mt-2.5 w-14 pr-2 text-right text-xs leading-5">
|
2022-12-14 13:36:10 +00:00
|
|
|
{finalHour}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|