feat: user now responsible for multiple area

This commit is contained in:
Methapon Metanipat 2024-11-05 09:33:45 +07:00
parent 1a255b6046
commit cd58a4bc36
2 changed files with 21 additions and 3 deletions

View file

@ -97,7 +97,7 @@ type UserCreate = {
sourceNationality?: string | null;
importNationality?: string | null;
trainingPlace?: string | null;
responsibleArea?: string | null;
responsibleArea?: string[] | null;
birthDate?: Date | null;
address: string;
@ -153,7 +153,7 @@ type UserUpdate = {
sourceNationality?: string | null;
importNationality?: string | null;
trainingPlace?: string | null;
responsibleArea?: string | null;
responsibleArea?: string[];
birthDate?: Date | null;
address?: string;
@ -432,6 +432,11 @@ export class UserController extends Controller {
data: {
id: userId,
...rest,
responsibleArea: rest.responsibleArea
? {
create: rest.responsibleArea.map((v) => ({ area: v })),
}
: undefined,
statusOrder: +(rest.status === "INACTIVE"),
username,
userRole: role.name,
@ -591,6 +596,12 @@ export class UserController extends Controller {
},
data: {
...rest,
responsibleArea: rest.responsibleArea
? {
deleteMany: {},
create: rest.responsibleArea.map((v) => ({ area: v })),
}
: undefined,
statusOrder: +(rest.status === "INACTIVE"),
userRole,
province: connectOrDisconnect(provinceId),