@@ -6,6 +6,7 @@ import { Loader } from "components/Loader/Loader";
6
6
import { Margins } from "components/Margins/Margins" ;
7
7
import { TabLink , Tabs , TabsList } from "components/Tabs/Tabs" ;
8
8
import { useAuthenticated } from "contexts/auth/RequireAuth" ;
9
+ import { useDashboard } from "modules/dashboard/useDashboard" ;
9
10
import { workspacePermissionChecks } from "modules/permissions/workspaces" ;
10
11
import {
11
12
type FC ,
@@ -77,15 +78,18 @@ export const TemplateLayout: FC<PropsWithChildren> = ({
77
78
const { user :me } = useAuthenticated ( ) ;
78
79
const { organization :organizationName = "default" , template :templateName } =
79
80
useParams ( ) as { organization ?:string ; template :string } ;
81
+ const { organizations} = useDashboard ( ) ;
82
+ const organization = organizations . find ( ( o ) => o . name === organizationName ) ;
80
83
const { data, error, isLoading} = useQuery ( {
81
84
queryKey :[ "template" , templateName ] ,
82
85
queryFn :( ) => fetchTemplate ( organizationName , templateName ) ,
83
86
} ) ;
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 ) ,
87
90
} ) ,
88
- ) ;
91
+ enabled :organization !== undefined ,
92
+ } ) ;
89
93
90
94
const location = useLocation ( ) ;
91
95
const paths = location . pathname . split ( "/" ) ;