@@ -11,6 +11,12 @@ import { Shield } from 'lucide-react';
1111const SCOPE_TYPES = [ 'Tenant' , 'Organization' , 'Department' , 'System' , 'Team' ] as const ;
1212const DELEGATED_ACTIONS = [ 'CreateUser' , 'BlockUser' , 'AssignProfile' , 'ResetPassword' , 'RevokeMfa' ] as const ;
1313
14+ const UNIMAR_USERS : Record < string , string > = {
15+ '5f4e3d01-1b0a-9f8e-7d6c-543210987654' : 'Gerente UNIMAR' ,
16+ '5f4e3d02-1b0a-9f8e-7d6c-543210987654' : 'Analista UNIMAR' ,
17+ '5f4e3d05-1b0a-9f8e-7d6c-543210987654' : 'Socio UNIMAR' ,
18+ } ;
19+
1420interface DelegationFormProps {
1521 isOpen : boolean ;
1622 onClose : ( ) => void ;
@@ -30,8 +36,9 @@ export const DelegationForm: React.FC<DelegationFormProps> = ({
3036 const t = useI18n ( ) ;
3137
3238 const [ tenantId ] = useState ( defaultTenantId ) ;
33- const [ delegatingAdminId , setDelegatingAdminId ] = useState ( defaultDelegatingAdminId ) ;
34- const [ delegatedAdminId , setDelegatedAdminId ] = useState ( '' ) ;
39+ const [ delegatingAdminId ] = useState ( defaultDelegatingAdminId ) ;
40+ // Default to first user in the list (excluding self if possible, but for mock any is fine)
41+ const [ delegatedAdminId , setDelegatedAdminId ] = useState ( '5f4e3d02-1b0a-9f8e-7d6c-543210987654' ) ;
3542 const [ scopeType , setScopeType ] = useState < ( typeof SCOPE_TYPES ) [ number ] > ( 'Tenant' ) ;
3643 const [ validFrom , setValidFrom ] = useState ( '' ) ;
3744 const [ validUntil , setValidUntil ] = useState ( '' ) ;
@@ -89,40 +96,33 @@ export const DelegationForm: React.FC<DelegationFormProps> = ({
8996 < M3FormDialog
9097 open = { isOpen }
9198 onClose = { onClose }
92- title = "Create Delegation"
99+ title = { t . createDelegation ?? 'Crear Delegación' }
93100 icon = { < Shield className = "w-5 h-5" /> }
94101 footer = {
95102 < >
96103 < M3Button variant = "text" onClick = { onClose } type = "button" >
97- { t . cancelBtn }
104+ { t . cancelBtn ?? 'Cancelar' }
98105 </ M3Button >
99106 < M3Button variant = "filled" onClick = { handleSubmit } loading = { createDelegationMutation . isPending } >
100- Create
107+ { t . createBtn ?? 'Crear' }
101108 </ M3Button >
102109 </ >
103110 }
104111 >
105- < form onSubmit = { handleSubmit } className = "space-y-0" >
106- < M3TextField
107- label = "Delegating Admin ID"
108- required
109- value = { delegatingAdminId }
110- onChange = { ( e ) => setDelegatingAdminId ( e . target . value ) }
111- placeholder = "UUID of the admin granting authority"
112- error = { errors . delegatingAdminId }
113- />
114-
115- < M3TextField
116- label = "Delegated Admin ID"
117- required
112+ < form onSubmit = { handleSubmit } className = "flex flex-col gap-5 pt-2" >
113+ < M3Select
114+ label = { t . delegatedAdminId ?? 'Delegar a (Usuario)' }
118115 value = { delegatedAdminId }
119116 onChange = { ( e ) => setDelegatedAdminId ( e . target . value ) }
120- placeholder = "UUID of the admin receiving authority"
121- error = { errors . delegatedAdminId }
122- />
117+ >
118+ < option value = "" disabled > Seleccione un usuario...</ option >
119+ { Object . entries ( UNIMAR_USERS ) . map ( ( [ id , name ] ) => (
120+ < option key = { id } value = { id } > { name } </ option >
121+ ) ) }
122+ </ M3Select >
123123
124124 < M3Select
125- label = "Scope Type"
125+ label = { t . scopeType ?? 'Alcance (Scope)' }
126126 value = { scopeType }
127127 onChange = { ( e ) => setScopeType ( e . target . value as typeof scopeType ) }
128128 >
@@ -133,15 +133,15 @@ export const DelegationForm: React.FC<DelegationFormProps> = ({
133133
134134 < div className = "grid grid-cols-2 gap-4" >
135135 < M3TextField
136- label = "Valid From"
136+ label = { t . validFrom ?? 'Válido desde' }
137137 required
138138 type = "datetime-local"
139139 value = { validFrom }
140140 onChange = { ( e ) => setValidFrom ( e . target . value ) }
141141 error = { errors . validFrom }
142142 />
143143 < M3TextField
144- label = "Valid Until"
144+ label = { t . validUntil ?? 'Válido hasta' }
145145 required
146146 type = "datetime-local"
147147 value = { validUntil }
@@ -150,39 +150,41 @@ export const DelegationForm: React.FC<DelegationFormProps> = ({
150150 />
151151 </ div >
152152
153- < div className = "mt-4" >
154- < p className = "text-xs font-medium text-m3-on-surface-variant mb-2" > Allowed Actions</ p >
153+ < div >
154+ < p className = "text-xs font-bold uppercase tracking-wider text-m3-secondary mb-3" >
155+ { t . allowedActions ?? 'Acciones Permitidas' }
156+ </ p >
155157 < div className = "flex flex-wrap gap-2" >
156158 { DELEGATED_ACTIONS . map ( ( action ) => (
157159 < button
158160 key = { action }
159161 type = "button"
160162 onClick = { ( ) => toggleAction ( action ) }
161- className = { `px-3 py-1 text-xs rounded-full border transition-colors ${
163+ className = { `px-3 py-1.5 text-xs rounded-full border transition-colors font-medium ${
162164 selectedActions . includes ( action )
163- ? 'bg-m3-primary text-m3-on- primary border-m3-primary'
164- : 'bg-transparent text-m3-secondary border-m3-outline'
165+ ? 'bg-m3-primary/10 text-m3-primary border-m3-primary/30 '
166+ : 'bg-transparent text-m3-secondary border-m3-outline/30 hover:bg-m3-surface-variant '
165167 } `}
166168 >
167169 { action }
168170 </ button >
169171 ) ) }
170172 </ div >
171173 { errors . allowedActions && (
172- < p className = "text-xs text-rose-600 mt-1 " > { errors . allowedActions } </ p >
174+ < p className = "text-xs text-rose-600 mt-2 " > { errors . allowedActions } </ p >
173175 ) }
174176 </ div >
175177
176- < div className = "flex items-center gap-2 mt-4 " >
178+ < div className = "flex items-center gap-3 mt-2 p-3 bg-m3-surface-container/30 rounded-xl border border-m3-outline/10 " >
177179 < input
178180 id = "requiresApproval"
179181 type = "checkbox"
180182 checked = { requiresApproval }
181183 onChange = { ( e ) => setRequiresApproval ( e . target . checked ) }
182- className = "w-4 h-4"
184+ className = "w-4 h-4 text-m3-primary border-gray-300 rounded focus:ring-m3-primary "
183185 />
184- < label htmlFor = "requiresApproval" className = "text-sm text-m3-on-surface" >
185- Requires Approval
186+ < label htmlFor = "requiresApproval" className = "text-sm font-medium text-m3-on-surface cursor-pointer select-none " >
187+ { t . requiresApproval ?? 'Requiere Aprobación' }
186188 </ label >
187189 </ div >
188190 </ form >
0 commit comments