Skip to content

Commit 0b13269

Browse files
committed
fix: get org id for permission check on template layout
1 parent 49951a6 commit 0b13269

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

site/src/pages/TemplatePage/TemplateLayout.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Loader } from "components/Loader/Loader";
66
import { Margins } from "components/Margins/Margins";
77
import { TabLink, Tabs, TabsList } from "components/Tabs/Tabs";
88
import { useAuthenticated } from "contexts/auth/RequireAuth";
9+
import { useDashboard } from "modules/dashboard/useDashboard";
910
import { workspacePermissionChecks } from "modules/permissions/workspaces";
1011
import {
1112
type FC,
@@ -77,15 +78,18 @@ export const TemplateLayout: FC<PropsWithChildren> = ({
7778
const { user: me } = useAuthenticated();
7879
const { organization: organizationName = "default", template: templateName } =
7980
useParams() as { organization?: string; template: string };
81+
const { organizations } = useDashboard();
82+
const organization = organizations.find((o) => o.name === organizationName);
8083
const { data, error, isLoading } = useQuery({
8184
queryKey: ["template", templateName],
8285
queryFn: () => fetchTemplate(organizationName, templateName),
8386
});
84-
const workspacePermissionsQuery = useQuery(
85-
checkAuthorization({
86-
checks: workspacePermissionChecks(organizationName, me.id),
87+
const workspacePermissionsQuery = useQuery({
88+
...checkAuthorization({
89+
checks: workspacePermissionChecks(organization?.id ?? "", me.id),
8790
}),
88-
);
91+
enabled: organization !== undefined,
92+
});
8993

9094
const location = useLocation();
9195
const paths = location.pathname.split("/");

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy