fix: Important Booking Page fixes (#10130)
This commit is contained in:
1 parent
2918a34e1a
commit
9444f925e5
17 files changed
+113
-123
No files matched your search
@@ -37,6 +37,7 @@ const BookerComponent = ({
|
||||
bookingData,
|
||||
hideBranding = false,
|
||||
isTeamEvent,
|
||||
org,
|
||||
}: BookerProps) => {
|
||||
const isMobile = useMediaQuery("(max-width: 768px)");
|
||||
const isTablet = useMediaQuery("(max-width: 1024px)");
|
||||
@@ -96,6 +97,7 @@ const BookerComponent = ({
|
||||
bookingData,
|
||||
layout: defaultLayout,
|
||||
isTeamEvent,
|
||||
org,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -25,6 +25,7 @@ type StoreInitializeType = {
|
||||
bookingData?: GetBookingType | null | undefined;
|
||||
rescheduleUid?: string | null;
|
||||
seatReferenceUid?: string;
|
||||
org?: string | null;
|
||||
};
|
||||
|
||||
type SeatedEventData = {
|
||||
@@ -105,6 +106,7 @@ export type BookerStore = {
|
||||
* both the slug and the event slug.
|
||||
*/
|
||||
isTeamEvent: boolean;
|
||||
org?: string | null;
|
||||
seatedEventData: SeatedEventData;
|
||||
setSeatedEventData: (seatedEventData: SeatedEventData) => void;
|
||||
};
|
||||
@@ -183,6 +185,7 @@ export const useBookerStore = create<BookerStore>((set, get) => ({
|
||||
bookingData = null,
|
||||
layout,
|
||||
isTeamEvent,
|
||||
org,
|
||||
}: StoreInitializeType) => {
|
||||
const selectedDateInStore = get().selectedDate;
|
||||
|
||||
@@ -201,6 +204,7 @@ export const useBookerStore = create<BookerStore>((set, get) => ({
|
||||
username,
|
||||
eventSlug,
|
||||
eventId,
|
||||
org,
|
||||
rescheduleUid,
|
||||
bookingUid,
|
||||
bookingData,
|
||||
@@ -250,6 +254,7 @@ export const useInitializeBookerStore = ({
|
||||
bookingData = null,
|
||||
layout,
|
||||
isTeamEvent,
|
||||
org,
|
||||
}: StoreInitializeType) => {
|
||||
const initializeStore = useBookerStore((state) => state.initialize);
|
||||
useEffect(() => {
|
||||
@@ -262,6 +267,18 @@ export const useInitializeBookerStore = ({
|
||||
bookingData,
|
||||
layout,
|
||||
isTeamEvent,
|
||||
org,
|
||||
});
|
||||
}, [initializeStore, username, eventSlug, month, eventId, rescheduleUid, bookingData, layout, isTeamEvent]);
|
||||
}, [
|
||||
initializeStore,
|
||||
org,
|
||||
username,
|
||||
eventSlug,
|
||||
month,
|
||||
eventId,
|
||||
rescheduleUid,
|
||||
bookingData,
|
||||
layout,
|
||||
isTeamEvent,
|
||||
]);
|
||||
};
|
||||
@@ -5,6 +5,8 @@ import type { GetBookingType } from "../lib/get-booking";
|
||||
export interface BookerProps {
|
||||
eventSlug: string;
|
||||
username: string;
|
||||
// Make it optional later, once we figure out where we can possibly need to set org
|
||||
org: string | null;
|
||||
|
||||
/**
|
||||
* If month is NOT set as a prop on the component, we expect a query parameter
|
||||
|
||||
@@ -17,9 +17,10 @@ import { useBookerStore } from "../store";
|
||||
export const useEvent = () => {
|
||||
const [username, eventSlug] = useBookerStore((state) => [state.username, state.eventSlug], shallow);
|
||||
const isTeamEvent = useBookerStore((state) => state.isTeamEvent);
|
||||
const org = useBookerStore((state) => state.org);
|
||||
|
||||
return trpc.viewer.public.event.useQuery(
|
||||
{ username: username ?? "", eventSlug: eventSlug ?? "", isTeamEvent },
|
||||
{ username: username ?? "", eventSlug: eventSlug ?? "", isTeamEvent, org: org ?? null },
|
||||
{ refetchOnWindowFocus: false, enabled: Boolean(username) && Boolean(eventSlug) }
|
||||
);
|
||||
};
|
||||
|
||||
@@ -8,13 +8,14 @@ interface BookerSeoProps {
|
||||
rescheduleUid: string | undefined;
|
||||
hideBranding?: boolean;
|
||||
isTeamEvent?: boolean;
|
||||
org: string | null;
|
||||
}
|
||||
|
||||
export const BookerSeo = (props: BookerSeoProps) => {
|
||||
const { eventSlug, username, rescheduleUid, hideBranding, isTeamEvent } = props;
|
||||
const { eventSlug, username, rescheduleUid, hideBranding, isTeamEvent, org } = props;
|
||||
const { t } = useLocale();
|
||||
const { data: event } = trpc.viewer.public.event.useQuery(
|
||||
{ username, eventSlug, isTeamEvent },
|
||||
{ username, eventSlug, isTeamEvent, org },
|
||||
{ refetchOnWindowFocus: false }
|
||||
);
|
||||
|
||||
|
||||
@@ -81,10 +81,15 @@ export const getPublicEvent = async (
|
||||
username: string,
|
||||
eventSlug: string,
|
||||
isTeamEvent: boolean | undefined,
|
||||
org: string | null,
|
||||
prisma: PrismaClient
|
||||
) => {
|
||||
const usernameList = getUsernameList(username);
|
||||
|
||||
const orgQuery = org
|
||||
? {
|
||||
slug: org ?? null,
|
||||
}
|
||||
: null;
|
||||
// In case of dynamic group event, we fetch user's data and use the default event.
|
||||
if (usernameList.length > 1) {
|
||||
const users = await prisma.user.findMany({
|
||||
@@ -92,6 +97,7 @@ export const getPublicEvent = async (
|
||||
username: {
|
||||
in: usernameList,
|
||||
},
|
||||
organization: orgQuery,
|
||||
},
|
||||
select: {
|
||||
username: true,
|
||||
@@ -151,12 +157,14 @@ export const getPublicEvent = async (
|
||||
? {
|
||||
team: {
|
||||
slug: username,
|
||||
parent: orgQuery,
|
||||
},
|
||||
}
|
||||
: {
|
||||
users: {
|
||||
some: {
|
||||
username,
|
||||
organization: orgQuery,
|
||||
},
|
||||
},
|
||||
team: null,
|
||||
@@ -192,6 +200,7 @@ export const getPublicEvent = async (
|
||||
// Sets user data on profile object for easier access
|
||||
profile: getProfileFromEvent(event),
|
||||
users,
|
||||
orgDomain: org,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user