mirror of
https://github.com/supabase/supabase.git
synced 2026-10-15 22:29:11 +03:00
56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
import { PropsWithChildren } from 'react'
|
|
|
|
import { AlertDescription_Shadcn_, AlertTitle_Shadcn_, Alert_Shadcn_, WarningIcon } from 'ui'
|
|
import { ContactSupportButton } from './ContactSupportButton'
|
|
|
|
export interface AlertErrorProps {
|
|
projectRef?: string
|
|
subject?: string
|
|
error?: { message: string } | null
|
|
className?: string
|
|
showIcon?: boolean
|
|
}
|
|
|
|
// [Joshen] To standardize the language for all error UIs
|
|
|
|
const AlertError = ({
|
|
projectRef,
|
|
subject,
|
|
error,
|
|
className,
|
|
showIcon = true,
|
|
children,
|
|
}: PropsWithChildren<AlertErrorProps>) => {
|
|
const formattedErrorMessage = error?.message?.includes('503')
|
|
? '503 Service Temporarily Unavailable'
|
|
: error?.message
|
|
|
|
return (
|
|
<Alert_Shadcn_ className={className} variant="warning" title={subject}>
|
|
{showIcon && <WarningIcon className="h-4 w-4" strokeWidth={2} />}
|
|
<AlertTitle_Shadcn_ className="text-foreground">{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 for more than a few minutes,
|
|
please reach out to us via support.
|
|
</p>
|
|
</div>
|
|
{children}
|
|
<ContactSupportButton
|
|
category="DASHBOARD_BUG"
|
|
subject={subject ?? ''}
|
|
message={error?.message ?? ''}
|
|
projectRef={projectRef}
|
|
errorContext={{
|
|
error: error?.message,
|
|
}}
|
|
/>
|
|
</AlertDescription_Shadcn_>
|
|
</Alert_Shadcn_>
|
|
)
|
|
}
|
|
|
|
export default AlertError
|