diff --git a/src/identity-and-account/employees/services/employees-update.service.ts b/src/identity-and-account/employees/services/employees-update.service.ts index 032c81f..2bb57be 100644 --- a/src/identity-and-account/employees/services/employees-update.service.ts +++ b/src/identity-and-account/employees/services/employees-update.service.ts @@ -31,16 +31,26 @@ export class EmployeesUpdateService { email: dto.email, phone_number: dto.phone_number, residence: dto.residence, - user_module_access: { - update: { - dashboard: normalized_access.dashboard, - employee_list: normalized_access.employee_list, - employee_management: normalized_access.employee_management, - personal_profile: normalized_access.personal_profile, - timesheets: normalized_access.timesheets, - timesheets_approval: normalized_access.timesheets_approval, - }, - }, + }, + }); + await tx.userModuleAccess.upsert({ + where: { user_id: user_id.data }, + update: { + dashboard: normalized_access.dashboard, + employee_list: normalized_access.employee_list, + employee_management: normalized_access.employee_management, + personal_profile: normalized_access.personal_profile, + timesheets: normalized_access.timesheets, + timesheets_approval: normalized_access.timesheets_approval, + }, + create: { + user_id: user_id.data, + dashboard: normalized_access.dashboard, + employee_list: normalized_access.employee_list, + employee_management: normalized_access.employee_management, + personal_profile: normalized_access.personal_profile, + timesheets: normalized_access.timesheets, + timesheets_approval: normalized_access.timesheets_approval, }, }); return tx.employees.update({