@@ -6,6 +6,7 @@ import { Loader } from "components/Loader/Loader";
66import { Margins } from "components/Margins/Margins" ;
77import { TabLink , Tabs , TabsList } from "components/Tabs/Tabs" ;
88import { useAuthenticated } from "contexts/auth/RequireAuth" ;
9+ import { useDashboard } from "modules/dashboard/useDashboard" ;
910import { workspacePermissionChecks } from "modules/permissions/workspaces" ;
1011import {
1112type FC ,
@@ -77,15 +78,18 @@ export const TemplateLayout: FC<PropsWithChildren> = ({
7778const { user :me } = useAuthenticated ( ) ;
7879const { organization :organizationName = "default" , template :templateName } =
7980useParams ( ) as { organization ?:string ; template :string } ;
81+ const { organizations} = useDashboard ( ) ;
82+ const organization = organizations . find ( ( o ) => o . name === organizationName ) ;
8083const { data, error, isLoading} = useQuery ( {
8184queryKey :[ "template" , templateName ] ,
8285queryFn :( ) => 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
9094const location = useLocation ( ) ;
9195const paths = location . pathname . split ( "/" ) ;