LinkSupportTicketForm.schema.ts 871 B

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