import { AnimatePresence, motion } from 'framer-motion' import { AlertCircle, Check, ChevronsUpDown, ExternalLink } from 'lucide-react' import Link from 'next/link' import type { UseFormReturn } from 'react-hook-form' import { toast } from 'sonner' // End of third-party imports import { useParams } from 'common' import CopyButton from 'components/ui/CopyButton' import InformationBox from 'components/ui/InformationBox' import { OrganizationProjectSelector } from 'components/ui/OrganizationProjectSelector' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import { Button, cn, CommandGroup_Shadcn_, CommandItem_Shadcn_, FormControl_Shadcn_, FormField_Shadcn_, } from 'ui' import { Admonition } from 'ui-patterns' import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout' import ShimmeringLoader from 'ui-patterns/ShimmeringLoader' import { useHighlightProjectRefContext } from './HighlightContext' import type { ExtendedSupportCategories } from './Support.constants' import type { SupportFormValues } from './SupportForm.schema' import { NO_ORG_MARKER, NO_PROJECT_MARKER } from './SupportForm.utils' interface ProjectAndPlanProps { form: UseFormReturn orgSlug: string | null projectRef: string | null category: ExtendedSupportCategories subscriptionPlanId: string | undefined showPlanExpectationInfo?: boolean } export function ProjectAndPlanInfo({ form, orgSlug, projectRef, category, subscriptionPlanId, showPlanExpectationInfo = true, }: ProjectAndPlanProps) { const { ref } = useHighlightProjectRefContext() const hasProjectSelected = projectRef && projectRef !== NO_PROJECT_MARKER return (
{!hasProjectSelected && ( )} {showPlanExpectationInfo && orgSlug && subscriptionPlanId !== 'enterprise' && category !== 'Login_issues' && ( )}
) } interface ProjectSelectorProps { form: UseFormReturn orgSlug: string | null projectRef: string | null } function ProjectSelector({ form, orgSlug, projectRef }: ProjectSelectorProps) { const { projectRef: urlProjectRef } = useParams() return ( ( { if (!urlProjectRef && (!projectRef || projectRef === NO_PROJECT_MARKER)) field.onChange(projects[0]?.ref ?? NO_PROJECT_MARKER) }} onSelect={(project) => field.onChange(project.ref)} renderTrigger={({ isLoading, project }) => { return ( ) }} renderActions={(setOpen) => ( { field.onChange(NO_PROJECT_MARKER) setOpen(false) }} > {field.value === NO_PROJECT_MARKER && }

No specific project

)} />
)} /> ) } interface ProjectRefHighlightedProps { projectRef: string | null } function ProjectRefHighlighted({ projectRef }: ProjectRefHighlightedProps) { const isVisible = !!projectRef && projectRef !== NO_PROJECT_MARKER const { shouldHighlightRef, setShouldHighlightRef: setHighlight } = useHighlightProjectRefContext() return ( {isVisible && (

Project ID:{' '} {projectRef}

{ toast.success('Copied to clipboard') setHighlight(false) }} />
)}
) } interface PlanExpectationInfoBoxProps { orgSlug: string planId?: string } const PlanExpectationInfoBox = ({ orgSlug, planId }: PlanExpectationInfoBoxProps) => { const { billingAll } = useIsFeatureEnabled(['billing:all']) return ( } defaultVisibility={true} hideCollapse={true} title="Expected response times are based on your organization's plan" description={
{planId === 'free' && (

Free Plan support is available within the community and officially by the team on a best efforts basis. For a guaranteed response we recommend upgrading to the Pro Plan. Enhanced SLAs for support are available on our Enterprise Plan.

)} {planId === 'pro' && (

Pro Plan includes email-based support. You can expect an answer within 1 business day in most situations for all severities. We recommend upgrading to the Team Plan for prioritized ticketing on all issues and prioritized escalation to product engineering teams. Enhanced SLAs for support are available on our Enterprise Plan.

)} {planId === 'team' && (

Team Plan includes email-based support. You get prioritized ticketing on all issues and prioritized escalation to product engineering teams. Low, Normal, and High severity tickets will generally be handled within 1 business day, while Urgent issues, we respond within 1 day, 365 days a year. Enhanced SLAs for support are available on our Enterprise Plan.

)} {billingAll && planId !== 'enterprise' && (
)}
} /> ) }