refactor: change verify input as frontend cannot detect type

This commit is contained in:
Methapon2001 2025-02-21 10:06:00 +07:00
parent d2d4036bcd
commit 2da138939c

View file

@ -7,13 +7,15 @@ import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status";
type SendEmail = {
identityNumber: string;
email: string;
} & ({ legalPersonNo: string } | { citizenId: string });
};
type VerificationPayload = {
identityNumber: string;
email: string;
otp: string;
} & ({ legalPersonNo: string } | { citizenId: string });
};
let emailTransport: ReturnType<(typeof nodemailer)["createTransport"]>;
@ -61,19 +63,20 @@ export class verificationController extends Controller {
const dataCustomerBranch = await prisma.customerBranch.findFirst({
where: {
email: body.email,
...("citizenId" in body
? {
citizenId: body.citizenId,
customer: {
customerType: "PERS",
},
}
: {
legalPersonNo: body.legalPersonNo,
customer: {
customerType: "CORP",
},
}),
OR: [
{
citizenId: body.identityNumber,
customer: {
customerType: "PERS",
},
},
{
legalPersonNo: body.identityNumber,
customer: {
customerType: "CORP",
},
},
],
},
});
@ -105,19 +108,20 @@ export class verificationController extends Controller {
const customerBranch = await prisma.customerBranch.findFirst({
where: {
email: body.email,
...("citizenId" in body
? {
citizenId: body.citizenId,
customer: {
customerType: "PERS",
},
}
: {
legalPersonNo: body.legalPersonNo,
customer: {
customerType: "CORP",
},
}),
OR: [
{
citizenId: body.identityNumber,
customer: {
customerType: "PERS",
},
},
{
legalPersonNo: body.identityNumber,
customer: {
customerType: "CORP",
},
},
],
},
});