Fixed role management while changing own role and removed No access from dashboard dropdown role

This commit is contained in:
Luka Radenovic 2022-06-15 14:50:35 +02:00
parent bca39f1091
commit 9cfb16a7e7

View file

@ -122,42 +122,41 @@ export const UserModal = ({ open, onClose, userId, setUserId }: UserModalProps)
<div className="sm:col-span-3"> <div className="sm:col-span-3">
<Input control={control} name="email" label="Email" type="email" onKeyPress={handleKeyPress} /> <Input control={control} name="email" label="Email" type="email" onKeyPress={handleKeyPress} />
</div> </div>
<div className="sm:col-span-3">
{fields
.filter((field) => field.name === 'dashboard')
.map((item, index) => (
<Select
key={item.name}
control={control}
name={`app_roles.${index}.role`}
label="Role"
options={[
{ value: UserRole.NoAccess, name: 'No access' },
{ value: UserRole.User, name: 'User' },
{ value: UserRole.Admin, name: 'Admin' },
]}
/>
))}
</div>
{isAdmin && ( {isAdmin && (
<div className="sm:col-span-3 opacity-40 cursor-default pointer-events-none select-none"> <>
<label htmlFor="status" className="block text-sm font-medium text-gray-700"> <div className="sm:col-span-3">
Status {fields
</label> .filter((field) => field.name === 'dashboard')
<div className="mt-1"> .map((item, index) => (
<select <Select
id="status" key={item.name}
name="status" control={control}
className="shadow-sm focus:ring-primary-500 focus:border-primary-500 block w-full sm:text-sm border-gray-300 rounded-md" name={`app_roles.${index}.role`}
> label="Role"
<option>Active</option> options={[
<option>Inactive</option> { value: UserRole.User, name: 'User' },
<option>Banned</option> { value: UserRole.Admin, name: 'Admin' },
</select> ]}
/>
))}
</div> </div>
</div> <div className="sm:col-span-3 opacity-40 cursor-default pointer-events-none select-none">
<label htmlFor="status" className="block text-sm font-medium text-gray-700">
Status
</label>
<div className="mt-1">
<select
id="status"
name="status"
className="shadow-sm focus:ring-primary-500 focus:border-primary-500 block w-full sm:text-sm border-gray-300 rounded-md"
>
<option>Active</option>
<option>Inactive</option>
<option>Banned</option>
</select>
</div>
</div>
</>
)} )}
</div> </div>
</div> </div>