Files
supabase/apps/studio/components/interfaces/Support/SupportForm.schema.ts
Charis d1c6cbacbd fix(studio): support form validation for client library (#42325)
Bug fix

## What is the current behavior?

The client library selector validation was failing when the simplified
support form was used, because the field was required but hidden.

## What is the new behavior?

The client library selector is only required when: client library JSON
flag is on + not using simplified support form + client libraries is
chosen as the problem category.

## Summary by CodeRabbit

* **Bug Fixes**
* Improved support form validation logic and category eligibility for
support access requests.
* Refined conditional rendering of support access toggle based on
selected category.

* **New Features**
* Added feature-flag-based library selection capability for support
submissions.

* **Refactor**
  * Streamlined support category options and removed obsolete entries.
* Simplified form schema initialization and made library field optional
where applicable.
2026-01-30 15:15:51 -05:00

36 lines
1.2 KiB
TypeScript

import { PLAN_REQUEST_EMPTY_PLACEHOLDER } from 'components/ui/UpgradePlanButton'
import { z } from 'zod'
import { CATEGORY_OPTIONS, type ExtendedSupportCategories } from './Support.constants'
export const SupportFormSchema = z
.object({
organizationSlug: z.string().min(1, 'Please select an organization'),
projectRef: z.string().min(1, 'Please select a project'),
category: z.enum(
CATEGORY_OPTIONS.map((opt) => opt.value) as [
ExtendedSupportCategories,
...ExtendedSupportCategories[],
]
),
severity: z.string(),
library: z.string().optional(),
subject: z.string().min(1, 'Please add a subject heading'),
message: z.string().min(1, "Please add a message about the issue that you're facing"),
affectedServices: z.string(),
allowSupportAccess: z.boolean(),
attachDashboardLogs: z.boolean(),
dashboardSentryIssueId: z.string().optional(),
})
.refine(
(data) => {
return !data.message.includes(PLAN_REQUEST_EMPTY_PLACEHOLDER)
},
{
message: `Please let us know which plan you'd like to upgrade to for your organization`,
path: ['message'],
}
)
export type SupportFormValues = z.infer<typeof SupportFormSchema>