Files
Saxon Fletcher 4452e0ac2e Support form sidebar (#45203)
Refactors our help sidebar within Studio to include the actual support
form itself when contact is selected. This PR also cleans up the initial
state of the sidebar and the options within.

## To test:
- Open an org and click the help icon top right
- Click contact support
- Submit a support ticket
- Click done to return to support sidebar state

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Support form V3 and support sidebar with status button; direct-email
helper and URL prefill
* Success screen supports onFinish callback and customizable finish
label
* AI Assistant and Help options accept optional click callbacks;
resource items gain keyboard/accessibility support

* **Refactor**
  * Help panel split into home/support views with back navigation
* Support components accept flexible align/className props and
layout/styling tweaks
  * Initial URL params loader added for support form

* **Tests**
* New/updated tests for support flows, success screen, and help options
interactions
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Gildas Garcia <1122076+djhi@users.noreply.github.com>
2026-05-08 13:51:49 +10:00

96 lines
3.3 KiB
TypeScript

import { Check, Mail } from 'lucide-react'
import Link from 'next/link'
import { Button, IconDiscord, Separator } from 'ui'
import { NO_PROJECT_MARKER } from './SupportForm.utils'
import { useProjectDetailQuery } from '@/data/projects/project-detail-query'
import { useProfile } from '@/lib/profile'
interface SuccessProps {
sentCategory?: string
selectedProject?: string
onFinish?: () => void
finishLabel?: string
}
export const Success = ({
sentCategory = '',
selectedProject = NO_PROJECT_MARKER,
onFinish,
finishLabel = 'Finish',
}: SuccessProps) => {
const { profile } = useProfile()
const respondToEmail = profile?.primary_email ?? 'your email'
const { data: project } = useProjectDetailQuery(
{ ref: selectedProject },
{ enabled: selectedProject !== NO_PROJECT_MARKER }
)
const projectName = project ? project.name : 'No specific project'
const categoriesToShowAdditionalResources = ['Problem', 'Unresponsive', 'Performance']
return (
<div className="mt-10 max-w-[620px] flex flex-col items-center space-y-4">
<div className="relative">
<Mail strokeWidth={1.5} size={32} className="text-brand" />
<div className="absolute -bottom-1 -right-1.5 flex h-4 w-4 items-center justify-center rounded-full bg-brand">
<Check strokeWidth={4} size={16} className="text-contrast" />
</div>
</div>
<div className="flex items-center flex-col space-y-2 text-center p-4">
<h3 className="text-xl">Support request sent</h3>
<p className="text-sm text-foreground-light text-balance">
{selectedProject !== NO_PROJECT_MARKER && (
<>
Your ticket has been logged for the project{' '}
<span className="text-foreground font-medium">{projectName}</span> with project ID:{' '}
<span className="text-foreground font-medium">{selectedProject}</span>.
</>
)}{' '}
We will reach out to you at{' '}
<span className="text-foreground font-medium">{respondToEmail}</span>.
</p>
</div>
{categoriesToShowAdditionalResources.includes(sentCategory) && (
<>
<div className="my-10! w-full">
<Separator />
</div>
<div className="flex flex-col items-center px-12 space-y-2 text-center">
<h4 className="text-lg font-normal">Tap into our community</h4>
<p className="text-sm text-foreground-light text-balance">
Our Discord community can help with code-related issues. Many questions are answered
in minutes.
</p>
</div>
<Button
asChild
type="default"
icon={<IconDiscord size={16} fill="hsl(var(--background-default))" />}
>
<Link href={'https://discord.supabase.com/'} target="_blank">
Join us on Discord
</Link>
</Button>
</>
)}
<div className="mt-10! w-full">
<Separator />
</div>
<div className="w-full pb-4 px-4 flex items-center justify-end">
{onFinish ? (
<Button type="default" onClick={onFinish}>
{finishLabel}
</Button>
) : (
<Button asChild type="default">
<Link href="/">{finishLabel}</Link>
</Button>
)}
</div>
</div>
)
}