feat: update contact to be nullable when request
This commit is contained in:
parent
030aa687e1
commit
b814537083
1 changed files with 10 additions and 9 deletions
|
|
@ -36,7 +36,7 @@ type BranchCreate = {
|
|||
zipCode: string;
|
||||
email: string;
|
||||
contactName?: string | null;
|
||||
contact: string | string[];
|
||||
contact?: string | string[] | null;
|
||||
telephoneNo: string;
|
||||
lineId?: string | null;
|
||||
longitude: string;
|
||||
|
|
@ -59,7 +59,7 @@ type BranchUpdate = {
|
|||
email?: string;
|
||||
telephoneNo: string;
|
||||
contactName?: string;
|
||||
contact?: string | string[];
|
||||
contact?: string | string[] | null;
|
||||
lineId?: string;
|
||||
longitude?: string;
|
||||
latitude?: string;
|
||||
|
|
@ -382,14 +382,15 @@ export class BranchController extends Controller {
|
|||
where: { id: branchId },
|
||||
});
|
||||
|
||||
if (record && contact) {
|
||||
if (record && contact !== undefined) {
|
||||
await prisma.branchContact.deleteMany({ where: { branchId } });
|
||||
await prisma.branchContact.createMany({
|
||||
data:
|
||||
typeof contact === "string"
|
||||
? [{ telephoneNo: contact, branchId }]
|
||||
: contact.map((v) => ({ telephoneNo: v, branchId })),
|
||||
});
|
||||
contact &&
|
||||
(await prisma.branchContact.createMany({
|
||||
data:
|
||||
typeof contact === "string"
|
||||
? [{ telephoneNo: contact, branchId }]
|
||||
: contact.map((v) => ({ telephoneNo: v, branchId })),
|
||||
}));
|
||||
}
|
||||
|
||||
return Object.assign(record, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue