import { TriangleAlert } from 'lucide-react'; import { WeakPasswordError, WeakPasswordReason, } from '@kit/supabase/hooks/use-sign-up-with-email-password'; import { Alert, AlertDescription, AlertTitle } from '@kit/ui/alert'; import { Trans } from '@kit/ui/trans'; function isWeakPasswordError(error: unknown): error is WeakPasswordError { return error instanceof Error && error.name === 'WeakPasswordError'; } /** * @name AuthErrorAlert * @param error This error comes from Supabase as the code returned on errors * This error is mapped from the translation auth:errors.{error} * To update the error messages, please update the translation file * https://github.com/supabase/gotrue-js/blob/master/src/lib/errors.ts * @constructor */ export function AuthErrorAlert({ error, }: { error: Error | null | undefined | string; }) { if (!error) { return null; } // Handle weak password errors specially if (isWeakPasswordError(error)) { return ; } const DefaultError = ; const errorCode = error instanceof Error ? 'code' in error && typeof error.code === 'string' ? error.code : error.message : error; return ( ); } function WeakPasswordErrorAlert({ reasons, }: { reasons: WeakPasswordReason[]; }) { return ( {reasons.length > 0 && (
    {reasons.map((reason) => (
  • ))}
)}
); }