feat: adding custom field of type PHONE (#5623)
* feat: adding custom field of type PHONE Signed-off-by: Udit Takkar <[email protected]> * fix: null phone number bug and removed console log Signed-off-by: Udit Takkar <[email protected]> * fix: decrease iteration Signed-off-by: Udit Takkar <[email protected]> Signed-off-by: Udit Takkar <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: Omar López <[email protected]>
This commit is contained in:
6 files changed
+68
-8
No files matched your search
@@ -7,6 +7,7 @@ import {
|
||||
WebhookTriggerEvents,
|
||||
} from "@prisma/client";
|
||||
import async from "async";
|
||||
import { isValidPhoneNumber } from "libphonenumber-js";
|
||||
import { cloneDeep } from "lodash";
|
||||
import type { NextApiRequest } from "next";
|
||||
import short from "short-uuid";
|
||||
@@ -1095,6 +1096,16 @@ function handleCustomInputs(
|
||||
z.literal(true, {
|
||||
errorMap: () => ({ message: `Missing ${etcInput.type} customInput: '${etcInput.label}'` }),
|
||||
}).parse(input?.value);
|
||||
} else if (etcInput.type === "PHONE") {
|
||||
z.string({
|
||||
errorMap: () => ({
|
||||
message: `Missing ${etcInput.type} customInput: '${etcInput.label}'`,
|
||||
}),
|
||||
})
|
||||
.refine((val) => isValidPhoneNumber(val), {
|
||||
message: "Phone number is invalid",
|
||||
})
|
||||
.parse(input?.value);
|
||||
} else {
|
||||
// type: NUMBER are also passed as string
|
||||
z.string({
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"@hookform/resolvers": "^2.9.7",
|
||||
"@sendgrid/client": "^7.7.0",
|
||||
"@sendgrid/mail": "^7.6.2",
|
||||
"libphonenumber-js": "^1.10.12",
|
||||
"twilio": "^3.80.1",
|
||||
"zod": "^3.20.2"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterEnum
|
||||
ALTER TYPE "EventTypeCustomInputType" ADD VALUE 'phone';
|
||||
@@ -344,6 +344,7 @@ enum EventTypeCustomInputType {
|
||||
NUMBER @map("number")
|
||||
BOOL @map("bool")
|
||||
RADIO @map("radio")
|
||||
PHONE @map("phone")
|
||||
}
|
||||
|
||||
model EventTypeCustomInput {
|
||||
|
||||
Reference in new issue
Block a user