SupportForm.schema.ts 1.2 KB

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