SupportForm.schema.ts35 lines · main
1import { z } from 'zod'
2
3import { CATEGORY_OPTIONS, type ExtendedSupportCategories } from './Support.constants'
4import { PLAN_REQUEST_EMPTY_PLACEHOLDER } from '@/components/ui/UpgradePlanButton'
5
6export const SupportFormSchema = z
7 .object({
8 organizationSlug: z.string().min(1, 'Please select an organization'),
9 projectRef: z.string().min(1, 'Please select a project'),
10 category: z.enum(
11 CATEGORY_OPTIONS.map((opt) => opt.value) as [
12 ExtendedSupportCategories,
13 ...ExtendedSupportCategories[],
14 ]
15 ),
16 severity: z.string(),
17 library: z.string().optional(),
18 subject: z.string().min(1, 'Please add a subject heading'),
19 message: z.string().min(1, "Please add a message about the issue that you're facing"),
20 affectedServices: z.string(),
21 allowSupportAccess: z.boolean(),
22 attachDashboardLogs: z.boolean(),
23 dashboardSentryIssueId: z.string().optional(),
24 })
25 .refine(
26 (data) => {
27 return !data.message.includes(PLAN_REQUEST_EMPTY_PLACEHOLDER)
28 },
29 {
30 message: `Please let us know which plan you'd like to upgrade to for your organization`,
31 path: ['message'],
32 }
33 )
34
35export type SupportFormValues = z.infer<typeof SupportFormSchema>