From e089e95ce8363070543b27497a80bc5e50155133 Mon Sep 17 00:00:00 2001 From: "tomosa.sarkar" Date: Mon, 8 Sep 2025 17:33:08 +0530 Subject: [PATCH] Feat : View User Configuration page is up --- TODO.md | 12 +- instruction.md | 1 + .../administrator/home/UserConfiguration.tsx | 10 +- .../home/ViewUserConfiguration.tsx | 175 ++++++++++++++++++ src/app/administrator/home/page.tsx | 3 +- src/app/administrator/login/page.tsx | 2 +- 6 files changed, 190 insertions(+), 13 deletions(-) create mode 100644 src/app/administrator/home/ViewUserConfiguration.tsx diff --git a/TODO.md b/TODO.md index 67530c7..ec81ad3 100644 --- a/TODO.md +++ b/TODO.md @@ -8,18 +8,18 @@ ### Feature - Password Expiry Logic - login -> check password Expiry -> Change password -> login screen -- Logout popup : - - Are you sure want to logout? +- >Logout popup : + - >Are you sure want to logout? - >Home page password Expiry message - Set userId and login with userID - Limit of transaction daily - >Statement Download -- In Every OTP page "Resend button" & 5 min timing of expiry. +- >In Every OTP page "Resend button" & 3 min timing of expiry. - OTP binding with actual mobile number. - IN settings page NOTE position Fixing. -- Admin page - - give rights - - view rights (Pending) +- >Admin page + - >give rights + - >view rights - Forget Password diff --git a/instruction.md b/instruction.md index e0f6669..4b1dfa4 100644 --- a/instruction.md +++ b/instruction.md @@ -88,5 +88,6 @@ scp -P 9022 Smsservice/smsserviceapplication.jar @localhost:/home/(""); + const [ibAccess, setIbAccess] = useState<"2" | "1" | null>(null); const [mbEnabled, setMbEnabled] = useState(false); - const [mbAccess, setMbAccess] = useState<"2" | "1" | "">(""); + const [mbAccess, setMbAccess] = useState<"2" | "1" | null>(null); const isValidated = !!userDetails; const canSubmit = isValidated && !!savingsAccount && confirmedPreview; @@ -47,7 +47,7 @@ export default function UserConfiguration() { const data = await response.json(); if (response.ok && Array.isArray(data) && data.length > 0) { const saAccount = data.find(acc => acc.stAccountType === 'SA'); - console.log(saAccount); + // console.log(saAccount); if (saAccount) { setSavingsAccount(saAccount.stAccountNo); } else { @@ -297,7 +297,7 @@ export default function UserConfiguration() { checked={ibEnabled} onChange={(e) => { setIbEnabled(e.currentTarget.checked); - if (!e.currentTarget.checked) setIbAccess(""); + if (!e.currentTarget.checked) setIbAccess(null); }} /> @@ -328,7 +328,7 @@ export default function UserConfiguration() { checked={mbEnabled} onChange={(e) => { setMbEnabled(e.currentTarget.checked); - if (!e.currentTarget.checked) setMbAccess(""); + if (!e.currentTarget.checked) setMbAccess(null); }} /> diff --git a/src/app/administrator/home/ViewUserConfiguration.tsx b/src/app/administrator/home/ViewUserConfiguration.tsx new file mode 100644 index 0000000..0e5e7bf --- /dev/null +++ b/src/app/administrator/home/ViewUserConfiguration.tsx @@ -0,0 +1,175 @@ +"use client"; +import React, { useState } from "react"; +import { + TextInput, + Button, + Title, + Stack, + Group, + Text, + Divider, + LoadingOverlay, + Box, + Paper, +} from "@mantine/core"; +import { notifications } from "@mantine/notifications"; + +interface UserRights { + customer_no: string; + created_at: string; + last_login: Date; + is_first_login: boolean; + ibAccess: "1" | "2" | "0" | null; + mbAccess: "1" | "2" | "0" | null; +} + +export default function ViewUserRights() { + const [CIFNo, setCIFNo] = useState(""); + const [loading, setLoading] = useState(false); + const [userData, setUserData] = useState(null); + const [detailsExpanded, setDetailsExpanded] = useState(true); + + const handleSearch = async () => { + if (!CIFNo) { + notifications.show({ + color: "red", + title: "Required", + message: "Please enter CIF Number.", + }); + return; + } + setLoading(true); + setUserData(null); + + try { + const token = localStorage.getItem("admin_access_token"); + const response = await fetch( + `/api/auth/admin/user/rights?CIF=${CIFNo}`, + { + method: "GET", + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${token}`, + }, + } + ); + + const data = await response.json(); + if (response.ok && data) { + setUserData({ + customer_no: data.customer_no, + created_at: data.created_at, + last_login: data.last_login, + is_first_login: data.is_first_login, + ibAccess: data.ib_access_level, + mbAccess: data.mb_access_level, + }); + } else { + notifications.show({ + color: "red", + title: "Not Found", + message: "No user rights found for this identifier.", + }); + } + } catch (err) { + notifications.show({ + color: "red", + title: "Failed", + message: "Error fetching user rights", + }); + } finally { + setLoading(false); + } + }; + + return ( + + + View User Rights + + { + const input = e.currentTarget.value.replace(/\D/g, ""); + if (input.length <= 11) { + setCIFNo(input); + setUserData(null) + }; + }} + style={{ flex: 1 }} + /> + + + + {userData && ( + <> + + + + + CIF Number: + {userData.customer_no} + + + User Created : + {new Date(userData.created_at).toLocaleString()} + + + User Active Status: + Active + + + User Registered Status: + + {userData.is_first_login ? "Not Registered" : "Registered"} + + + + + + + + + Internet Banking Rights: + + {userData.ibAccess === "1" + ? "Transaction Mode" + : userData.ibAccess === "2" + ? "Read Mode" + : "Not Declared"} + + + + Mobile Banking Rights: + + {userData.mbAccess === "1" + ? "Transaction Mode" + : userData.mbAccess === "2" + ? "Read Mode" + : "Not Declared"} + + + + + + ) + } + + ); +} diff --git a/src/app/administrator/home/page.tsx b/src/app/administrator/home/page.tsx index 91a736d..52cde41 100644 --- a/src/app/administrator/home/page.tsx +++ b/src/app/administrator/home/page.tsx @@ -8,6 +8,7 @@ import NextImage from "next/image"; import logo from '@/app/image/logo1.jpg'; import { IconEye, IconLogout, IconPhoneFilled, IconUsers, IconUserScreen } from "@tabler/icons-react"; import UserConfiguration from "./UserConfiguration"; +import ViewUserConfiguration from "./ViewUserConfiguration"; export default function Login() { const router = useRouter(); @@ -165,7 +166,7 @@ export default function Login() { {view === 'userConf' && } - {view === 'view' && Feature will be available soon ....} + {view === 'view' && } {!view && Welcome To The Admin Portal } diff --git a/src/app/administrator/login/page.tsx b/src/app/administrator/login/page.tsx index b95363b..7e4bf49 100644 --- a/src/app/administrator/login/page.tsx +++ b/src/app/administrator/login/page.tsx @@ -73,7 +73,7 @@ export default function Login() { const data = await response.json(); setIsLogging(true); if (response.ok) { - console.log(data); + // console.log(data); const token = data.token; localStorage.setItem("admin_access_token", token); router.push("/administrator/home");