2021-06-19 22:50:47 +00:00
|
|
|
import Link from "next/link";
|
2021-06-24 22:15:18 +00:00
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import Slots from "./Slots";
|
2021-06-19 22:50:47 +00:00
|
|
|
|
2021-06-24 22:15:18 +00:00
|
|
|
const AvailableTimes = ({ date, eventLength, eventTypeId, workingHours, timeFormat }) => {
|
2021-06-19 22:50:47 +00:00
|
|
|
const router = useRouter();
|
|
|
|
const { user, rescheduleUid } = router.query;
|
2021-06-27 22:02:27 +00:00
|
|
|
const { slots, isFullyBooked } = Slots({ date, eventLength, workingHours });
|
2021-06-19 22:50:47 +00:00
|
|
|
return (
|
|
|
|
<div className="sm:pl-4 mt-8 sm:mt-0 text-center sm:w-1/3 md:max-h-97 overflow-y-auto">
|
|
|
|
<div className="text-gray-600 font-light text-xl mb-4 text-left">
|
2021-06-24 22:15:18 +00:00
|
|
|
<span className="w-1/2">{date.format("dddd DD MMMM YYYY")}</span>
|
2021-06-19 22:50:47 +00:00
|
|
|
</div>
|
2021-06-24 22:15:18 +00:00
|
|
|
{slots.length > 0 ? (
|
|
|
|
slots.map((slot) => (
|
|
|
|
<div key={slot.format()}>
|
2021-06-20 00:10:08 +00:00
|
|
|
<Link
|
2021-06-24 22:15:18 +00:00
|
|
|
href={
|
|
|
|
`/${user}/book?date=${slot.utc().format()}&type=${eventTypeId}` +
|
|
|
|
(rescheduleUid ? "&rescheduleUid=" + rescheduleUid : "")
|
|
|
|
}>
|
|
|
|
<a className="block font-medium mb-4 text-blue-600 border border-blue-600 rounded hover:text-white hover:bg-blue-600 py-4">
|
|
|
|
{slot.format(timeFormat)}
|
|
|
|
</a>
|
2021-06-20 00:10:08 +00:00
|
|
|
</Link>
|
|
|
|
</div>
|
2021-06-24 22:15:18 +00:00
|
|
|
))
|
2021-06-27 22:02:27 +00:00
|
|
|
) : isFullyBooked ?
|
|
|
|
<div className="w-full h-full flex flex-col justify-center content-center items-center -mt-4">
|
|
|
|
<h1 className="text-xl font">{user} is all booked today.</h1>
|
|
|
|
</div>
|
|
|
|
: <div className="loader" />
|
|
|
|
}
|
2021-06-19 22:50:47 +00:00
|
|
|
</div>
|
|
|
|
);
|
2021-06-24 22:15:18 +00:00
|
|
|
};
|
2021-06-19 22:50:47 +00:00
|
|
|
|
2021-06-22 15:19:28 +00:00
|
|
|
export default AvailableTimes;
|