Files
supabase/apps/studio/components/ui/AlertError.tsx
Jonathan Summers-Muir f912536db8 [Design system] Feat/sonner (#27382)
* fix toast examples

* add sonner stuff

* new sonner examples added

* updated

* add upload POC

* add

* Update sonner-upload.tsx

* move statusicons

* Minor fix.

---------

Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2024-07-19 12:38:42 +02:00

51 lines
1.6 KiB
TypeScript

import Link from 'next/link'
import type { ResponseError } from 'types'
import { AlertDescription_Shadcn_, AlertTitle_Shadcn_, Alert_Shadcn_, Button } from 'ui'
import { WarningIcon } from 'ui'
export interface AlertErrorProps {
projectRef?: string
subject?: string
error?: ResponseError | null
className?: string
}
// [Joshen] To standardize the language for all error UIs
const AlertError = ({ projectRef, subject, error, className }: AlertErrorProps) => {
const subjectString = subject?.replace(/ /g, '%20')
let href = `/support/new?category=dashboard_bug`
if (projectRef) href += `&ref=${projectRef}`
if (subjectString) href += `&subject=${subjectString}`
if (error) href += `&message=Error:%20${error.message}`
const formattedErrorMessage = error?.message?.includes('503')
? '503 Service Temporarily Unavailable'
: error?.message
return (
<Alert_Shadcn_ className={className} variant="warning" title={subject}>
<WarningIcon className="h-4 w-4" strokeWidth={2} />
<AlertTitle_Shadcn_>{subject}</AlertTitle_Shadcn_>
<AlertDescription_Shadcn_ className="flex flex-col gap-3 break-words">
<div>
{error?.message && <p className="text-left">Error: {formattedErrorMessage}</p>}
<p className="text-left">
Try refreshing your browser, but if the issue persists, please reach out to us via
support.
</p>
</div>
<div>
<Button asChild type="warning">
<Link href={href}>Contact support</Link>
</Button>
</div>
</AlertDescription_Shadcn_>
</Alert_Shadcn_>
)
}
export default AlertError