LinkSupportTicketForm.schema.ts27 lines · main
| 1 | import { z } from 'zod' |
| 2 | |
| 3 | import { CATEGORY_OPTIONS, type ExtendedSupportCategories } from './Support.constants' |
| 4 | import { NO_ORG_MARKER } from './SupportForm.utils' |
| 5 | |
| 6 | export const LinkSupportTicketFormSchema = z.object({ |
| 7 | conversation_id: z.string().min(1, 'Conversation ID is required'), |
| 8 | organizationSlug: z |
| 9 | .string() |
| 10 | .min(1, 'Please select an organization') |
| 11 | .refine((val) => val !== NO_ORG_MARKER, { |
| 12 | message: 'Please select an organization', |
| 13 | }), |
| 14 | projectRef: z.string().min(1, 'Please select a project'), |
| 15 | category: z.enum( |
| 16 | CATEGORY_OPTIONS.map((opt) => opt.value) as [ |
| 17 | ExtendedSupportCategories, |
| 18 | ...ExtendedSupportCategories[], |
| 19 | ], |
| 20 | { |
| 21 | required_error: 'Please select a category', |
| 22 | } |
| 23 | ), |
| 24 | allowSupportAccess: z.boolean(), |
| 25 | }) |
| 26 | |
| 27 | export type LinkSupportTicketFormValues = z.infer<typeof LinkSupportTicketFormSchema> |