added id in roles obj request
This commit is contained in:
parent
66703de72e
commit
b595fe6a0f
@ -20,7 +20,9 @@ const formSchema = z.object({
|
||||
),
|
||||
});
|
||||
|
||||
const ManageRole = ({ employeeId, onClosed }) => {
|
||||
const ManageRole = ( {employeeId, onClosed} ) =>
|
||||
{
|
||||
|
||||
const disptach = useDispatch();
|
||||
disptach(changeMaster("Application Role"));
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
@ -68,12 +70,17 @@ const ManageRole = ({ employeeId, onClosed }) => {
|
||||
}
|
||||
}, [initialRoles, reset]);
|
||||
|
||||
const onSubmit = (formdata) => {
|
||||
const onSubmit = ( formdata ) =>
|
||||
{
|
||||
setIsLoading(true);
|
||||
const result = [];
|
||||
for (const [roleId, isEnabled] of Object.entries(formdata.selectedRole)) {
|
||||
if (isEnabled) {
|
||||
result.push({
|
||||
for ( const [ roleId, isEnabled ] of Object.entries( formdata.selectedRole ) )
|
||||
{
|
||||
if ( isEnabled )
|
||||
{
|
||||
const existingRole = employeeRoles?.find((role) => role.roleId === roleId);
|
||||
result.push( {
|
||||
id: existingRole?.id || null,
|
||||
employeeId: employeeId,
|
||||
isEnabled: true,
|
||||
roleId: roleId,
|
||||
|
Loading…
x
Reference in New Issue
Block a user