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:
authored and GitHub committed 2022-12-16 12:39:41 -07:00
1 parent b789e58624
commit 916468b8cc
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({
+1
View File
@@ -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';
+1
View File
@@ -344,6 +344,7 @@ enum EventTypeCustomInputType {
NUMBER @map("number")
BOOL @map("bool")
RADIO @map("radio")
PHONE @map("phone")
}
model EventTypeCustomInput {