Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Add Zod schemas for submitted lead comments

Rafic9221c5ab03c
diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.ts
index 8b953820ee..bf0aebe4f1 100644
--- a/apps/web/lib/types.ts
+++ b/apps/web/lib/types.ts
@@ -193,6 +193,7 @@ import {
import { fraudEventContext } from "./zod/schemas/schemas";
import { submittedLeadFormDataSchema } from "./zod/schemas/submitted-lead-form";
import {
+ SubmittedLeadCommentSchema,
submittedLeadSchema,
updateSubmittedLeadStatusSchema,
} from "./zod/schemas/submitted-leads";
@@ -813,6 +814,10 @@ export type CreateFraudEventInput = Pick<
export type SubmittedLeadProps = z.infer<typeof submittedLeadSchema>;
+export type SubmittedLeadCommentProps = z.infer<
+ typeof SubmittedLeadCommentSchema
+>;
+
export type SubmittedLeadFormDataField = z.infer<
typeof submittedLeadFormDataSchema
>;
diff --git a/apps/web/lib/zod/schemas/submitted-leads.ts b/apps/web/lib/zod/schemas/submitted-leads.ts
index 23863d03e2..f28decd143 100644
--- a/apps/web/lib/zod/schemas/submitted-leads.ts
+++ b/apps/web/lib/zod/schemas/submitted-leads.ts
@@ -3,6 +3,7 @@ import * as z from "zod/v4";
import { getPaginationQuerySchema } from "./misc";
import { PartnerSchema } from "./partners";
import { submittedLeadFormDataSchema } from "./submitted-lead-form";
+import { UserSchema } from "./users";
import { centsSchema } from "./utils";
export const submittedLeadSchema = z.object({
@@ -115,3 +116,45 @@ export const updateSubmittedLeadStatusSchema = z.discriminatedUnion("status", [
status: z.literal("closedLost"),
}),
]);
+
+export const MAX_SUBMITTED_LEAD_COMMENT_LENGTH = 2000;
+
+export const SubmittedLeadCommentSchema = z.object({
+ id: z.string(),
+ leadId: z.string(),
+ userId: z.string(),
+ partnerId: z.string().nullable(),
+ text: z.string(),
+ partnerVisible: z.boolean(),
+ createdAt: z.date(),
+ updatedAt: z.date(),
+ user: UserSchema.pick({
+ id: true,
+ name: true,
+ image: true,
+ }),
+});
+
+export const createSubmittedLeadCommentSchema = z.object({
+ workspaceId: z.string(),
+ leadId: z.string(),
+ text: z.string().trim().min(1).max(MAX_SUBMITTED_LEAD_COMMENT_LENGTH),
+ partnerVisible: z.boolean().default(false),
+});
+
+export const updateSubmittedLeadCommentSchema = z.object({
+ workspaceId: z.string(),
+ commentId: z.string(),
+ text: z.string().trim().min(1).max(MAX_SUBMITTED_LEAD_COMMENT_LENGTH),
+});
+
+export const deleteSubmittedLeadCommentSchema = z.object({
+ workspaceId: z.string(),
+ commentId: z.string(),
+});
+
+export const createPartnerSubmittedLeadCommentSchema = z.object({
+ programId: z.string(),
+ leadId: z.string(),
+ text: z.string().trim().min(1).max(MAX_SUBMITTED_LEAD_COMMENT_LENGTH),
+});