From 8dfd0748b1146c669d3c6b889416f1b46306d1d5 Mon Sep 17 00:00:00 2001 From: David Paul Graham Date: Sun, 4 Aug 2024 13:58:25 -0400 Subject: [PATCH] fix hook if search parameter is an org ID of org user is not authorized to use --- client/app/hooks/useOrg/useOrg.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/app/hooks/useOrg/useOrg.tsx b/client/app/hooks/useOrg/useOrg.tsx index 72d90e34..b8f6b0f9 100644 --- a/client/app/hooks/useOrg/useOrg.tsx +++ b/client/app/hooks/useOrg/useOrg.tsx @@ -26,8 +26,10 @@ export const useOrg = () => { // If an orgId is set, and we have the users orgs, check if the orgId is valid, remove otherwise if (orgIdSearchParam && orgs) { if (!orgs.find((org) => org.slug === orgSlug)) { - searchParams.delete('org'); + const defaultOrg = orgs[0].slug; + searchParams.set('org', defaultOrg); setSearchParams(searchParams); + setOrgSlugState(defaultOrg); } }