feat: dynamic group links + flexible schedule (#9931)
* redirect user to /[user]/[type] for dynamic booking in /[user] * feat: dynamic group links * fix: type errors * fix: more type errors * Booker components cannot rely on useRouter * Rename 15min/30/60 to dynamic * Fixed a blocking test, unclear what it was waiting for --------- Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
1 parent
829a103f6b
commit
94b4507901
4 files changed
+52
-153
No files matched your search
@@ -236,10 +236,7 @@ test.describe("Routing Forms", () => {
|
||||
await user.apiLogin();
|
||||
|
||||
await page.goto(`/apps/routing-forms/reporting/${routingForm.id}`);
|
||||
// Can't keep waiting forever. So, added a timeout of 5000ms
|
||||
await page.waitForResponse((response) => response.url().includes("appRoutingForms/report"), {
|
||||
timeout: 5000,
|
||||
});
|
||||
|
||||
const headerEls = page.locator("[data-testid='reporting-header'] th");
|
||||
// Once the response is there, React would soon render it, so 500ms is enough
|
||||
// FIXME: Sometimes it takes more than 500ms, so added a timeout of 1000ms for now. There might be something wrong with rendering.
|
||||
|
||||
@@ -14,17 +14,23 @@ export const EventDuration = ({ event }: { event: PublicEvent }) => {
|
||||
state.setSelectedDuration,
|
||||
]);
|
||||
|
||||
const isDynamicEvent = "isDynamic" in event && event.isDynamic;
|
||||
|
||||
// Sets initial value of selected duration to the default duration.
|
||||
useEffect(() => {
|
||||
// Only store event duration in url if event has multiple durations.
|
||||
if (!selectedDuration && event.metadata?.multipleDuration) setSelectedDuration(event.length);
|
||||
}, [selectedDuration, setSelectedDuration, event.length, event.metadata?.multipleDuration]);
|
||||
if (!selectedDuration && (event.metadata?.multipleDuration || isDynamicEvent))
|
||||
setSelectedDuration(event.length);
|
||||
}, [selectedDuration, setSelectedDuration, event.metadata?.multipleDuration, event.length, isDynamicEvent]);
|
||||
|
||||
if (!event?.metadata?.multipleDuration) return <>{t("multiple_duration_mins", { count: event.length })}</>;
|
||||
if (!event?.metadata?.multipleDuration && !isDynamicEvent)
|
||||
return <>{t("multiple_duration_mins", { count: event.length })}</>;
|
||||
|
||||
const durations = event?.metadata?.multipleDuration || [15, 30, 60];
|
||||
|
||||
return (
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{event.metadata.multipleDuration.map((duration) => (
|
||||
{durations.map((duration) => (
|
||||
<Badge
|
||||
variant="gray"
|
||||
className={classNames(selectedDuration === duration && "bg-brand-default text-brand")}
|
||||
|
||||
@@ -106,38 +106,18 @@ const commons = {
|
||||
}),
|
||||
};
|
||||
|
||||
const min15Event = {
|
||||
length: 15,
|
||||
slug: "15",
|
||||
title: "15min",
|
||||
eventName: "Dynamic Collective 15min Event",
|
||||
description: "Dynamic Collective 15min Event",
|
||||
descriptionAsSafeHTML: "Dynamic Collective 15min Event",
|
||||
const dynamicEvent = {
|
||||
length: 30,
|
||||
slug: "dynamic",
|
||||
title: "Dynamic",
|
||||
eventName: "Dynamic Event",
|
||||
description: "",
|
||||
descriptionAsSafeHTML: "",
|
||||
position: 0,
|
||||
...commons,
|
||||
};
|
||||
const min30Event = {
|
||||
length: 30,
|
||||
slug: "30",
|
||||
title: "30min",
|
||||
eventName: "Dynamic Collective 30min Event",
|
||||
description: "Dynamic Collective 30min Event",
|
||||
descriptionAsSafeHTML: "Dynamic Collective 30min Event",
|
||||
position: 1,
|
||||
...commons,
|
||||
};
|
||||
const min60Event = {
|
||||
length: 60,
|
||||
slug: "60",
|
||||
title: "60min",
|
||||
eventName: "Dynamic Collective 60min Event",
|
||||
description: "Dynamic Collective 60min Event",
|
||||
descriptionAsSafeHTML: "Dynamic Collective 60min Event",
|
||||
position: 2,
|
||||
...commons,
|
||||
};
|
||||
|
||||
const defaultEvents = [min15Event, min30Event, min60Event];
|
||||
const defaultEvents = [dynamicEvent];
|
||||
|
||||
export const getDynamicEventDescription = (dynamicUsernames: string[], slug: string): string => {
|
||||
return `Book a ${slug} min event with ${dynamicUsernames.join(", ")}`;
|
||||
@@ -152,7 +132,7 @@ export const getDefaultEvent = (slug: string) => {
|
||||
const event = defaultEvents.find((obj) => {
|
||||
return obj.slug === slug;
|
||||
});
|
||||
return event || min15Event;
|
||||
return event || dynamicEvent;
|
||||
};
|
||||
|
||||
export const getGroupName = (usernameList: string[]): string => {
|
||||
|
||||
Reference in new issue
Block a user