import { SupportCategories } from '@supabase/shared-types/out/constants' import { PropsWithChildren, useEffect, useRef } from 'react' import { Button } from 'ui' import { Admonition } from 'ui-patterns/admonition' import { SupportLink } from '@/components/interfaces/Support/SupportLink' import { useTrack } from '@/lib/telemetry/track' export interface AlertErrorProps { projectRef?: string subject?: string description?: string error?: { message: string } | null layout?: 'vertical' | 'horizontal' | 'responsive' className?: string showIcon?: boolean showInstructions?: boolean showErrorPrefix?: boolean additionalActions?: React.ReactNode } export const ContactSupportButton = ({ projectRef, subject, error, }: { projectRef?: string subject?: string error?: { message: string } | null }) => { return ( Contact support ) } // [Joshen] To standardize the language for all error UIs export const AlertError = ({ projectRef, subject, description = 'Try refreshing your browser, but if the issue persists for more than a few minutes, please reach out to us via support.', error, className, showIcon = true, layout = 'responsive', showInstructions = true, showErrorPrefix = true, children, additionalActions, }: PropsWithChildren) => { const track = useTrack() const hasTrackedRef = useRef(false) const formattedErrorMessage = error?.message?.includes('503') ? '503 Service Temporarily Unavailable' : error?.message useEffect(() => { if (!hasTrackedRef.current) { hasTrackedRef.current = true if (Math.random() < 0.1) { track('dashboard_error_created', { source: 'admonition', }) } } }, [track]) return ( {error?.message && ( {showErrorPrefix && 'Error: '} {formattedErrorMessage} )} {showInstructions && {description}} {children} > } actions={ additionalActions ? ( <> {additionalActions} > ) : ( ) } className={className} /> ) } export default AlertError
{showErrorPrefix && 'Error: '} {formattedErrorMessage}
{description}