feat: Add rescheduledBy & canceledBy fields in the DB (#15337)

* feat: Add rescheduledBy & canceledBy fields in the DB

* fix: type check

* fix: type check

* fix: use session user email for reschedule

* fix: unit test

* feat: db field email validation

* feat: rescheduledBy and cancelledBy in webhooks

* revert unrelated changes.

* make session user secondary, default to Anonymous

* if condition not required

* Make cancelledBy optional

Co-authored-by: Syed Ali Shahbaz <[email protected]>

* update cancel booking type

* fix: update cancelledBy in db when requesting reschedule

* remove default value for fields

* fix: type check

* feat: manage fields via api v1

* fix: add fields in booking read api v1

* test: expand to cover new fields

* fix: use cancelledBy param on booking page

---------

Co-authored-by: Anik Dhabal Babu <[email protected]>
Co-authored-by: Syed Ali Shahbaz <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-08-25 11:31:46 +02:00
1 parent 34075ee303
commit b6d31129a3
28 files changed
+139 -20

No files matched your search

@@ -47,6 +47,7 @@ import { AtomsWrapper } from "../src/components/atoms-wrapper";
export type BookerPlatformWrapperAtomProps = Omit<BookerProps, "username" | "entity"> & {
rescheduleUid?: string;
rescheduledBy?: string;
bookingUid?: string;
username: string | string[] | undefined;
entity?: BookerProps["entity"];
@@ -357,6 +358,7 @@ export const BookerPlatformWrapper = (props: BookerPlatformWrapperAtomProps) =>
}
}
rescheduleUid={props.rescheduleUid ?? null}
rescheduledBy={null}
bookingUid={props.bookingUid ?? null}
isRedirect={false}
fromUserNameRedirected=""
@@ -39,6 +39,8 @@ export const BookerWebWrapper = (props: BookerWebWrapperAtomProps) => {
const fromUserNameRedirected = searchParams?.get("username") || "";
const rescheduleUid =
typeof window !== "undefined" ? new URLSearchParams(window.location.search).get("rescheduleUid") : null;
const rescheduledBy =
typeof window !== "undefined" ? new URLSearchParams(window.location.search).get("rescheduledBy") : null;
const bookingUid =
typeof window !== "undefined" ? new URLSearchParams(window.location.search).get("bookingUid") : null;
const date = dayjs(selectedDate).format("YYYY-MM-DD");
@@ -52,6 +54,7 @@ export const BookerWebWrapper = (props: BookerWebWrapperAtomProps) => {
...props,
eventId: event?.data?.id,
rescheduleUid,
rescheduledBy,
bookingUid: bookingUid,
layout: bookerLayout.defaultLayout,
org: props.entity.orgSlug,
@@ -196,6 +199,7 @@ export const BookerWebWrapper = (props: BookerWebWrapperAtomProps) => {
isRedirect={isRedirect}
fromUserNameRedirected={fromUserNameRedirected}
rescheduleUid={rescheduleUid}
rescheduledBy={rescheduledBy}
bookingUid={bookingUid}
hasSession={hasSession}
extraOptions={routerQuery}
@@ -44,6 +44,7 @@ export const useHandleBookEvent = ({
const duration = useBookerStore((state) => state.selectedDuration);
const { timezone } = useTimePreferences();
const rescheduleUid = useBookerStore((state) => state.rescheduleUid);
const rescheduledBy = useBookerStore((state) => state.rescheduledBy);
const { t, i18n } = useLocale();
const username = useBookerStore((state) => state.username);
const recurringEventCount = useBookerStore((state) => state.recurringEventCount);
@@ -82,6 +83,7 @@ export const useHandleBookEvent = ({
timeZone: timezone,
language: i18n.language,
rescheduleUid: rescheduleUid || undefined,
rescheduledBy: rescheduledBy || undefined,
bookingUid: (bookingData && bookingData.uid) || seatedEventData?.bookingUid || undefined,
username: username || "",
metadata: metadata,