@@ -10,7 +10,7 @@ import ProfileModificationForm, {
10
10
PROFILE_NAME ,
11
11
USER_QUOTAS ,
12
12
} from './profile-modification-form' ;
13
- import yup from 'utils/yup-config' ;
13
+ import yup from '../../../ utils/yup-config' ;
14
14
import { yupResolver } from '@hookform/resolvers/yup' ;
15
15
import { useForm } from 'react-hook-form' ;
16
16
import {
@@ -20,18 +20,17 @@ import {
20
20
useMemo ,
21
21
useState ,
22
22
} from 'react' ;
23
- import { useSnackMessage } from '@gridsuite/commons-ui' ;
24
- import { getProfile , modifyProfile , UserProfile } from 'services/user-admin' ;
25
- import CustomMuiDialog from './custom-mui-dialog' ;
23
+ import { CustomMuiDialog , useSnackMessage } from '@gridsuite/commons-ui' ;
24
+ import { UserAdminSrv , UserProfile } from '../../../services' ;
26
25
import { UUID } from 'crypto' ;
27
26
28
- // TODO remove FetchStatus when available in commons-ui (available soon)
29
- export const FetchStatus = {
30
- IDLE : 'IDLE' ,
31
- FETCHING : 'FETCHING' ,
32
- FETCH_SUCCESS : 'FETCH_SUCCESS' ,
33
- FETCH_ERROR : 'FETCH_ERROR' ,
34
- } ;
27
+ // TODO remove FetchStatus when exported in commons-ui (available soon)
28
+ export enum FetchStatus {
29
+ IDLE = 'IDLE' ,
30
+ FETCHING = 'FETCHING' ,
31
+ FETCH_SUCCESS = 'FETCH_SUCCESS' ,
32
+ FETCH_ERROR = 'FETCH_ERROR' ,
33
+ }
35
34
36
35
export interface ProfileModificationDialogProps {
37
36
profileId : UUID | undefined ;
@@ -44,7 +43,9 @@ const ProfileModificationDialog: FunctionComponent<
44
43
ProfileModificationDialogProps
45
44
> = ( { profileId, open, onClose, onUpdate } ) => {
46
45
const { snackError } = useSnackMessage ( ) ;
47
- const [ dataFetchStatus , setDataFetchStatus ] = useState ( FetchStatus . IDLE ) ;
46
+ const [ dataFetchStatus , setDataFetchStatus ] = useState < FetchStatus > (
47
+ FetchStatus . IDLE
48
+ ) ;
48
49
49
50
const formSchema = yup
50
51
. object ( )
@@ -57,6 +58,7 @@ const ProfileModificationDialog: FunctionComponent<
57
58
. nullable ( ) ,
58
59
} )
59
60
. required ( ) ;
61
+ console . log ( 'formSchema =' , formSchema ) ;
60
62
61
63
const formMethods = useForm ( {
62
64
resolver : yupResolver ( formSchema ) ,
@@ -73,7 +75,8 @@ const ProfileModificationDialog: FunctionComponent<
73
75
loadFlowParameterId : profileFormData [ LF_PARAM_ID ] ,
74
76
maxAllowedCases : profileFormData [ USER_QUOTAS ] ,
75
77
} ;
76
- modifyProfile ( profileData )
78
+ console . log ( 'modify' , profileData ) ;
79
+ UserAdminSrv . modifyProfile ( profileData )
77
80
. catch ( ( error ) => {
78
81
snackError ( {
79
82
messageTxt : error . message ,
@@ -96,9 +99,10 @@ const ProfileModificationDialog: FunctionComponent<
96
99
useEffect ( ( ) => {
97
100
if ( profileId && open ) {
98
101
setDataFetchStatus ( FetchStatus . FETCHING ) ;
99
- getProfile ( profileId )
102
+ UserAdminSrv . getProfile ( profileId )
100
103
. then ( ( response ) => {
101
104
setDataFetchStatus ( FetchStatus . FETCH_SUCCESS ) ;
105
+ console . log ( 'reset' , response ) ;
102
106
reset ( {
103
107
[ PROFILE_NAME ] : response . name ,
104
108
[ LF_PARAM_ID ] : response . loadFlowParameterId
0 commit comments