fix: update contact endpoint
This commit is contained in:
parent
63293b671b
commit
f9eb48d741
1 changed files with 11 additions and 1 deletions
|
|
@ -351,7 +351,7 @@ export class BranchController extends Controller {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { provinceId, districtId, subDistrictId, headOfficeId, ...rest } = body;
|
const { provinceId, districtId, subDistrictId, headOfficeId, telephoneNo, ...rest } = body;
|
||||||
|
|
||||||
if (!(await prisma.branch.findUnique({ where: { id: branchId } }))) {
|
if (!(await prisma.branch.findUnique({ where: { id: branchId } }))) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "Branch cannot be found.", "data_not_found");
|
throw new HttpError(HttpStatus.NOT_FOUND, "Branch cannot be found.", "data_not_found");
|
||||||
|
|
@ -383,6 +383,16 @@ export class BranchController extends Controller {
|
||||||
where: { id: branchId },
|
where: { id: branchId },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (record && telephoneNo) {
|
||||||
|
await prisma.branchContact.deleteMany({ where: { branchId } });
|
||||||
|
await prisma.branchContact.createMany({
|
||||||
|
data:
|
||||||
|
typeof telephoneNo === "string"
|
||||||
|
? [{ telephoneNo, branchId }]
|
||||||
|
: telephoneNo.map((v) => ({ telephoneNo: v, branchId })),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return Object.assign(record, {
|
return Object.assign(record, {
|
||||||
qrCodeImageUrl: await minio.presignedGetObject(
|
qrCodeImageUrl: await minio.presignedGetObject(
|
||||||
MINIO_BUCKET,
|
MINIO_BUCKET,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue