: ( // /* OTP Verification Step */ // //
// //

// {t("sendOTPTo")}{" "} // // {formData.credential} // //

//
//
// // { // setOtpCode(e.target.value); // if (otpError) setOtpError(""); // }} // className={`w-full px-4 py-4 bg-white/5 border rounded-xl focus:outline-none focus:ring-2 focus:ring-amber-500 focus:border-transparent text-white text-center text-2xl tracking-[0.5em] placeholder-gray-500 transition-all ${ // otpError ? "border-red-500" : "border-gray-700" // }`} // placeholder="______" // maxLength={6} // dir="ltr" // /> // {otpError && ( // // {otpError} // // )} //
// // // {isLoading ? ( // <> // // {t("verifying")} // // ) : isSuccess ? ( // <> // // {t("success")} // // ) : ( // <> // // {t("verify")} // // )} // // //
// // //
//
<> // )} // Send OTP try { if (loginMethod === "email") { await sendEmailOTP(); } else { await sendPhoneOTP(); } } catch (otpErr) { console.warn("[Login] OTP send failed, proceeding anyway:", otpErr); } setStep("otp"); } else if (result.status >= 500) { console.error("[Login] Server error:", result.status, result.data); toast.error(t("serverError"), { style: { background: "#fee2e2", color: "#991b1b" }, }); } else if (result.status === 404) { console.error("[Login] API endpoint not found:", result.status); toast.error(t("apiNotFound"), { style: { background: "#fee2e2", color: "#991b1b" }, }); } else if (result.status === 429) { toast.error(t("tooManyRequests"), { style: { background: "#fee2e2", color: "#991b1b" }, }); } else { console.error("[Login] Unexpected status:", result.status, result.data); toast.error(result.data?.message || result.data || t("invalidCredentials"), { style: { background: "#fee2e2", color: "#991b1b" }, }); } } catch (err) { console.error("[Login] Error:", err); toast.error(err.message || t("connectionError"), { style: { background: "#fee2e2", color: "#991b1b" }, }); toast(t("otpRequired"), { icon: "🔐", style: { background: "#fef3c7", color: "#92400e" }, }); // Send OTP try { if (loginMethod === "email") { await sendEmailOTP(); } else { await sendPhoneOTP(); } } catch (otpErr) { console.warn("[Login] OTP send failed, proceeding anyway:", otpErr); } setStep("otp"); } else if (result.status >= 500) { console.error("[Login] Server error:", result.status, result.data); toast.error(t("serverError"), { style: { background: "#fee2e2", color: "#991b1b" }, }); } else if (result.status === 404) { console.error("[Login] API endpoint not found:", result.status); toast.error(t("apiNotFound"), { style: { background: "#fee2e2", color: "#991b1b" }, }); } else if (result.status === 429) { toast.error(t("tooManyRequests"), { style: { background: "#fee2e2", color: "#991b1b" }, }); } else { console.error("[Login] Unexpected status:", result.status, result.data); toast.error(result.data?.message || result.data || t("invalidCredentials"), { style: { background: "#fee2e2", color: "#991b1b" }, }); } } catch (err) { console.error("[Login] Error:", err); toast.error(err.message || t("connectionError"), { style: { background: "#fee2e2", color: "#991b1b" }, }); } finally { setIsLoading(false); }