import { Loader2 } from "lucide-react" import { useState } from "react" import { useNavigate } from "react-router-dom" import { toast } from "sonner" import { resolveAuthMobile, startGoogleLogin } from "../../api/users" import { Button } from "../../components/ui/button" import { Input } from "../../components/ui/input" import { useAuthFlow } from "../../context/AuthFlowContext" import { useTranslation } from "../../hooks/useTranslation" import { AuthPanel } from "./AuthPanel" import { getApiErrorMessage } from "./utils" const GoogleIcon = () => ( ) export function LoginMobilePage() { const navigate = useNavigate() const { t } = useTranslation() const { state, setMobile, clearOtpDelivery, clearSignupDetails, resetFlow } = useAuthFlow() const [loading, setLoading] = useState(false) const handleContinue = async () => { if (!state.login.mobile) { toast.error(t.login.toasts.enterMobile) return } setLoading(true) try { const result = await resolveAuthMobile(state.login.mobile) resetFlow("forgotPassword") if (result.status === "existing_user") { clearOtpDelivery("login") navigate("/auth/login/password") return } resetFlow("signup") clearSignupDetails() setMobile("signup", state.login.mobile) navigate("/auth/signup/password") } catch (error) { toast.error(getApiErrorMessage(error, t.login.toasts.resolveMobileFailed)) } finally { setLoading(false) } } return (
{ event.preventDefault() void handleContinue() }} className="grid gap-4" > setMobile("login", event.target.value)} className="h-11 text-start" />
{t.login.orContinueWith}
) }