1
1
import { createOrganization } from "api/queries/organizations" ;
2
2
import { displaySuccess } from "components/GlobalSnackbar/utils" ;
3
+ import { useAuthenticated } from "contexts/auth/RequireAuth" ;
4
+ import { RequirePermission } from "contexts/auth/RequirePermission" ;
3
5
import { useFeatureVisibility } from "modules/dashboard/useFeatureVisibility" ;
4
6
import type { FC } from "react" ;
5
7
import { useMutation , useQueryClient } from "react-query" ;
@@ -9,6 +11,7 @@ import { CreateOrganizationPageView } from "./CreateOrganizationPageView";
9
11
const CreateOrganizationPage : FC = ( ) => {
10
12
const navigate = useNavigate ( ) ;
11
13
const feats = useFeatureVisibility ( ) ;
14
+ const { permissions } = useAuthenticated ( ) ;
12
15
13
16
const queryClient = useQueryClient ( ) ;
14
17
const createOrganizationMutation = useMutation (
@@ -19,15 +22,17 @@ const CreateOrganizationPage: FC = () => {
19
22
20
23
return (
21
24
< main className = "py-7" >
22
- < CreateOrganizationPageView
23
- error = { error }
24
- isEntitled = { feats . multiple_organizations }
25
- onSubmit = { async ( values ) => {
26
- await createOrganizationMutation . mutateAsync ( values ) ;
27
- displaySuccess ( "Organization created." ) ;
28
- navigate ( `/organizations/${ values . name } ` ) ;
29
- } }
30
- />
25
+ < RequirePermission isFeatureVisible = { permissions . createOrganization } >
26
+ < CreateOrganizationPageView
27
+ error = { error }
28
+ isEntitled = { feats . multiple_organizations }
29
+ onSubmit = { async ( values ) => {
30
+ await createOrganizationMutation . mutateAsync ( values ) ;
31
+ displaySuccess ( "Organization created." ) ;
32
+ navigate ( `/organizations/${ values . name } ` ) ;
33
+ } }
34
+ />
35
+ </ RequirePermission >
31
36
</ main >
32
37
) ;
33
38
} ;
0 commit comments