@@ -19,7 +19,7 @@ import {
1919
2020import { copyToClipboard } from 'libs' ;
2121
22- import { TRoleSelectOption } from './types' ;
22+ import { TActiveSelectOption , TRoleSelectOption } from './types' ;
2323
2424export interface Props {
2525 initialValues ?: IUserWithCreds ;
@@ -44,22 +44,37 @@ export const UserForm: React.FC<Props> = ({
4444 const isEditing = ! ! initialValues ;
4545
4646 const { handleSubmit, control } = useForm < IUser > ( {
47- defaultValues : initialValues ?? {
48- global_role : 'user' ,
49- } ,
47+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
48+ // @ts -ignore
49+ defaultValues : initialValues
50+ ? { ...initialValues , active : initialValues . active ? 'active' : 'inactive' }
51+ : {
52+ global_role : 'user' ,
53+ active : 'active' ,
54+ } ,
5055 } ) ;
5156
5257 const roleSelectOptions : TRoleSelectOption [ ] = [
5358 { label : t ( 'roles.admin' ) , value : 'admin' } ,
5459 { label : t ( 'roles.user' ) , value : 'user' } ,
5560 ] ;
5661
62+ const activeSelectOptions : TActiveSelectOption [ ] = [
63+ { label : t ( 'users.activated' ) , value : 'active' } ,
64+ { label : t ( 'users.deactivated' ) , value : 'inactive' } ,
65+ ] ;
66+
5767 const onCopyToken = ( ) => {
5868 copyToClipboard ( initialValues ?. creds . token ?? '' ) ;
5969 } ;
6070
6171 const onSubmit = ( data : IUser ) => {
62- onSubmitProp ( data ) ;
72+ onSubmitProp ( {
73+ ...data ,
74+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
75+ // @ts -ignore
76+ active : data . active === 'active' ,
77+ } ) ;
6378 } ;
6479
6580 const isDisabledEmailAndRoleField = ( ) => {
@@ -124,6 +139,15 @@ export const UserForm: React.FC<Props> = ({
124139 options = { roleSelectOptions }
125140 disabled = { isDisabledEmailAndRoleField ( ) }
126141 />
142+
143+ < FormSelect
144+ label = { t ( 'users.active' ) }
145+ description = { t ( 'users.active_description' ) }
146+ control = { control }
147+ name = "active"
148+ options = { activeSelectOptions }
149+ disabled = { isDisabledEmailAndRoleField ( ) }
150+ />
127151 </ ColumnLayout >
128152
129153 { initialValues && (
0 commit comments