import * as Sentry from '@sentry/nextjs' import { Loader2, Wrench } from 'lucide-react' import Link from 'next/link' import { type Dispatch, type PropsWithChildren, useCallback, useReducer } from 'react' import type { UseFormReturn } from 'react-hook-form' import SVG from 'react-inlinesvg' import { toast } from 'sonner' // End of third-party imports import CopyButton from 'components/ui/CopyButton' import InformationBox from 'components/ui/InformationBox' import { InlineLink, InlineLinkClassName } from 'components/ui/InlineLink' import { usePlatformStatusQuery } from 'data/platform/platform-status-query' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' import { useStateTransition } from 'hooks/misc/useStateTransition' import { BASE_PATH, DOCS_URL } from 'lib/constants' import { Button, cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui' import { AIAssistantOption } from './AIAssistantOption' import { HighlightProjectRefProvider, useHighlightProjectRefContext } from './HighlightContext' import { Success } from './Success' import type { ExtendedSupportCategories } from './Support.constants' import type { SupportFormValues } from './SupportForm.schema' import { createInitialSupportFormState, type SupportFormActions, supportFormReducer, type SupportFormState, } from './SupportForm.state' import { SupportFormV2 } from './SupportFormV2' import { useSupportForm } from './useSupportForm' function useSupportFormTelemetry() { const { mutate: sendEvent } = useSendEventMutation() return useCallback( ({ projectRef, orgSlug, category, }: { projectRef: string | undefined orgSlug: string | undefined category: ExtendedSupportCategories }) => sendEvent({ action: 'support_ticket_submitted', properties: { ticketCategory: category, }, groups: { project: projectRef, organization: orgSlug, }, }), [sendEvent] ) } export function SupportFormPage() { return ( ) } function SupportFormPageContent() { const [state, dispatch] = useReducer(supportFormReducer, undefined, createInitialSupportFormState) const { form, initialError, projectRef, orgSlug } = useSupportForm(dispatch) const sendTelemetry = useSupportFormTelemetry() useStateTransition(state, 'submitting', 'success', (_, curr) => { toast.success('Support request sent. Thank you!') sendTelemetry({ projectRef: curr.sentProjectRef, orgSlug: curr.sentOrgSlug, category: curr.sentCategory, }) }) useStateTransition(state, 'submitting', 'error', (_, curr) => { toast.error(`Failed to submit support ticket: ${curr.message}`) Sentry.captureMessage(`Failed to submit Support Form: ${curr.message}`) dispatch({ type: 'RETURN_TO_EDITING' }) }) return ( ) } function SupportFormWrapper({ children }: PropsWithChildren) { return (
{children}
) } function SupportFormHeader() { const { data, isLoading, isError } = usePlatformStatusQuery() const isHealthy = data?.isHealthy return (

Supabase support

Check Supabase status page
) } function SupportFormDirectEmailInfo() { const { scrollToRef, setShouldHighlightRef: setHighlight } = useHighlightProjectRefContext() return (

Email us directly at{' '} support@supabase.com toast.success('Copied to clipboard')} />

Please, make sure to{' '} {' '} and as much information as possible.

} defaultVisibility={true} hideCollapse={true} /> ) } interface SupportFromBodyProps { form: UseFormReturn state: SupportFormState dispatch: Dispatch initialError: string | null selectedProjectRef: string | null } function SupportFormBody({ form, state, dispatch, initialError, selectedProjectRef, }: SupportFromBodyProps) { const showSuccessMessage = state.type === 'success' return (
{showSuccessMessage ? ( ) : ( )}
) }