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_place' => ['required', 'string', 'max:100'],
|
||||||
'birth_date' => ['required', 'date'],
|
'birth_date' => ['required', 'date'],
|
||||||
'base_salary' => ['required', 'integer', 'min:0'],
|
'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>
|
||||||
|
|
||||||
<Field>
|
<Field>
|
||||||
<Label htmlFor="roles">Peran</Label>
|
<Label htmlFor="roles" required>
|
||||||
|
Peran
|
||||||
|
</Label>
|
||||||
<Combobox
|
<Combobox
|
||||||
multiple
|
multiple
|
||||||
autoHighlight
|
autoHighlight
|
||||||
|
|||||||
@ -237,7 +237,9 @@ export default function UserEdit({ user, roles }: { user: any, roles: any[] }) {
|
|||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field>
|
<Field>
|
||||||
<Label htmlFor="roles">Peran</Label>
|
<Label htmlFor="roles" required>
|
||||||
|
Peran
|
||||||
|
</Label>
|
||||||
<Combobox
|
<Combobox
|
||||||
multiple
|
multiple
|
||||||
autoHighlight
|
autoHighlight
|
||||||
|
|||||||
@ -122,7 +122,7 @@
|
|||||||
it('validates user creation', function () {
|
it('validates user creation', function () {
|
||||||
postJson(route('user.store'), [])
|
postJson(route('user.store'), [])
|
||||||
->assertStatus(422)
|
->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 () {
|
it('can access user edit page', function () {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user