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();
|
const disptach = useDispatch();
|
||||||
disptach(changeMaster("Application Role"));
|
disptach(changeMaster("Application Role"));
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
@ -68,12 +70,17 @@ const ManageRole = ({ employeeId, onClosed }) => {
|
|||||||
}
|
}
|
||||||
}, [initialRoles, reset]);
|
}, [initialRoles, reset]);
|
||||||
|
|
||||||
const onSubmit = (formdata) => {
|
const onSubmit = ( formdata ) =>
|
||||||
|
{
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
const result = [];
|
const result = [];
|
||||||
for (const [roleId, isEnabled] of Object.entries(formdata.selectedRole)) {
|
for ( const [ roleId, isEnabled ] of Object.entries( formdata.selectedRole ) )
|
||||||
if (isEnabled) {
|
{
|
||||||
result.push({
|
if ( isEnabled )
|
||||||
|
{
|
||||||
|
const existingRole = employeeRoles?.find((role) => role.roleId === roleId);
|
||||||
|
result.push( {
|
||||||
|
id: existingRole?.id || null,
|
||||||
employeeId: employeeId,
|
employeeId: employeeId,
|
||||||
isEnabled: true,
|
isEnabled: true,
|
||||||
roleId: roleId,
|
roleId: roleId,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user