make path prettier

proto/trying-alternative-approach
KATT 2021-11-19 12:28:30 +01:00
parent 22545c3e40
commit 6cd30f0a41
1 changed files with 10 additions and 12 deletions

View File

@ -78,21 +78,19 @@ const AvailableTimes: FC<AvailableTimesProps> = ({
{!loading &&
slots?.length > 0 &&
slots.map((slot) => {
let bookingUrl = `/${basePath}/book?date=${encodeURIComponent(
slot.time.format()
)}&type=${eventTypeId}`;
if (rescheduleUid) {
bookingUrl += `&rescheduleUid=${rescheduleUid}`;
}
if (schedulingType === SchedulingType.ROUND_ROBIN) {
bookingUrl += `&user=${slot.users}`;
}
const url = {
pathname: `/${basePath}/book`,
query: {
type: eventTypeId,
// conditionally add things to query params
...(rescheduleUid ? { rescheduleUid } : {}),
...(schedulingType === SchedulingType.ROUND_ROBIN ? { user: slot.users } : {}),
},
};
return (
<div key={slot.time.format()}>
<Link href={bookingUrl}>
<Link href={url} as={url}>
<a
className="block py-4 mb-2 font-medium bg-white border rounded-sm dark:bg-gray-600 text-primary-500 dark:text-neutral-200 border-brand dark:border-transparent hover:text-white hover:bg-brand dark:hover:border-black dark:hover:bg-black"
data-testid="time">