From 3c868ec00f350100b3c84281f6a5c93ff405afcd Mon Sep 17 00:00:00 2001 From: YasamanKahdooei Date: Wed, 17 Apr 2024 16:40:39 +0330 Subject: [PATCH] part of "RecentRequest" Added --- app/RecentRequest/layout.tsx | 4 +- app/RecentRequest/page.tsx | 4 +- app/globals.css | 4 +- components/Menu/SideMenu.tsx | 45 ++++++++++++++++++--- components/RecentRequest/RecentRequests.tsx | 2 +- components/SignIn/LoginForm.tsx | 11 +++++ components/Verify/CountDown.jsx | 2 + components/Verify/VerifyInput.tsx | 30 ++++++++++---- constants/index.tsx | 16 ++++++++ package-lock.json | 9 +++++ package.json | 1 + utils/authenticateApi.ts | 4 +- utils/commonApi.ts | 4 +- 13 files changed, 112 insertions(+), 24 deletions(-) create mode 100644 constants/index.tsx diff --git a/app/RecentRequest/layout.tsx b/app/RecentRequest/layout.tsx index e53af82..14b200b 100644 --- a/app/RecentRequest/layout.tsx +++ b/app/RecentRequest/layout.tsx @@ -7,11 +7,11 @@ export default function RequestLayout({ children: React.ReactNode; }) { return ( -
+
{/* Include shared UI here e.g. a header or sidebar */} -
{children}
+
{children}
); } diff --git a/app/RecentRequest/page.tsx b/app/RecentRequest/page.tsx index e6fd21a..8cb7aee 100644 --- a/app/RecentRequest/page.tsx +++ b/app/RecentRequest/page.tsx @@ -2,9 +2,9 @@ import React from 'react' import RecentRequests from '@/components/RecentRequest/RecentRequests' function page() { return ( - <> +
- +
) } diff --git a/app/globals.css b/app/globals.css index c60d30b..db848dc 100644 --- a/app/globals.css +++ b/app/globals.css @@ -79,8 +79,8 @@ margin: 0; padding: 0; box-sizing: border-box; - direction: rtl; - font-family: "iranyekan"; + /* direction: rtl; */ + font-family: iranyekan; -webkit-tap-highlight-color: transparent; --d-header-height: 70px; --d-sideMenu-width-open: 200px; diff --git a/components/Menu/SideMenu.tsx b/components/Menu/SideMenu.tsx index 0940fa4..714a6de 100644 --- a/components/Menu/SideMenu.tsx +++ b/components/Menu/SideMenu.tsx @@ -1,9 +1,42 @@ -import React from 'react' +"use client"; +import React, { useState } from "react"; +import { GoArrowLeft } from "react-icons/go"; +import { menuItems } from "@/constants"; +import Link from "next/link"; const SideMenu = () => { - return ( -
SideMenu
- ) -} + const [open, setOpen] = useState(false); -export default SideMenu \ No newline at end of file + return ( +
+ SideMenu +
setOpen(!open)} + className={`flex items-center aspect-square bg-white rounded-full shadow-sm text-yellow cursor-pointer h-7 justify-center -left-3 absolute top-5 transition-all duration-700 ease-in-out w-7 z-[400] + ${open === true ? "rotate-180" : "rotate-0"} `} + > + +
+
+
    + {menuItems.map((menuItem) => ( + + {menuItem.icon} + {menuItem.title} + + + ))} +
+
+
+ ); +}; + +export default SideMenu; diff --git a/components/RecentRequest/RecentRequests.tsx b/components/RecentRequest/RecentRequests.tsx index 2a03d81..9cf446a 100644 --- a/components/RecentRequest/RecentRequests.tsx +++ b/components/RecentRequest/RecentRequests.tsx @@ -7,7 +7,7 @@ import UserContainer from "../User/UserContainer"; function RecentRequests() { return ( <> - +
diff --git a/components/SignIn/LoginForm.tsx b/components/SignIn/LoginForm.tsx index 4a51a9a..2f67018 100644 --- a/components/SignIn/LoginForm.tsx +++ b/components/SignIn/LoginForm.tsx @@ -25,6 +25,8 @@ import { useRouter } from "next/navigation"; import useData from "@/store/useData"; import { useMutation, useQuery } from "@tanstack/react-query"; import { logisterCitizen } from "@/utils/authenticateApi"; +import { useEffect } from "react"; +import { appConstants } from "@/utils/variables"; const formSchema = z.object({ phoneNumber: z.string({ required_error: "*فیلد اجباری*" }).max(11, { @@ -40,6 +42,13 @@ function LoginForm() { const router = useRouter(); const saveData = useData((state) => state.saveData); + useEffect(() => { + localStorage.removeItem("countdownTime"); + localStorage.removeItem("CountDownCompleted"); + localStorage.removeItem(appConstants.SH_CT_OTP_TOKEN); + }, []); + + const { data: CaptchaData, isLoading, @@ -56,6 +65,8 @@ function LoginForm() { router.push("/Verify"); localStorage.setItem("VerifyRole", "citizen"); localStorage.setItem("verificationToken", res); + localStorage.setItem(appConstants.SH_CT_OTP_TOKEN,res.data); + console.log(res.data); }, onError: (err: any | string) => { refetch(); diff --git a/components/Verify/CountDown.jsx b/components/Verify/CountDown.jsx index b588c75..784c424 100644 --- a/components/Verify/CountDown.jsx +++ b/components/Verify/CountDown.jsx @@ -41,6 +41,8 @@ const CountdownTimer = ({ isShow, setIsShow }) => { const handleTick = (time) => { // Store remaining time in local storage on each tick localStorage.setItem("countdownTime", time.total); + console.log("handleTick"); + }; const renderer = ({ hours, minutes, seconds, completed }) => { return ( diff --git a/components/Verify/VerifyInput.tsx b/components/Verify/VerifyInput.tsx index 225998a..e00b538 100644 --- a/components/Verify/VerifyInput.tsx +++ b/components/Verify/VerifyInput.tsx @@ -38,7 +38,7 @@ export const VerifyInput = () => { const justLogin = localStorage.getItem("Shahrbin_Login_State"); if (justLogin) { // router.push("/Account/Complaints"); - router.push("/After"); + router.push("/RecentRequest"); localStorage.removeItem("Shahrbin_Login_State"); console.log("justLogin"); } else { @@ -93,26 +93,41 @@ export const VerifyInput = () => { }); }; + //Handle Verify useEffect(() => { console.log(otp); - if (otp.length == 6) { + console.log("Lenght 6"); if (localStorage.getItem("CountDownCompleted")) { const otpTokenString = localStorage.getItem( appConstants.SH_CT_OTP_TOKEN - ); + ) + // if (otpTokenString !== null) { + // resendOtpMutation.mutate({ + // otpToken: JSON.parse(otpTokenString), + // }); + // } + if (otpTokenString !== null) { - resendOtpMutation.mutate({ - otpToken: JSON.parse(otpTokenString), - }); + try { + const otpToken = JSON.parse(otpTokenString); + resendOtpMutation.mutate({ + otpToken: otpToken, + }); + } catch (error) { + console.error('Error parsing otpTokenString:', error); + // Handle the error accordingly, e.g., notify the user or handle it gracefully. + } } + } else { console.log(2); // makeRequest(); } const payload = { - otpToken: localStorage.getItem("verificationToken"), + // otpToken: localStorage.getItem("verificationToken"), + otpToken: localStorage.getItem(appConstants.SH_CT_OTP_TOKEN), verificationCode: otp, }; CitizenVerifyMutation.mutate(payload); @@ -194,6 +209,7 @@ export const VerifyInput = () => { /> + {/* */}
{" "} }, + { id: 2, title: "ثبت درخواست", href: "/", icon: }, + { id: 3, title: "درخواست های من", href: "/", icon: }, + { id: 4, title: "نظرسنجی ها ", href: "/", icon: }, + { id: 5, title: "اخبار", href: "/" , icon: }, + { id: 6, title: "تنظیمات", href: "/", icon: }, + ]; + \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index f93a19b..2523302 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,7 @@ "react-countdown": "^2.3.5", "react-dom": "^18", "react-hook-form": "^7.51.2", + "react-icons": "^5.1.0", "react-loader-spinner": "^6.1.6", "react-otp-input": "^3.1.1", "sonner": "^1.4.41", @@ -4406,6 +4407,14 @@ "react": "^16.8.0 || ^17 || ^18" } }, + "node_modules/react-icons": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.1.0.tgz", + "integrity": "sha512-D3zug1270S4hbSlIRJ0CUS97QE1yNNKDjzQe3HqY0aefp2CBn9VgzgES27sRR2gOvFK+0CNx/BW0ggOESp6fqQ==", + "peerDependencies": { + "react": "*" + } + }, "node_modules/react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", diff --git a/package.json b/package.json index a3d98df..e3f0416 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "react-countdown": "^2.3.5", "react-dom": "^18", "react-hook-form": "^7.51.2", + "react-icons": "^5.1.0", "react-loader-spinner": "^6.1.6", "react-otp-input": "^3.1.1", "sonner": "^1.4.41", diff --git a/utils/authenticateApi.ts b/utils/authenticateApi.ts index 4b47877..72f6bd3 100644 --- a/utils/authenticateApi.ts +++ b/utils/authenticateApi.ts @@ -17,7 +17,7 @@ export async function logisterCitizen(payload: { value: string; }; }) { - const data = await axios.post(`api/${instance.id}/Authenticate/LogisterCitizen`,payload); + const data = await axios.post(`api/Authenticate/LogisterCitizen`,payload); return data.data; } @@ -27,7 +27,7 @@ export async function verifyCitizen(payload: { otpToken: string | null; verificationCode: string; }) { - const data = await axios.post(`api/${instance.id}/Authenticate/VerifyCitizen`, payload); + const data = await axios.post(`api/Authenticate/VerifyCitizen`, payload); return data.data; } \ No newline at end of file diff --git a/utils/commonApi.ts b/utils/commonApi.ts index 0b13b43..9601618 100644 --- a/utils/commonApi.ts +++ b/utils/commonApi.ts @@ -7,7 +7,7 @@ axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP; // Get Captcha export async function getCaptcha() { - const data = await axios.get(`/api/${instance.id}/Authenticate/Captcha`, { + const data = await axios.get(`/api/Authenticate/Captcha`, { responseType: "blob", }); return data; @@ -15,7 +15,7 @@ export async function getCaptcha() { export async function resendOtp(payload: { otpToken: string | any}) { const data = await axios.post( - `/api/${instance.id}/Authenticate/ResendOtp`, + `/api/Authenticate/ResendOtp`, payload ); return data.data;