refactor: map responsible area to string array

This commit is contained in:
Methapon Metanipat 2024-11-05 09:46:52 +07:00
parent 8c02f31d16
commit 670fa1bfac

View file

@ -294,6 +294,7 @@ export class UserController extends Controller {
prisma.user.findMany({ prisma.user.findMany({
orderBy: [{ statusOrder: "asc" }, { createdAt: "asc" }], orderBy: [{ statusOrder: "asc" }, { createdAt: "asc" }],
include: { include: {
responsibleArea: true,
province: true, province: true,
district: true, district: true,
subDistrict: true, subDistrict: true,
@ -311,6 +312,7 @@ export class UserController extends Controller {
return { return {
result: result.map((v) => ({ result: result.map((v) => ({
...v, ...v,
responsibleArea: v.responsibleArea.map((v) => v.area),
branch: includeBranch ? v.branch.map((a) => a.branch) : undefined, branch: includeBranch ? v.branch.map((a) => a.branch) : undefined,
})), })),
page, page,