fix: Broken team events if a user with the same name exists (#10724)
* fix: Broken team events if a user with the same name exists * Fix tests + fix usernameList optionality
This commit is contained in:
1 parent
4d5697f5a5
commit
ceb18167cf
5 files changed
+74
-39
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import { useSearchParams, usePathname } from "next/navigation";
|
||||
import { shallow } from "zustand/shallow";
|
||||
|
||||
import { useSchedule } from "@calcom/features/schedules";
|
||||
@@ -59,8 +59,10 @@ export const useScheduleForEvent = ({
|
||||
(state) => [state.username, state.eventSlug, state.month, state.selectedDuration],
|
||||
shallow
|
||||
);
|
||||
const serachParams = useSearchParams();
|
||||
const rescheduleUid = serachParams.get("rescheduleUid");
|
||||
const searchParams = useSearchParams();
|
||||
const rescheduleUid = searchParams.get("rescheduleUid");
|
||||
|
||||
const pathname = usePathname();
|
||||
|
||||
return useSchedule({
|
||||
username: usernameFromStore ?? username,
|
||||
@@ -71,5 +73,6 @@ export const useScheduleForEvent = ({
|
||||
rescheduleUid,
|
||||
month: monthFromStore ?? month,
|
||||
duration: durationFromStore ?? duration,
|
||||
isTeamEvent: pathname.indexOf("/team/") !== -1,
|
||||
});
|
||||
};
|
||||
@@ -11,6 +11,7 @@ type UseScheduleWithCacheArgs = {
|
||||
prefetchNextMonth?: boolean;
|
||||
duration?: number | null;
|
||||
rescheduleUid?: string | null;
|
||||
isTeamEvent?: boolean;
|
||||
};
|
||||
|
||||
export const useSchedule = ({
|
||||
@@ -22,6 +23,7 @@ export const useSchedule = ({
|
||||
prefetchNextMonth,
|
||||
duration,
|
||||
rescheduleUid,
|
||||
isTeamEvent,
|
||||
}: UseScheduleWithCacheArgs) => {
|
||||
const monthDayjs = month ? dayjs(month) : dayjs();
|
||||
const nextMonthDayjs = monthDayjs.add(1, "month");
|
||||
@@ -30,6 +32,7 @@ export const useSchedule = ({
|
||||
// no satisfy typscript.
|
||||
return trpc.viewer.public.slots.getSchedule.useQuery(
|
||||
{
|
||||
isTeamEvent,
|
||||
usernameList: getUsernameList(username ?? ""),
|
||||
// Prioritize slug over id, since slug is the first value we get available.
|
||||
// If we have a slug, we don't need to fetch the id.
|
||||
|
||||
Reference in new issue
Block a user