feat: enforce roles requirement in user management validation and UI
This commit is contained in:
parent
b059d5a260
commit
044dffefa8
@ -37,7 +37,7 @@ public function rules(): array
|
||||
'birth_place' => ['required', 'string', 'max:100'],
|
||||
'birth_date' => ['required', 'date'],
|
||||
'base_salary' => ['required', 'integer', 'min:0'],
|
||||
'roles' => ['nullable', 'array'],
|
||||
'roles' => ['required', 'array'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -384,7 +384,9 @@ export default function UserCreate({ roles }: { roles: any[] }) {
|
||||
</Field>
|
||||
|
||||
<Field>
|
||||
<Label htmlFor="roles">Peran</Label>
|
||||
<Label htmlFor="roles" required>
|
||||
Peran
|
||||
</Label>
|
||||
<Combobox
|
||||
multiple
|
||||
autoHighlight
|
||||
|
||||
@ -237,7 +237,9 @@ export default function UserEdit({ user, roles }: { user: any, roles: any[] }) {
|
||||
</Field>
|
||||
|
||||
<Field>
|
||||
<Label htmlFor="roles">Peran</Label>
|
||||
<Label htmlFor="roles" required>
|
||||
Peran
|
||||
</Label>
|
||||
<Combobox
|
||||
multiple
|
||||
autoHighlight
|
||||
|
||||
@ -122,7 +122,7 @@
|
||||
it('validates user creation', function () {
|
||||
postJson(route('user.store'), [])
|
||||
->assertStatus(422)
|
||||
->assertJsonValidationErrors(['username', 'email', 'nik', 'full_name', 'phone_number', 'address', 'birth_place', 'birth_date', 'base_salary']);
|
||||
->assertJsonValidationErrors(['username', 'email', 'nik', 'full_name', 'phone_number', 'address', 'birth_place', 'birth_date', 'base_salary', 'roles']);
|
||||
});
|
||||
|
||||
it('can access user edit page', function () {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user