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

+10 -7
View File
@@ -509,7 +509,7 @@ export type NavigationItemType = {
}: {
item: Pick<NavigationItemType, "href">;
isChild?: boolean;
pathname: string;
pathname: string | null;
}) => boolean;
};
@@ -527,7 +527,7 @@ const navigation: NavigationItemType[] = [
href: "/bookings/upcoming",
icon: Calendar,
badge: <UnconfirmedBookingBadge />,
isCurrent: ({ pathname }) => pathname?.startsWith("/bookings"),
isCurrent: ({ pathname }) => pathname?.startsWith("/bookings") ?? false,
},
{
name: "availability",
@@ -547,7 +547,7 @@ const navigation: NavigationItemType[] = [
icon: Grid,
isCurrent: ({ pathname: path, item }) => {
// During Server rendering path is /v2/apps but on client it becomes /apps(weird..)
return path?.startsWith(item.href) && !path?.includes("routing-forms/");
return (path?.startsWith(item.href) ?? false) && !(path?.includes("routing-forms/") ?? false);
},
child: [
{
@@ -556,7 +556,9 @@ const navigation: NavigationItemType[] = [
isCurrent: ({ pathname: path, item }) => {
// During Server rendering path is /v2/apps but on client it becomes /apps(weird..)
return (
path?.startsWith(item.href) && !path?.includes("routing-forms/") && !path?.includes("/installed")
(path?.startsWith(item.href) ?? false) &&
!(path?.includes("routing-forms/") ?? false) &&
!(path?.includes("/installed") ?? false)
);
},
},
@@ -564,7 +566,8 @@ const navigation: NavigationItemType[] = [
name: "installed_apps",
href: "/apps/installed/calendar",
isCurrent: ({ pathname: path }) =>
path?.startsWith("/apps/installed/") || path?.startsWith("/v2/apps/installed/"),
(path?.startsWith("/apps/installed/") ?? false) ||
(path?.startsWith("/v2/apps/installed/") ?? false),
},
],
},
@@ -577,7 +580,7 @@ const navigation: NavigationItemType[] = [
name: "Routing Forms",
href: "/apps/routing-forms/forms",
icon: FileText,
isCurrent: ({ pathname }) => pathname?.startsWith("/apps/routing-forms/"),
isCurrent: ({ pathname }) => pathname?.startsWith("/apps/routing-forms/") ?? false,
},
{
name: "workflows",
@@ -631,7 +634,7 @@ function useShouldDisplayNavigationItem(item: NavigationItemType) {
}
const defaultIsCurrent: NavigationItemType["isCurrent"] = ({ isChild, item, pathname }) => {
return isChild ? item.href === pathname : item.href ? pathname?.startsWith(item.href) : false;
return isChild ? item.href === pathname : item.href ? pathname?.startsWith(item.href) ?? false : false;
};
const NavigationItem: React.FC<{