From e9d097c89d9b18b290bab4e89bf5520bbf7be4ea Mon Sep 17 00:00:00 2001 From: Maina Wycliffe Date: Fri, 15 Sep 2023 09:28:27 +0300 Subject: [PATCH 1/3] chore: add org switcher and user profile to skelton loader --- .../SkeletonLoader/FullPageSkeletonLoader.tsx | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/components/SkeletonLoader/FullPageSkeletonLoader.tsx b/src/components/SkeletonLoader/FullPageSkeletonLoader.tsx index aacfe7d75..b5aa45f77 100644 --- a/src/components/SkeletonLoader/FullPageSkeletonLoader.tsx +++ b/src/components/SkeletonLoader/FullPageSkeletonLoader.tsx @@ -1,7 +1,12 @@ +import { OrganizationSwitcher, UserButton } from "@clerk/nextjs"; +import useDetermineAuthSystem from "../Authentication/useDetermineAuthSystem"; + export default function FullPageSkeletonLoader() { + const authSystem = useDetermineAuthSystem(); + return ( -
-
+
+
@@ -12,11 +17,22 @@ export default function FullPageSkeletonLoader() {
-
-
-
+
+
+ {authSystem === "kratos" ? ( +
+ ) : ( +
+ + +
+ )}
-
+
From 2cdfc31ec2aad27a1543ab984b8977710aa6739e Mon Sep 17 00:00:00 2001 From: Maina Wycliffe Date: Fri, 15 Sep 2023 09:35:26 +0300 Subject: [PATCH 2/3] chore: add org switcher and profile to the error page This will allow user to change organization if need be --- .../Authentication/Clerk/ClerkAuthErrors.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/Authentication/Clerk/ClerkAuthErrors.tsx b/src/components/Authentication/Clerk/ClerkAuthErrors.tsx index b60cfd1a8..9323c2412 100644 --- a/src/components/Authentication/Clerk/ClerkAuthErrors.tsx +++ b/src/components/Authentication/Clerk/ClerkAuthErrors.tsx @@ -2,6 +2,7 @@ import Link from "next/link"; import { useRouter } from "next/router"; import { Head } from "../../Head/Head"; import ErrorPage from "../../Errors/ErrorPage"; +import { OrganizationSwitcher, UserButton } from "@clerk/nextjs"; export default function ClerkAuthErrors() { const { query } = useRouter(); @@ -11,8 +12,19 @@ export default function ClerkAuthErrors() { return ( <> -
-
+
+
+
+ + +
+
+
+
{code === "BAD_SESSION" ? ( Date: Fri, 15 Sep 2023 10:11:52 +0300 Subject: [PATCH 3/3] fix: improve how we handle nullability for permission service --- src/context/UserAccessContext/UserAccessContext.tsx | 2 +- src/services/permissions/permissionsService.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/context/UserAccessContext/UserAccessContext.tsx b/src/context/UserAccessContext/UserAccessContext.tsx index eb8a60382..1f08e97c3 100644 --- a/src/context/UserAccessContext/UserAccessContext.tsx +++ b/src/context/UserAccessContext/UserAccessContext.tsx @@ -83,7 +83,7 @@ export const UserAccessStateContextProvider = ({ const fetchUserRoleInfo = async (userId: string) => { const { data = [] } = await fetchPeopleRoles([userId]); - let roles = data!.find((item) => item.id === userId)?.roles || []; + let roles = (data ?? []).find((item) => item.id === userId)?.roles || []; if (!roles.length) { roles = [Roles.viewer]; } diff --git a/src/services/permissions/permissionsService.ts b/src/services/permissions/permissionsService.ts index bee0b6b6f..497f551b9 100644 --- a/src/services/permissions/permissionsService.ts +++ b/src/services/permissions/permissionsService.ts @@ -20,7 +20,7 @@ class PermissionService { const parentResource = featureToParentMap[featureName as keyof typeof featureToParentMap]; let isDisabled = Boolean( - properties.find((item) => item.name === name && item.value === "true") + properties?.find((item) => item.name === name && item.value === "true") ); if (isDisabled || !parentResource) { return isDisabled;