chore: change timezone format and update webhook (#14433)

* chore: change timezone format

* chore: set guest email and guest company to null

* feat: also check states to get id

* chore: improve code

* chore: fix type erro

* chore: update zod schema
This commit is contained in:
Udit Takkar authored and GitHub committed 2024-04-08 15:26:31 +05:30
1 parent 67262910cd
commit 74dc46f8b2
4 files changed
+57 -12

No files matched your search

+22 -2
View File
@@ -702,8 +702,8 @@ export const AIPhoneSettingSchema = z.object({
guestName: z.string().trim().min(1, {
message: "Please enter Guest Name",
}),
guestEmail: z.string().email().optional(),
guestCompany: z.string().optional(),
guestEmail: z.string().email().nullable().optional(),
guestCompany: z.string().nullable().optional(),
generalPrompt: z.string().trim().min(1, {
message: "Please enter prompt",
}),
@@ -731,6 +731,26 @@ export const getRetellLLMSchema = z
})
.passthrough()
),
states: z
.array(
z
.object({
name: z.string(),
tools: z.array(
z
.object({
name: z.string(),
type: z.string(),
cal_api_key: z.string().optional(),
event_type_id: z.number().optional(),
timezone: z.string().optional(),
})
.passthrough()
),
})
.passthrough()
)
.nullable(),
})
.passthrough();
@@ -16,8 +16,8 @@ export const EventTypeUpdateInput = _EventTypeModel
yourPhoneNumber: z.string().default(""),
numberToCall: z.string().default(""),
guestName: z.string().default(""),
guestEmail: z.string().default(""),
guestCompany: z.string().default(""),
guestEmail: z.string().nullable().default(null),
guestCompany: z.string().nullable().default(null),
})
.optional(),
calAiPhoneScript: z.string().optional(),
@@ -372,9 +372,15 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
where: {
eventTypeId: id,
},
update: aiPhoneCallConfig,
update: {
...aiPhoneCallConfig,
guestEmail: !!aiPhoneCallConfig?.guestEmail ? aiPhoneCallConfig.guestEmail : null,
guestCompany: !!aiPhoneCallConfig?.guestCompany ? aiPhoneCallConfig.guestCompany : null,
},
create: {
...aiPhoneCallConfig,
guestEmail: !!aiPhoneCallConfig?.guestEmail ? aiPhoneCallConfig.guestEmail : null,
guestCompany: !!aiPhoneCallConfig?.guestCompany ? aiPhoneCallConfig.guestCompany : null,
eventTypeId: id,
},
});