chore: [app dir bootstrapping 4] check nullability of navigation hook return values (#12005)

This commit is contained in:
Greg Pabian authored and GitHub committed 2023-10-20 16:47:05 -07:00
1 parent eac45c5e23
commit 39cfe18ffe
28 files changed
+114 -86

No files matched your search

+5 -4
View File
@@ -520,18 +520,19 @@ const EmbedTypeCodeAndPreviewDialogContent = ({
(state) => [state.month, state.selectedDatesAndTimes],
shallow
);
const eventId = searchParams.get("eventId");
const eventId = searchParams?.get("eventId");
const parsedEventId = parseInt(eventId ?? "", 10);
const calLink = decodeURIComponent(embedUrl);
const { data: eventTypeData } = trpc.viewer.eventTypes.get.useQuery(
{ id: parseInt(eventId as string) },
{ enabled: !!eventId && embedType === "email", refetchOnWindowFocus: false }
{ id: parsedEventId },
{ enabled: !Number.isNaN(parsedEventId) && embedType === "email", refetchOnWindowFocus: false }
);
const s = (href: string) => {
const _searchParams = new URLSearchParams(searchParams);
const [a, b] = href.split("=");
_searchParams.set(a, b);
return `${pathname?.split("?")[0]}?${_searchParams.toString()}`;
return `${pathname?.split("?")[0] ?? ""}?${_searchParams.toString()}`;
};
const parsedTabs = tabs.map((t) => ({ ...t, href: s(t.href) }));
const embedCodeRefs: Record<(typeof tabs)[0]["name"], RefObject<HTMLTextAreaElement>> = {};