feat : kavenegar otp added
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useRouter } from "@/i18n/routing";
|
||||
import { useRouter, Link } from "@/i18n/routing";
|
||||
import { apiPost, ApiClientError } from "@/lib/api/client";
|
||||
import type { AuthTokenResponse } from "@/lib/api/types";
|
||||
import { useAuthStore } from "@/lib/stores/auth.store";
|
||||
@@ -27,8 +27,6 @@ export default function LoginPage() {
|
||||
switch (err.code) {
|
||||
case "RATE_LIMITED":
|
||||
return t("rateLimited");
|
||||
case "NOT_FOUND":
|
||||
return t("notFound");
|
||||
case "SMS_FAILED":
|
||||
return t("smsFailed");
|
||||
case "INVALID_OTP":
|
||||
@@ -47,6 +45,11 @@ export default function LoginPage() {
|
||||
await apiPost("/api/auth/send-otp", { phone });
|
||||
setStep("otp");
|
||||
} catch (e) {
|
||||
if (e instanceof ApiClientError && e.code === "NOT_FOUND") {
|
||||
// No account → take them to register with phone pre-filled
|
||||
router.push(`/register?phone=${encodeURIComponent(phone)}`);
|
||||
return;
|
||||
}
|
||||
setError(authErrorMessage(e));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -137,6 +140,13 @@ export default function LoginPage() {
|
||||
{error && (
|
||||
<p className="text-center text-sm text-destructive">{error}</p>
|
||||
)}
|
||||
|
||||
<p className="text-center text-sm text-muted-foreground">
|
||||
{t("noAccount")}{" "}
|
||||
<Link href="/register" className="font-medium text-primary hover:underline">
|
||||
{t("registerLink")}
|
||||
</Link>
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user