From 1e9595abd48ecd0017a9493e58c8edb077d2e607 Mon Sep 17 00:00:00 2001 From: "nabanita.jana" Date: Mon, 22 Sep 2025 12:07:11 +0530 Subject: [PATCH] feat:user migration --- .../account_statement/accountStatement.tsx | 2 +- src/app/(main)/layout.tsx | 2 +- src/app/login/page.tsx | 108 +++++++++++++++++- 3 files changed, 109 insertions(+), 3 deletions(-) diff --git a/src/app/(main)/accounts/account_statement/accountStatement.tsx b/src/app/(main)/accounts/account_statement/accountStatement.tsx index 96fa2e0..17d7791 100644 --- a/src/app/(main)/accounts/account_statement/accountStatement.tsx +++ b/src/app/(main)/accounts/account_statement/accountStatement.tsx @@ -208,7 +208,7 @@ export default function AccountStatementPage() { style={{ cursor: "pointer" }} onClick={() => generatePDF(selectedAccNo || "", availableBalance || "0", transactions, - localStorage.getItem("remitter_name") || "", + localStorage.getItem("remitter_name") || "", startDate ? dayjs(startDate).format("DD/MM/YYYY") : "", endDate ? dayjs(endDate).format("DD/MM/YYYY") : "") } diff --git a/src/app/(main)/layout.tsx b/src/app/(main)/layout.tsx index c245356..d9b58c8 100644 --- a/src/app/(main)/layout.tsx +++ b/src/app/(main)/layout.tsx @@ -249,7 +249,7 @@ export default function RootLayout({ children }: { children: React.ReactNode }) diff --git a/src/app/login/page.tsx b/src/app/login/page.tsx index f8c0a7d..a349933 100644 --- a/src/app/login/page.tsx +++ b/src/app/login/page.tsx @@ -1,6 +1,6 @@ "use client"; import React, { useState, useEffect, memo, useRef } from "react"; -import { Text, Button, TextInput, PasswordInput, Title, Card, Group, Flex, Box, Image, Anchor, Tooltip } from "@mantine/core"; +import { Text, Button, TextInput, PasswordInput, Title, Card, Group, Flex, Box, Image, Anchor, Tooltip, Modal } from "@mantine/core"; import { notifications } from "@mantine/notifications"; import { Providers } from "@/app/providers"; import { useRouter } from "next/navigation"; @@ -20,6 +20,11 @@ export default function Login() { const [isLogging, setIsLogging] = useState(false); const ClientCarousel = dynamic(() => import('./clientCarousel'), { ssr: false }); const headerRef = useRef(null); + const [opened, setOpened] = useState(false); + const [otpStep, setOtpStep] = useState(false); + const [otp, setOtp] = useState(""); + const [isOtpSending, setIsOtpSending] = useState(false); + const [isOtpVerifying, setIsOtpVerifying] = useState(false); useEffect(() => { const loadCaptcha = async () => { @@ -97,7 +102,13 @@ export default function Login() { }); const data = await response.json(); console.log(data); + if (data.error === "MIGRATED_USER_HAS_NO_PASSWORD") { + //console.log("Migration issue detected → opening modal"); + setOpened(true); + return; + } if (!response.ok) { + //console.log("hiiiii"); notifications.show({ withBorder: true, color: "red", @@ -109,6 +120,7 @@ export default function Login() { localStorage.clear(); sessionStorage.clear(); return; + } setIsLogging(true); if (response.ok) { @@ -163,6 +175,100 @@ export default function Login() { return ( + { + setOpened(false); + setOtpStep(false); + setOtp(""); + }} + title="User Migration Notice" + centered + > + {!otpStep ? ( + // STEP 1: Migration Notice + <> + + Your account is being migrated to the new system. + You need to set a new password to continue login. + + + + + + {/* ✅ Instead of calling API, just open OTP screen */} + + + + ) : ( + // STEP 2: OTP Verification (Frontend-only) + <> + + Enter the OTP (for demo, you can accept any value). + + + setOtp(e.currentTarget.value)} + /> + + + + + + + + )} + + + + {/* */}
{/* Header */}