From 1c7ed780bfff9769a822265055c00b955b229852 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Mon, 10 Jul 2023 17:13:57 +0330 Subject: [PATCH 01/54] add register page and debuging login --- public/images/register.svg | 1 + public/locales/fa/app.json | 21 +- src/components/first/index.jsx | 56 +++-- src/components/login-navy/index.jsx | 106 +++++----- .../login-welfare-services/index.jsx | 82 ++++---- src/components/register-navy/index.jsx | 191 ++++++++++++++++++ src/pages/dashboard/index.jsx | 2 +- src/pages/register-navy.jsx | 4 +- 8 files changed, 328 insertions(+), 135 deletions(-) create mode 100644 public/images/register.svg diff --git a/public/images/register.svg b/public/images/register.svg new file mode 100644 index 0000000..f5184c9 --- /dev/null +++ b/public/images/register.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 9eb981a..d4073b1 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -5,6 +5,7 @@ "first_page": "خوش آمدید", "login": "ورود", "login_navy": "ورود اعضای ناوگان", + "register_navy": "ثبت نام اعضای ناوگان", "login_welfare_services": "ورود اعضای خدمات رفاهی", "user_welfare_services": "خدمات رفاهی", "user_navy": "ناوگان", @@ -34,10 +35,8 @@ "typography_routing_dashbaord_page": "داشبورد..." }, "LoginPage": { - "text_field_user_name": "نام کاربری", - "text_field_enter_your_username": "نام کاربری خود را وارد کنید", - "text_field_password": "رمز عبور", - "text_field_enter_your_password": "رمز عبور خود را وارد کنید", + "text_field_phone_number": "شماره تلفن", + "text_field_enter_your_phone_number": "شماره تلفن خود را وارد کنید", "button_submit": "ورود", "link_routing_back_to": "بازگشت به", "link_routing_previuos_page": "صفحه قبل", @@ -45,7 +44,19 @@ "error_message_required": "اجباری!", "button_make_account": "ایجاد حساب" }, - "dashboard": { + "Dashboard": { "dashboard_page": "داشبورد" + }, + "RegisterPage": { + "link_routing_back_to": "بازگشت به", + "link_routing_login_navy": "صفحه ورود", + "text_field_phone_number": "شماره تلفن", + "text_field_enter_your_phone_number": "شماره تلفن خود را وارد کنید", + "text_field_national_id": "کد ملی", + "text_field_enter_your_national_id": "کد ملی خود را وارد کنید", + "text_field_navgan_id": "شماره ناوگان", + "text_field_enter_your_navgan_id": "شماره ناوگان خود را وارد کنید", + "error_message_required": "اجباری!", + "button_request_verification": "دریافت کد یکبارمصرف" } } diff --git a/src/components/first/index.jsx b/src/components/first/index.jsx index 9a1be52..24ef6bb 100644 --- a/src/components/first/index.jsx +++ b/src/components/first/index.jsx @@ -4,7 +4,7 @@ import StyledImage from "@/core/components/StyledImage"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import useUser from "@/lib/app/hooks/useUser"; -import { Box, Button, Divider, Typography } from "@mui/material"; +import { Box, Button, Grid, Typography } from "@mui/material"; import { useTranslations } from "next-intl"; const FirstComponent = () => { @@ -34,28 +34,42 @@ const FirstComponent = () => { {t("dashboard")} ) : ( - - - - + + + + + + + )} diff --git a/src/components/login-navy/index.jsx b/src/components/login-navy/index.jsx index 70abf0e..8f1cbbd 100644 --- a/src/components/login-navy/index.jsx +++ b/src/components/login-navy/index.jsx @@ -1,6 +1,5 @@ import LinkRouting from "@/core/components/LinkRouting"; // import Notifications from "@/core/components/notifications"; -import PasswordField from "@/core/components/PasswordField"; import StyledForm from "@/core/components/StyledForm"; // import { GET_USER_TOKEN } from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; @@ -13,6 +12,7 @@ import { Box, Button, Container, + Grid, Paper, Stack, TextField, @@ -35,27 +35,24 @@ const LoginComponent = () => { const backUrlDecodedPath = searchParams.get("back_url"); // formik properties -// const handleSubmit = async (values, props) => { -// await axios -// .post(GET_USER_TOKEN, { -// username: values.username, -// password: values.password, -// }) -// .then(function (response) { -// setToken(response.data.token); -// }) -// .catch(function (error) { -// Notifications(directionApp, error.response, t); -// props.setSubmitting(false); -// }); -// }; + // const handleSubmit = async (values, props) => { + // await axios + // .post(GET_USER_TOKEN, { + // phone_number: values.phone_number, + // }) + // .then(function (response) { + // setToken(response.data.token); + // }) + // .catch(function (error) { + // Notifications(directionApp, error.response, t); + // props.setSubmitting(false); + // }); + // }; const initialValues = { - username: "", - password: "", + phone_number: "" }; const validationSchema = Yup.object().shape({ - username: Yup.string().required(t("LoginPage.error_message_required")), - password: Yup.string().required(t("LoginPage.error_message_required")), + phone_number: Yup.string().required(t("LoginPage.error_message_required")) }); return ( @@ -82,66 +79,57 @@ const LoginComponent = () => { - - - + + + + + + - - {t("LoginPage.button_make_account")} - - + + diff --git a/src/components/login-welfare-services/index.jsx b/src/components/login-welfare-services/index.jsx index 863f3aa..33dfa38 100644 --- a/src/components/login-welfare-services/index.jsx +++ b/src/components/login-welfare-services/index.jsx @@ -1,6 +1,5 @@ import LinkRouting from "@/core/components/LinkRouting"; // import Notifications from "@/core/components/notifications"; -import PasswordField from "@/core/components/PasswordField"; import StyledForm from "@/core/components/StyledForm"; // import { GET_USER_TOKEN } from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; @@ -13,6 +12,7 @@ import { Box, Button, Container, + Grid, Paper, Stack, TextField, @@ -38,8 +38,7 @@ const LoginComponent = () => { // const handleSubmit = async (values, props) => { // await axios // .post(GET_USER_TOKEN, { - // username: values.username, - // password: values.password, + // phone_number: values.phone_number // }) // .then(function (response) { // setToken(response.data.token); @@ -50,12 +49,10 @@ const LoginComponent = () => { // }); // }; const initialValues = { - username: "", - password: "", + phone_number: "" }; const validationSchema = Yup.object().shape({ - username: Yup.string().required(t("LoginPage.error_message_required")), - password: Yup.string().required(t("LoginPage.error_message_required")), + phone_number: Yup.string().required(t("LoginPage.error_message_required")) }); return ( @@ -82,66 +79,57 @@ const LoginComponent = () => { - - - + + + + + + - - - + + diff --git a/src/components/register-navy/index.jsx b/src/components/register-navy/index.jsx index e69de29..6aa2271 100644 --- a/src/components/register-navy/index.jsx +++ b/src/components/register-navy/index.jsx @@ -0,0 +1,191 @@ +import StyledForm from "@/core/components/StyledForm"; +import { + Box, + Button, + Container, + Paper, + Stack, + Typography, + TextField, +} from "@mui/material"; +import { Field, Formik } from "formik"; +import Image from "next/image"; +import FingerprintIcon from "@mui/icons-material/Fingerprint"; +import FullPageLayout from "@/layouts/FullPageLayout"; +import CenterLayout from "@/layouts/CenterLayout"; +import { useTranslations } from "next-intl"; +import * as Yup from "yup"; +import LinkRouting from "@/core/components/LinkRouting"; +import { useSearchParams } from "next/navigation"; +import useDirection from "@/lib/app/hooks/useDirection"; +import useUser from "@/lib/app/hooks/useUser"; +// import { GET_USER_TOKEN } from "@/core/data/apiRoutes"; +// import axios from "axios"; + +const RegisterNavyComponent = () => { + const t = useTranslations(); + + const { directionApp } = useDirection(); + const { setToken } = useUser(); + + const searchParams = useSearchParams(); + const backUrlDecodedPath = searchParams.get("back_url"); + + const initialValues = { + type_id: "1", + phone_number: "", + national_id: "", + navgan_id: "", + }; + const validationSchema = Yup.object().shape({ + phone_number: Yup.string().required( + t("RegisterPage.error_message_required") + ), + national_id: Yup.string().required( + t("RegisterPage.error_message_required") + ), + navgan_id: Yup.string().required(t("RegisterPage.error_message_required")), + }); + // const handleSubmit = async (values, props) => { + // await axios + // .post(GET_USER_TOKEN, { + // type_id: values.type_id, + // national_id: values.national_id, + // navgan_id: values.navgan_id, + // phone_number: values.phone_number, + // }) + // .then(function (response) { + // setToken(response.data.token); + // }) + // .catch(function (error) { + // Notifications(directionApp, error.response, t); + // props.setSubmitting(false); + // }); + // }; + + return ( + + + + + + {(props) => ( + + + {t("app_name")} + + + {t("register_navy")} + + + + + + + + + + + )} + + + + + + + {t("RegisterPage.link_routing_back_to")}{" "} + {t("RegisterPage.link_routing_login_navy")} + + + + ); +}; + +export default RegisterNavyComponent; diff --git a/src/pages/dashboard/index.jsx b/src/pages/dashboard/index.jsx index 5ebc479..806513c 100644 --- a/src/pages/dashboard/index.jsx +++ b/src/pages/dashboard/index.jsx @@ -6,7 +6,7 @@ import { parse } from "next-useragent"; export default function Dashboard() { return ( - + ); diff --git a/src/pages/register-navy.jsx b/src/pages/register-navy.jsx index 822a82b..7a6512f 100644 --- a/src/pages/register-navy.jsx +++ b/src/pages/register-navy.jsx @@ -1,4 +1,4 @@ -import RegisterComponent from "@/components/register-navy"; +import RegisterNavyComponent from "@/components/register-navy"; import TitlePage from "@/core/components/TitlePage"; import WithoutAuthMiddleware from "@/middlewares/WithoutAuth"; import { parse } from "next-useragent"; @@ -11,7 +11,7 @@ export default function RegisterNavy() { return ( - + {directionApp === "rtl" ? : } ); From 460b46512b7c76b9a8affe0438062bdbe0f4db8c Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Tue, 11 Jul 2023 15:02:13 +0330 Subject: [PATCH 02/54] design loan request page --- public/locales/fa/app.json | 32 +- .../dashboard/loan-request/index.jsx | 441 +++++++++++++++++- src/components/login-navy/index.jsx | 11 +- src/pages/dashboard/loan-follow-up/index.jsx | 2 +- src/pages/dashboard/loan-request/index.jsx | 2 +- 5 files changed, 477 insertions(+), 11 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index d4073b1..07e2420 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -44,9 +44,6 @@ "error_message_required": "اجباری!", "button_make_account": "ایجاد حساب" }, - "Dashboard": { - "dashboard_page": "داشبورد" - }, "RegisterPage": { "link_routing_back_to": "بازگشت به", "link_routing_login_navy": "صفحه ورود", @@ -58,5 +55,34 @@ "text_field_enter_your_navgan_id": "شماره ناوگان خود را وارد کنید", "error_message_required": "اجباری!", "button_request_verification": "دریافت کد یکبارمصرف" + }, + "Dashboard": { + "dashboard_page": "داشبورد" + }, + "LoanFollowUp": { + "loan_follow_up_page": "پیگیری درخواست" + }, + "LoanRequest": { + "loan_request_page": "فرم درخواست وام", + "error_message_required": "اجباری!", + "text_field_phone_number": "شماره تلفن", + "text_field_enter_your_phone_number": "شماره تلفن خود را وارد کنید", + "text_field_first_name": "نام", + "text_field_enter_your_first_name": "نام خود را وارد کنید", + "text_field_last_name": "نام خانوادگی", + "text_field_enter_your_last_name": "نام خانوادگی خود را وارد کنید", + "text_field_vehicle_type": "نام وسیله نقلیه", + "text_field_enter_your_vehicle_type": "نام وسیله نقلیه خود را وارد کنید", + "text_field_province": "استان", + "text_field_enter_your_province": "استان خود را وارد کنید", + "text_field_navgan_id": "شماره ناوگان", + "text_field_enter_your_navgan_id": "شماره ناوگان خود را وارد کنید", + "text_field_national_code": "کد ملی", + "text_field_enter_your_national_code": "کد ملی خود را وارد کنید", + "text_field_birth_certificate_id": "شماره شناسنامه", + "text_field_enter_your_birth_certificate_id": "شماره شناسنامه خود را وارد کنید", + "text_field_plate_number": "شماره پلاک", + "text_field_enter_your_plate_number": "شماره پلاک خود را وارد کنید", + "button_submit": "ثبت درخواست" } } diff --git a/src/components/dashboard/loan-request/index.jsx b/src/components/dashboard/loan-request/index.jsx index b13cf78..385d6dc 100644 --- a/src/components/dashboard/loan-request/index.jsx +++ b/src/components/dashboard/loan-request/index.jsx @@ -1,16 +1,453 @@ +import StyledForm from "@/core/components/StyledForm"; import CenterLayout from "@/layouts/CenterLayout"; import DashboardLayouts from "@/layouts/dashboardLayouts"; import useUser from "@/lib/app/hooks/useUser"; +import { Box, Button, Stack, TextField } from "@mui/material"; +import { Field, Formik } from "formik"; import { useTranslations } from "next-intl"; -import React from "react"; +import Image from "next/image"; +import DataSaverOnIcon from "@mui/icons-material/DataSaverOn"; +import * as Yup from "yup"; const DashboardLoanRequestComponent = () => { const t = useTranslations(); const { token } = useUser(); + + const initialValues = { + first_name: "", + last_name: "", + phone_number: "", + vehicle_type: "", + plate_number: "", + province: "", + navgan_id: "", + national_code: "", + birth_certificate_id: "", + national_card_img: "", + birth_certificate_img: "", + }; + + const validationSchema = Yup.object().shape({ + first_name: Yup.string().required(t("LoanRequest.error_message_required")), + last_name: Yup.string().required(t("LoanRequest.error_message_required")), + phone_number: Yup.string().required( + t("LoanRequest.error_message_required") + ), + vehicle_type: Yup.string().required( + t("LoanRequest.error_message_required") + ), + plate_number: Yup.string().required( + t("LoanRequest.error_message_required") + ), + province: Yup.string().required(t("LoanRequest.error_message_required")), + navgan_id: Yup.string().required(t("LoanRequest.error_message_required")), + national_code: Yup.string().required( + t("LoanRequest.error_message_required") + ), + birth_certificate_id: Yup.string().required( + t("LoanRequest.error_message_required") + ), + }); + return ( -

نکنه وامم میخوای؟؟؟

+ + {(props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {t("app_name")} + + + {t("app_name")} + + + + + + + + )} +
); diff --git a/src/components/login-navy/index.jsx b/src/components/login-navy/index.jsx index 8f1cbbd..e3fd879 100644 --- a/src/components/login-navy/index.jsx +++ b/src/components/login-navy/index.jsx @@ -49,10 +49,10 @@ const LoginComponent = () => { // }); // }; const initialValues = { - phone_number: "" + phone_number: "", }; const validationSchema = Yup.object().shape({ - phone_number: Yup.string().required(t("LoginPage.error_message_required")) + phone_number: Yup.string().required(t("LoginPage.error_message_required")), }); return ( @@ -87,13 +87,16 @@ const LoginComponent = () => { )} type={"text"} error={ - props.touched.phone_number && props.errors.phone_number + props.touched.phone_number && + props.errors.phone_number ? true : false } fullWidth helperText={ - props.touched.phone_number ? props.errors.phone_number : null + props.touched.phone_number + ? props.errors.phone_number + : null } /> - + ); diff --git a/src/pages/dashboard/loan-request/index.jsx b/src/pages/dashboard/loan-request/index.jsx index b76f172..f66f9fb 100644 --- a/src/pages/dashboard/loan-request/index.jsx +++ b/src/pages/dashboard/loan-request/index.jsx @@ -6,7 +6,7 @@ import { parse } from "next-useragent"; export default function LoanRequest() { return ( - + ); From 6c32a374def81a20f0d0ccafc66e431c623494f1 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Wed, 12 Jul 2023 14:43:54 +0330 Subject: [PATCH 03/54] complete implemention and design of login and register navgan users --- public/locales/fa/app.json | 10 +- .../dashboard/loan-request/index.jsx | 2 + src/components/login-navy/SendToken.jsx | 130 +++++++++++ src/components/login-navy/SendUserData.jsx | 164 ++++++++++++++ src/components/login-navy/index.jsx | 167 +------------- .../login-welfare-services/index.jsx | 16 +- .../login-welfare-services/sendToken.jsx | 0 src/components/register-navy/SendToken.jsx | 127 +++++++++++ src/components/register-navy/SendUserData.jsx | 195 ++++++++++++++++ src/components/register-navy/index.jsx | 213 +++--------------- .../register-welfare-services/index.jsx | 169 ++++++++++++++ .../register-welfare-services/sendToken.jsx | 0 src/core/data/apiRoutes.js | 9 + src/lib/app/contexts/user.jsx | 29 +-- 14 files changed, 859 insertions(+), 372 deletions(-) create mode 100644 src/components/login-navy/SendToken.jsx create mode 100644 src/components/login-navy/SendUserData.jsx create mode 100644 src/components/login-welfare-services/sendToken.jsx create mode 100644 src/components/register-navy/SendToken.jsx create mode 100644 src/components/register-navy/SendUserData.jsx create mode 100644 src/components/register-welfare-services/sendToken.jsx diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 07e2420..b1e8c16 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -37,24 +37,30 @@ "LoginPage": { "text_field_phone_number": "شماره تلفن", "text_field_enter_your_phone_number": "شماره تلفن خود را وارد کنید", + "text_field_verification_code": "کد یکبار مصرف", + "text_field_enter_your_verification_code": "کد یکبار مصرف خود را وارد کنید", "button_submit": "ورود", "link_routing_back_to": "بازگشت به", "link_routing_previuos_page": "صفحه قبل", "link_routing_main_page": "صفحه اصلی", "error_message_required": "اجباری!", - "button_make_account": "ایجاد حساب" + "button_make_account": "ایجاد حساب", + "button_request_verification": "دریافت کد یکبارمصرف" }, "RegisterPage": { "link_routing_back_to": "بازگشت به", "link_routing_login_navy": "صفحه ورود", "text_field_phone_number": "شماره تلفن", "text_field_enter_your_phone_number": "شماره تلفن خود را وارد کنید", + "text_field_verification_code": "کد یکبار مصرف", + "text_field_enter_your_verification_code": "کد یکبار مصرف خود را وارد کنید", "text_field_national_id": "کد ملی", "text_field_enter_your_national_id": "کد ملی خود را وارد کنید", "text_field_navgan_id": "شماره ناوگان", "text_field_enter_your_navgan_id": "شماره ناوگان خود را وارد کنید", "error_message_required": "اجباری!", - "button_request_verification": "دریافت کد یکبارمصرف" + "button_request_verification": "دریافت کد یکبارمصرف", + "button_submit": "ورود" }, "Dashboard": { "dashboard_page": "داشبورد" diff --git a/src/components/dashboard/loan-request/index.jsx b/src/components/dashboard/loan-request/index.jsx index 385d6dc..b51837c 100644 --- a/src/components/dashboard/loan-request/index.jsx +++ b/src/components/dashboard/loan-request/index.jsx @@ -412,6 +412,7 @@ const DashboardLoanRequestComponent = () => { width={300} height={300} src="/images/login.svg" + priority alt={t("app_name")} /> @@ -420,6 +421,7 @@ const DashboardLoanRequestComponent = () => { width={300} height={300} src="/images/login.svg" + priority alt={t("app_name")} /> diff --git a/src/components/login-navy/SendToken.jsx b/src/components/login-navy/SendToken.jsx new file mode 100644 index 0000000..d7fb84b --- /dev/null +++ b/src/components/login-navy/SendToken.jsx @@ -0,0 +1,130 @@ +// import Notifications from "@/core/components/notifications"; +import StyledForm from "@/core/components/StyledForm"; +import { LOGIN } from "@/core/data/apiRoutes"; +import CenterLayout from "@/layouts/CenterLayout"; +import FullPageLayout from "@/layouts/FullPageLayout"; +import useDirection from "@/lib/app/hooks/useDirection"; +import useUser from "@/lib/app/hooks/useUser"; +import LoginIcon from "@mui/icons-material/Login"; +import { + Box, + Button, + Container, + Grid, + Paper, + Stack, + TextField, + Typography +} from "@mui/material"; +import axios from "axios"; +import { Field, Formik } from "formik"; +import { useTranslations } from "next-intl"; +import Image from "next/image"; +import * as Yup from "yup"; + +const SendToken = ({ PhoneNumber }) => { + const t = useTranslations(); + const { directionApp } = useDirection(); + const { setToken } = useUser(); + + const initialValues = { + phone_number: PhoneNumber, + verification_code: "", + }; + const validationSchema = Yup.object().shape({ + verification_code: Yup.string().required( + t("LoginPage.error_message_required") + ), + }); + + const handleSubmit = async (values, props) => { + await axios + .post(LOGIN, { + phone_number: values.phone_number, + verification_code: values.verification_code, + }) + .then(function (response) { + setToken(response.data.token); + }) + .catch(function (error) { + Notifications(directionApp, error.response, t); + props.setSubmitting(false); + }); + }; + + return ( + + + + + + {(props) => ( + + + {t("app_name")} + + + {t("login_navy")} + + + + + + + + + + + + + )} + + + + + + ); +}; + +export default SendToken; diff --git a/src/components/login-navy/SendUserData.jsx b/src/components/login-navy/SendUserData.jsx new file mode 100644 index 0000000..c3197b8 --- /dev/null +++ b/src/components/login-navy/SendUserData.jsx @@ -0,0 +1,164 @@ +// import Notifications from "@/core/components/notifications"; +import LinkRouting from "@/core/components/LinkRouting"; +import StyledForm from "@/core/components/StyledForm"; +import { LOGIN_SEND_OTP_TOKEN } from "@/core/data/apiRoutes"; +import CenterLayout from "@/layouts/CenterLayout"; +import FullPageLayout from "@/layouts/FullPageLayout"; +import useDirection from "@/lib/app/hooks/useDirection"; +import FingerprintIcon from "@mui/icons-material/Fingerprint"; +import PersonAddIcon from "@mui/icons-material/PersonAdd"; +import { + Box, + Button, + Container, + Grid, + Paper, + Stack, + TextField, + Typography +} from "@mui/material"; +import axios from "axios"; +import { Field, Formik } from "formik"; +import { useTranslations } from "next-intl"; +import Image from "next/image"; +import { useSearchParams } from "next/navigation"; +import * as Yup from "yup"; + +const SendUserData = ({ setOtpToken, setPhoneNumber }) => { + const t = useTranslations(); + const { directionApp } = useDirection(); + + const searchParams = useSearchParams(); + const backUrlDecodedPath = searchParams.get("back_url"); + + const initialValues = { + phone_number: "", + }; + const validationSchema = Yup.object().shape({ + phone_number: Yup.string().required(t("LoginPage.error_message_required")), + }); + + const handleSubmit = async (values, props) => { + await axios + .post(LOGIN_SEND_OTP_TOKEN, { + phone_number: values.phone_number, + }) + .then(function (response) { + setPhoneNumber(values.phone_number); + setOtpToken(true); + }) + .catch(function (error) { + // Notifications(directionApp, error.response, t); + props.setSubmitting(false); + }); + }; + + return ( + + + + + + {(props) => ( + + + {t("app_name")} + + + {t("login_navy")} + + + + + + + + + + + + + + + + + + )} + + + + + + + {t("LoginPage.link_routing_back_to")}{" "} + {backUrlDecodedPath + ? t("LoginPage.link_routing_previuos_page") + : t("LoginPage.link_routing_main_page")} + + + + ); +}; + +export default SendUserData; diff --git a/src/components/login-navy/index.jsx b/src/components/login-navy/index.jsx index e3fd879..ba30668 100644 --- a/src/components/login-navy/index.jsx +++ b/src/components/login-navy/index.jsx @@ -1,161 +1,18 @@ -import LinkRouting from "@/core/components/LinkRouting"; -// import Notifications from "@/core/components/notifications"; -import StyledForm from "@/core/components/StyledForm"; -// import { GET_USER_TOKEN } from "@/core/data/apiRoutes"; -import CenterLayout from "@/layouts/CenterLayout"; -import FullPageLayout from "@/layouts/FullPageLayout"; -import useDirection from "@/lib/app/hooks/useDirection"; -import useUser from "@/lib/app/hooks/useUser"; -import LoginIcon from "@mui/icons-material/Login"; -import PersonAddIcon from "@mui/icons-material/PersonAdd"; -import { - Box, - Button, - Container, - Grid, - Paper, - Stack, - TextField, - Typography, -} from "@mui/material"; -// import axios from "axios"; -import { Field, Formik } from "formik"; -import { useTranslations } from "next-intl"; -import Image from "next/image"; -import { useSearchParams } from "next/navigation"; -import * as Yup from "yup"; +import SendUserData from "./SendUserData"; +import { useState } from "react"; +import SendToken from "./SendToken"; const LoginComponent = () => { - const t = useTranslations(); - const { directionApp } = useDirection(); - const { setToken } = useUser(); // pass token to set token + const [otpToken, setOtpToken] = useState(false); + const [PhoneNumber, setPhoneNumber] = useState(""); - // gettin url query - const searchParams = useSearchParams(); - const backUrlDecodedPath = searchParams.get("back_url"); - - // formik properties - // const handleSubmit = async (values, props) => { - // await axios - // .post(GET_USER_TOKEN, { - // phone_number: values.phone_number, - // }) - // .then(function (response) { - // setToken(response.data.token); - // }) - // .catch(function (error) { - // Notifications(directionApp, error.response, t); - // props.setSubmitting(false); - // }); - // }; - const initialValues = { - phone_number: "", - }; - const validationSchema = Yup.object().shape({ - phone_number: Yup.string().required(t("LoginPage.error_message_required")), - }); - - return ( - - - - - - {(props) => ( - - - {t("app_name")} - - - {t("login_navy")} - - - - - - - - - - - - - - - - - - )} - - - - - - - {t("LoginPage.link_routing_back_to")}{" "} - {backUrlDecodedPath - ? t("LoginPage.link_routing_previuos_page") - : t("LoginPage.link_routing_main_page")} - - - - ); + if (!otpToken) { + return ( + + ); + } else { + return ; + } }; export default LoginComponent; diff --git a/src/components/login-welfare-services/index.jsx b/src/components/login-welfare-services/index.jsx index 33dfa38..3ec6b1b 100644 --- a/src/components/login-welfare-services/index.jsx +++ b/src/components/login-welfare-services/index.jsx @@ -70,7 +70,12 @@ const LoginComponent = () => { - {t("app_name")} + {t("app_name")} {t("login_welfare_services")} @@ -87,13 +92,16 @@ const LoginComponent = () => { )} type={"text"} error={ - props.touched.phone_number && props.errors.phone_number + props.touched.phone_number && + props.errors.phone_number ? true : false } fullWidth helperText={ - props.touched.phone_number ? props.errors.phone_number : null + props.touched.phone_number + ? props.errors.phone_number + : null } /> { }} > - + + + + + )} + + + + + + ); +}; + +export default SendToken; diff --git a/src/components/register-navy/SendUserData.jsx b/src/components/register-navy/SendUserData.jsx new file mode 100644 index 0000000..8766d44 --- /dev/null +++ b/src/components/register-navy/SendUserData.jsx @@ -0,0 +1,195 @@ +import LinkRouting from "@/core/components/LinkRouting"; +import StyledForm from "@/core/components/StyledForm"; +import { REGISTER_SEND_OTP_TOKEN } from "@/core/data/apiRoutes"; +import CenterLayout from "@/layouts/CenterLayout"; +import FullPageLayout from "@/layouts/FullPageLayout"; +import FingerprintIcon from "@mui/icons-material/Fingerprint"; +import { + Box, + Button, + Container, + Paper, + Stack, TextField, Typography +} from "@mui/material"; +import axios from "axios"; +import { Field, Formik } from "formik"; +import { useTranslations } from "next-intl"; +import Image from "next/image"; +import { useSearchParams } from "next/navigation"; +import * as Yup from "yup"; + +const SendUserData = ({ + setOtpToken, + setPhoneNumber, + setNationalId, + setNavganId, + setTypeId, +}) => { + const t = useTranslations(); + + const searchParams = useSearchParams(); + const backUrlDecodedPath = searchParams.get("back_url"); + + const initialValues = { + type_id: "1", + phone_number: "", + national_id: "", + navgan_id: "", + }; + const validationSchema = Yup.object().shape({ + phone_number: Yup.string().required( + t("RegisterPage.error_message_required") + ), + national_id: Yup.string().required( + t("RegisterPage.error_message_required") + ), + navgan_id: Yup.string().required(t("RegisterPage.error_message_required")), + }); + + const handleSubmit = async (values, props) => { + await axios + .post(REGISTER_SEND_OTP_TOKEN, { + type_id: values.type_id, + national_id: values.national_id, + navgan_id: values.navgan_id, + phone_number: values.phone_number, + }) + .then(function (response) { + setPhoneNumber(values.phone_number); + setNationalId(values.national_id); + setNavganId(values.navgan_id); + setTypeId(values.type_id); + setOtpToken(true) + }) + .catch(function (error) { + Notifications(directionApp, error.response, t); + props.setSubmitting(false); + }); + }; + + return ( + + + + + + {(props) => ( + + + {t("app_name")} + + + {t("register_navy")} + + + + + + + + + + + )} + + + + + + + {t("RegisterPage.link_routing_back_to")}{" "} + {t("RegisterPage.link_routing_login_navy")} + + + + ); +}; + +export default SendUserData; diff --git a/src/components/register-navy/index.jsx b/src/components/register-navy/index.jsx index 6aa2271..7a136c7 100644 --- a/src/components/register-navy/index.jsx +++ b/src/components/register-navy/index.jsx @@ -1,191 +1,34 @@ -import StyledForm from "@/core/components/StyledForm"; -import { - Box, - Button, - Container, - Paper, - Stack, - Typography, - TextField, -} from "@mui/material"; -import { Field, Formik } from "formik"; -import Image from "next/image"; -import FingerprintIcon from "@mui/icons-material/Fingerprint"; -import FullPageLayout from "@/layouts/FullPageLayout"; -import CenterLayout from "@/layouts/CenterLayout"; -import { useTranslations } from "next-intl"; -import * as Yup from "yup"; -import LinkRouting from "@/core/components/LinkRouting"; -import { useSearchParams } from "next/navigation"; -import useDirection from "@/lib/app/hooks/useDirection"; -import useUser from "@/lib/app/hooks/useUser"; -// import { GET_USER_TOKEN } from "@/core/data/apiRoutes"; -// import axios from "axios"; +import { useState } from "react"; +import SendToken from "./SendToken"; +import SendUserData from "./SendUserData"; const RegisterNavyComponent = () => { - const t = useTranslations(); + const [otpToken, setOtpToken] = useState(false); + const [PhoneNumber, setPhoneNumber] = useState(""); + const [nationalId, setNationalId] = useState(""); + const [navganId, setNavganId] = useState(""); + const [typeId, setTypeId] = useState(""); - const { directionApp } = useDirection(); - const { setToken } = useUser(); - - const searchParams = useSearchParams(); - const backUrlDecodedPath = searchParams.get("back_url"); - - const initialValues = { - type_id: "1", - phone_number: "", - national_id: "", - navgan_id: "", - }; - const validationSchema = Yup.object().shape({ - phone_number: Yup.string().required( - t("RegisterPage.error_message_required") - ), - national_id: Yup.string().required( - t("RegisterPage.error_message_required") - ), - navgan_id: Yup.string().required(t("RegisterPage.error_message_required")), - }); - // const handleSubmit = async (values, props) => { - // await axios - // .post(GET_USER_TOKEN, { - // type_id: values.type_id, - // national_id: values.national_id, - // navgan_id: values.navgan_id, - // phone_number: values.phone_number, - // }) - // .then(function (response) { - // setToken(response.data.token); - // }) - // .catch(function (error) { - // Notifications(directionApp, error.response, t); - // props.setSubmitting(false); - // }); - // }; - - return ( - - - - - - {(props) => ( - - - {t("app_name")} - - - {t("register_navy")} - - - - - - - - - - - )} - - - - - - - {t("RegisterPage.link_routing_back_to")}{" "} - {t("RegisterPage.link_routing_login_navy")} - - - - ); + if (!otpToken) { + return ( + + ); + } else { + return ( + + ); + } }; export default RegisterNavyComponent; diff --git a/src/components/register-welfare-services/index.jsx b/src/components/register-welfare-services/index.jsx index e69de29..b9a35c5 100644 --- a/src/components/register-welfare-services/index.jsx +++ b/src/components/register-welfare-services/index.jsx @@ -0,0 +1,169 @@ +import StyledForm from "@/core/components/StyledForm"; +import { + Box, + Button, + Container, + Paper, + Stack, + Typography, + TextField, +} from "@mui/material"; +import { Field, Formik } from "formik"; +import Image from "next/image"; +import FingerprintIcon from "@mui/icons-material/Fingerprint"; +import FullPageLayout from "@/layouts/FullPageLayout"; +import CenterLayout from "@/layouts/CenterLayout"; +import { useTranslations } from "next-intl"; +import * as Yup from "yup"; +import LinkRouting from "@/core/components/LinkRouting"; +import { useSearchParams } from "next/navigation"; +import useDirection from "@/lib/app/hooks/useDirection"; +import useUser from "@/lib/app/hooks/useUser"; +// import { GET_USER_TOKEN } from "@/core/data/apiRoutes"; +// import axios from "axios"; + +const RegisterNavyComponent = () => { + const t = useTranslations(); + + const { directionApp } = useDirection(); + const { setToken } = useUser(); + + const searchParams = useSearchParams(); + const backUrlDecodedPath = searchParams.get("back_url"); + + const initialValues = { + type_id: "2", + phone_number: "", + national_id: "", + navgan_id: "", + }; + const validationSchema = Yup.object().shape({ + phone_number: Yup.string().required( + t("RegisterPage.error_message_required") + ), + national_id: Yup.string().required( + t("RegisterPage.error_message_required") + ), + }); + // const handleSubmit = async (values, props) => { + // await axios + // .post(GET_USER_TOKEN, { + // type_id: values.type_id, + // national_id: values.national_id, + // navgan_id: values.navgan_id, + // phone_number: values.phone_number, + // }) + // .then(function (response) { + // setToken(response.data.token); + // }) + // .catch(function (error) { + // Notifications(directionApp, error.response, t); + // props.setSubmitting(false); + // }); + // }; + + return ( + + + + + + {(props) => ( + + + {t("app_name")} + + + {t("register_navy")} + + + + + + + + + + )} + + + + + + + {t("RegisterPage.link_routing_back_to")}{" "} + {t("RegisterPage.link_routing_login_navy")} + + + + ); +}; + +export default RegisterNavyComponent; diff --git a/src/components/register-welfare-services/sendToken.jsx b/src/components/register-welfare-services/sendToken.jsx new file mode 100644 index 0000000..e69de29 diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index e69de29..bd04212 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -0,0 +1,9 @@ +const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL + "/api"; + +export const LOGIN_SEND_OTP_TOKEN = BASE_URL + "/login/send_otp"; +export const LOGIN = BASE_URL + "/login"; +export const REGISTER_SEND_OTP_TOKEN = BASE_URL + "/register/send_otp"; +export const REGISTER = BASE_URL + "/register"; +export const USER_INFO = BASE_URL + "/hamidGiveme"; + + diff --git a/src/lib/app/contexts/user.jsx b/src/lib/app/contexts/user.jsx index 49d55af..e859c58 100644 --- a/src/lib/app/contexts/user.jsx +++ b/src/lib/app/contexts/user.jsx @@ -1,7 +1,4 @@ -import { - GET_USER_ROUTE, - SET_LANGUAGE -} from "@/core/data/apiRoutes"; +import { USER_INFO } from "@/core/data/apiRoutes"; import axios from "axios"; import { createContext, useCallback, useEffect, useReducer } from "react"; @@ -51,27 +48,7 @@ export const UserProvider = ({ children }) => { dispatch({ type: "CHANGE_USER", user }); }, []); - const changeUserLanguage = useCallback( - (language) => { - dispatch({ type: "CHANGE_USER_LANGUAGE", language }); - axios - .post( - SET_LANGUAGE, - { language: language }, - { - headers: { - authorization: `Bearer ${state.token}`, - }, - } - ) - .then(() => { - getUser((data) => { - changeUser(data); - }); - }); - }, - [state.token] - ); + const changeUserLanguage = useCallback(/* for multi language app */); const changeAuthState = useCallback((isAuth) => { dispatch({ type: "CHANGE_AUTH_STATE", isAuth }); @@ -92,7 +69,7 @@ export const UserProvider = ({ children }) => { const getUser = useCallback( (callback = () => {}) => { axios - .get(GET_USER_ROUTE, { + .get(USER_INFO, { headers: { authorization: `Bearer ${state.token}` }, }) .then(({ data }) => { From 69b97b8fe2938b117a463808902fedaf1f8e5877 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Wed, 12 Jul 2023 15:28:45 +0330 Subject: [PATCH 04/54] authorization of users --- public/images/loading.svg | 1 + public/images/logo.svg | 10 ---------- src/core/components/LoadingHardPage.jsx | 2 +- src/core/components/Messages.jsx | 2 +- src/core/data/apiRoutes.js | 2 +- src/middlewares/WithAuth.jsx | 5 ++--- src/middlewares/WithoutAuth.jsx | 8 ++++---- src/pages/dashboard/index.jsx | 2 +- src/pages/dashboard/loan-follow-up/index.jsx | 2 +- src/pages/dashboard/loan-request/index.jsx | 2 +- 10 files changed, 13 insertions(+), 23 deletions(-) create mode 100644 public/images/loading.svg delete mode 100644 public/images/logo.svg diff --git a/public/images/loading.svg b/public/images/loading.svg new file mode 100644 index 0000000..03b8908 --- /dev/null +++ b/public/images/loading.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/images/logo.svg b/public/images/logo.svg deleted file mode 100644 index 5931dd4..0000000 --- a/public/images/logo.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - MARHABA - - diff --git a/src/core/components/LoadingHardPage.jsx b/src/core/components/LoadingHardPage.jsx index 5da632d..01ce658 100644 --- a/src/core/components/LoadingHardPage.jsx +++ b/src/core/components/LoadingHardPage.jsx @@ -28,7 +28,7 @@ const LoadingHardPage = ({ children, loading }) => { > { { text={ {t( - "typography_your_access_to_this_page_has_expired_Please_login_again" + "Authorization.typography_your_access_to_this_page_has_expired_Please_login_again" )} } @@ -26,8 +26,7 @@ const WithAuthMiddleware = ({ children }) => { variant="contained" component={NextLinkComposed} to={{ - pathname: "/login", - query: { back_url: encodeURIComponent(router.asPath) }, + pathname: "/", }} > {t("login")} diff --git a/src/middlewares/WithoutAuth.jsx b/src/middlewares/WithoutAuth.jsx index 5fb4f93..cb8e571 100644 --- a/src/middlewares/WithoutAuth.jsx +++ b/src/middlewares/WithoutAuth.jsx @@ -37,14 +37,14 @@ const WithoutAuthMiddleware = ({ children }) => { {t( - "typography_your_login_is_valid_and_you_do_not_need_to_login_again" + "Authorization.typography_your_login_is_valid_and_you_do_not_need_to_login_again" )} - {t("typography_redirect_to")}{" "} + {t("Authorization.typography_redirect_to")}{" "} {backUrlDecodedPath - ? t("typography_routing_previuos_page") - : t("typography_routing_dashbaord_page")} + ? t("Authorization.typography_routing_previuos_page") + : t("Authorization.typography_routing_dashbaord_page")} } diff --git a/src/pages/dashboard/index.jsx b/src/pages/dashboard/index.jsx index 806513c..c3c3933 100644 --- a/src/pages/dashboard/index.jsx +++ b/src/pages/dashboard/index.jsx @@ -1,6 +1,6 @@ import DashboardFirstComponent from "@/components/dashboard/first"; import TitlePage from "@/core/components/TitlePage"; -import WithAuthMiddleware from "@/middlewares/WithoutAuth"; +import WithAuthMiddleware from "@/middlewares/WithAuth"; import { parse } from "next-useragent"; export default function Dashboard() { diff --git a/src/pages/dashboard/loan-follow-up/index.jsx b/src/pages/dashboard/loan-follow-up/index.jsx index 46c9440..89a441d 100644 --- a/src/pages/dashboard/loan-follow-up/index.jsx +++ b/src/pages/dashboard/loan-follow-up/index.jsx @@ -1,6 +1,6 @@ import DashboardLoanFollowUpComponent from "@/components/dashboard/loan-follow-up"; import TitlePage from "@/core/components/TitlePage"; -import WithAuthMiddleware from "@/middlewares/WithoutAuth"; +import WithAuthMiddleware from "@/middlewares/WithAuth"; import { parse } from "next-useragent"; export default function LoanFollowUp() { diff --git a/src/pages/dashboard/loan-request/index.jsx b/src/pages/dashboard/loan-request/index.jsx index f66f9fb..962d662 100644 --- a/src/pages/dashboard/loan-request/index.jsx +++ b/src/pages/dashboard/loan-request/index.jsx @@ -1,6 +1,6 @@ import DashboardLoanRequestComponent from "@/components/dashboard/loan-request"; import TitlePage from "@/core/components/TitlePage"; -import WithAuthMiddleware from "@/middlewares/WithoutAuth"; +import WithAuthMiddleware from "@/middlewares/WithAuth"; import { parse } from "next-useragent"; export default function LoanRequest() { From b01052bc8c683c75e540b44a9110616bd56212a0 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Wed, 12 Jul 2023 16:26:25 +0330 Subject: [PATCH 05/54] complete login and register implemention of welfare services --- public/locales/fa/app.json | 2 +- .../login-welfare-services/SendUserData.jsx | 164 +++++++++++++++ .../login-welfare-services/index.jsx | 172 ++-------------- .../login-welfare-services/sendToken.jsx | 130 ++++++++++++ .../SendUserData.jsx | 171 ++++++++++++++++ .../register-welfare-services/index.jsx | 189 +++--------------- .../register-welfare-services/sendToken.jsx | 127 ++++++++++++ 7 files changed, 631 insertions(+), 324 deletions(-) create mode 100644 src/components/login-welfare-services/SendUserData.jsx create mode 100644 src/components/register-welfare-services/SendUserData.jsx diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index b1e8c16..af54719 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -7,7 +7,7 @@ "login_navy": "ورود اعضای ناوگان", "register_navy": "ثبت نام اعضای ناوگان", "login_welfare_services": "ورود اعضای خدمات رفاهی", - "user_welfare_services": "خدمات رفاهی", + "register_welfare_services": "ثبت نام اعضای خدمات رفاهی", "user_navy": "ناوگان", "header": { "open_profile": "پروفایل", diff --git a/src/components/login-welfare-services/SendUserData.jsx b/src/components/login-welfare-services/SendUserData.jsx new file mode 100644 index 0000000..ec8072f --- /dev/null +++ b/src/components/login-welfare-services/SendUserData.jsx @@ -0,0 +1,164 @@ +// import Notifications from "@/core/components/notifications"; +import LinkRouting from "@/core/components/LinkRouting"; +import StyledForm from "@/core/components/StyledForm"; +import { LOGIN_SEND_OTP_TOKEN } from "@/core/data/apiRoutes"; +import CenterLayout from "@/layouts/CenterLayout"; +import FullPageLayout from "@/layouts/FullPageLayout"; +import useDirection from "@/lib/app/hooks/useDirection"; +import FingerprintIcon from "@mui/icons-material/Fingerprint"; +import PersonAddIcon from "@mui/icons-material/PersonAdd"; +import { + Box, + Button, + Container, + Grid, + Paper, + Stack, + TextField, + Typography, +} from "@mui/material"; +import axios from "axios"; +import { Field, Formik } from "formik"; +import { useTranslations } from "next-intl"; +import Image from "next/image"; +import { useSearchParams } from "next/navigation"; +import * as Yup from "yup"; + +const SendUserData = ({ setOtpToken, setPhoneNumber }) => { + const t = useTranslations(); + const { directionApp } = useDirection(); + + const searchParams = useSearchParams(); + const backUrlDecodedPath = searchParams.get("back_url"); + + const initialValues = { + phone_number: "", + }; + const validationSchema = Yup.object().shape({ + phone_number: Yup.string().required(t("LoginPage.error_message_required")), + }); + + const handleSubmit = async (values, props) => { + await axios + .post(LOGIN_SEND_OTP_TOKEN, { + phone_number: values.phone_number, + }) + .then(function (response) { + setPhoneNumber(values.phone_number); + setOtpToken(true); + }) + .catch(function (error) { + // Notifications(directionApp, error.response, t); + props.setSubmitting(false); + }); + }; + + return ( + + + + + + {(props) => ( + + + {t("app_name")} + + + {t("login_welfare_services")} + + + + + + + + + + + + + + + + + + )} + + + + + + + {t("LoginPage.link_routing_back_to")}{" "} + {backUrlDecodedPath + ? t("LoginPage.link_routing_previuos_page") + : t("LoginPage.link_routing_main_page")} + + + + ); +}; + +export default SendUserData; diff --git a/src/components/login-welfare-services/index.jsx b/src/components/login-welfare-services/index.jsx index 3ec6b1b..ba30668 100644 --- a/src/components/login-welfare-services/index.jsx +++ b/src/components/login-welfare-services/index.jsx @@ -1,166 +1,18 @@ -import LinkRouting from "@/core/components/LinkRouting"; -// import Notifications from "@/core/components/notifications"; -import StyledForm from "@/core/components/StyledForm"; -// import { GET_USER_TOKEN } from "@/core/data/apiRoutes"; -import CenterLayout from "@/layouts/CenterLayout"; -import FullPageLayout from "@/layouts/FullPageLayout"; -import useDirection from "@/lib/app/hooks/useDirection"; -import useUser from "@/lib/app/hooks/useUser"; -import LoginIcon from "@mui/icons-material/Login"; -import PersonAddIcon from "@mui/icons-material/PersonAdd"; -import { - Box, - Button, - Container, - Grid, - Paper, - Stack, - TextField, - Typography, -} from "@mui/material"; -// import axios from "axios"; -import { Field, Formik } from "formik"; -import { useTranslations } from "next-intl"; -import Image from "next/image"; -import { useSearchParams } from "next/navigation"; -import * as Yup from "yup"; +import SendUserData from "./SendUserData"; +import { useState } from "react"; +import SendToken from "./SendToken"; const LoginComponent = () => { - const t = useTranslations(); - const { directionApp } = useDirection(); - const { setToken } = useUser(); // pass token to set token + const [otpToken, setOtpToken] = useState(false); + const [PhoneNumber, setPhoneNumber] = useState(""); - // gettin url query - const searchParams = useSearchParams(); - const backUrlDecodedPath = searchParams.get("back_url"); - - // formik properties - // const handleSubmit = async (values, props) => { - // await axios - // .post(GET_USER_TOKEN, { - // phone_number: values.phone_number - // }) - // .then(function (response) { - // setToken(response.data.token); - // }) - // .catch(function (error) { - // Notifications(directionApp, error.response, t); - // props.setSubmitting(false); - // }); - // }; - const initialValues = { - phone_number: "" - }; - const validationSchema = Yup.object().shape({ - phone_number: Yup.string().required(t("LoginPage.error_message_required")) - }); - - return ( - - - - - - {(props) => ( - - - {t("app_name")} - - - {t("login_welfare_services")} - - - - - - - - - - - - - - - - - - )} - - - - - - - {t("LoginPage.link_routing_back_to")}{" "} - {backUrlDecodedPath - ? t("LoginPage.link_routing_previuos_page") - : t("LoginPage.link_routing_main_page")} - - - - ); + if (!otpToken) { + return ( + + ); + } else { + return ; + } }; export default LoginComponent; diff --git a/src/components/login-welfare-services/sendToken.jsx b/src/components/login-welfare-services/sendToken.jsx index e69de29..00414b7 100644 --- a/src/components/login-welfare-services/sendToken.jsx +++ b/src/components/login-welfare-services/sendToken.jsx @@ -0,0 +1,130 @@ +// import Notifications from "@/core/components/notifications"; +import StyledForm from "@/core/components/StyledForm"; +import { LOGIN } from "@/core/data/apiRoutes"; +import CenterLayout from "@/layouts/CenterLayout"; +import FullPageLayout from "@/layouts/FullPageLayout"; +import useDirection from "@/lib/app/hooks/useDirection"; +import useUser from "@/lib/app/hooks/useUser"; +import LoginIcon from "@mui/icons-material/Login"; +import { + Box, + Button, + Container, + Grid, + Paper, + Stack, + TextField, + Typography, +} from "@mui/material"; +import axios from "axios"; +import { Field, Formik } from "formik"; +import { useTranslations } from "next-intl"; +import Image from "next/image"; +import * as Yup from "yup"; + +const SendToken = ({ PhoneNumber }) => { + const t = useTranslations(); + const { directionApp } = useDirection(); + const { setToken } = useUser(); + + const initialValues = { + phone_number: PhoneNumber, + verification_code: "", + }; + const validationSchema = Yup.object().shape({ + verification_code: Yup.string().required( + t("LoginPage.error_message_required") + ), + }); + + const handleSubmit = async (values, props) => { + await axios + .post(LOGIN, { + phone_number: values.phone_number, + verification_code: values.verification_code, + }) + .then(function (response) { + setToken(response.data.token); + }) + .catch(function (error) { + Notifications(directionApp, error.response, t); + props.setSubmitting(false); + }); + }; + + return ( + + + + + + {(props) => ( + + + {t("app_name")} + + + {t("login_navy")} + + + + + + + + + + + + + )} + + + + + + ); +}; + +export default SendToken; diff --git a/src/components/register-welfare-services/SendUserData.jsx b/src/components/register-welfare-services/SendUserData.jsx new file mode 100644 index 0000000..ddf4933 --- /dev/null +++ b/src/components/register-welfare-services/SendUserData.jsx @@ -0,0 +1,171 @@ +import LinkRouting from "@/core/components/LinkRouting"; +import StyledForm from "@/core/components/StyledForm"; +import { REGISTER_SEND_OTP_TOKEN } from "@/core/data/apiRoutes"; +import CenterLayout from "@/layouts/CenterLayout"; +import FullPageLayout from "@/layouts/FullPageLayout"; +import FingerprintIcon from "@mui/icons-material/Fingerprint"; +import { + Box, + Button, + Container, + Paper, + Stack, + TextField, + Typography, +} from "@mui/material"; +import axios from "axios"; +import { Field, Formik } from "formik"; +import { useTranslations } from "next-intl"; +import Image from "next/image"; +import { useSearchParams } from "next/navigation"; +import * as Yup from "yup"; + +const SendUserData = ({ + setOtpToken, + setPhoneNumber, + setNationalId, + setTypeId, +}) => { + const t = useTranslations(); + + const searchParams = useSearchParams(); + const backUrlDecodedPath = searchParams.get("back_url"); + + const initialValues = { + type_id: "2", + phone_number: "", + national_id: "", + }; + const validationSchema = Yup.object().shape({ + phone_number: Yup.string().required( + t("RegisterPage.error_message_required") + ), + national_id: Yup.string().required( + t("RegisterPage.error_message_required") + ), + }); + + const handleSubmit = async (values, props) => { + await axios + .post(REGISTER_SEND_OTP_TOKEN, { + type_id: values.type_id, + national_id: values.national_id, + phone_number: values.phone_number, + }) + .then(function (response) { + setPhoneNumber(values.phone_number); + setNationalId(values.national_id); + setTypeId(values.type_id); + setOtpToken(true); + }) + .catch(function (error) { + Notifications(directionApp, error.response, t); + props.setSubmitting(false); + }); + }; + + return ( + + + + + + {(props) => ( + + + {t("app_name")} + + + {t("register_welfare_services")} + + + + + + + + + + )} + + + + + + + {t("RegisterPage.link_routing_back_to")}{" "} + {t("RegisterPage.link_routing_login_navy")} + + + + ); +}; + +export default SendUserData; diff --git a/src/components/register-welfare-services/index.jsx b/src/components/register-welfare-services/index.jsx index b9a35c5..24678eb 100644 --- a/src/components/register-welfare-services/index.jsx +++ b/src/components/register-welfare-services/index.jsx @@ -1,169 +1,32 @@ -import StyledForm from "@/core/components/StyledForm"; -import { - Box, - Button, - Container, - Paper, - Stack, - Typography, - TextField, -} from "@mui/material"; -import { Field, Formik } from "formik"; -import Image from "next/image"; -import FingerprintIcon from "@mui/icons-material/Fingerprint"; -import FullPageLayout from "@/layouts/FullPageLayout"; -import CenterLayout from "@/layouts/CenterLayout"; -import { useTranslations } from "next-intl"; -import * as Yup from "yup"; -import LinkRouting from "@/core/components/LinkRouting"; -import { useSearchParams } from "next/navigation"; -import useDirection from "@/lib/app/hooks/useDirection"; -import useUser from "@/lib/app/hooks/useUser"; -// import { GET_USER_TOKEN } from "@/core/data/apiRoutes"; -// import axios from "axios"; +import { useState } from "react"; +import SendToken from "./SendToken"; +import SendUserData from "./SendUserData"; const RegisterNavyComponent = () => { - const t = useTranslations(); + const [otpToken, setOtpToken] = useState(false); + const [PhoneNumber, setPhoneNumber] = useState(""); + const [nationalId, setNationalId] = useState(""); + const [navganId, setNavganId] = useState(""); + const [typeId, setTypeId] = useState(""); - const { directionApp } = useDirection(); - const { setToken } = useUser(); - - const searchParams = useSearchParams(); - const backUrlDecodedPath = searchParams.get("back_url"); - - const initialValues = { - type_id: "2", - phone_number: "", - national_id: "", - navgan_id: "", - }; - const validationSchema = Yup.object().shape({ - phone_number: Yup.string().required( - t("RegisterPage.error_message_required") - ), - national_id: Yup.string().required( - t("RegisterPage.error_message_required") - ), - }); - // const handleSubmit = async (values, props) => { - // await axios - // .post(GET_USER_TOKEN, { - // type_id: values.type_id, - // national_id: values.national_id, - // navgan_id: values.navgan_id, - // phone_number: values.phone_number, - // }) - // .then(function (response) { - // setToken(response.data.token); - // }) - // .catch(function (error) { - // Notifications(directionApp, error.response, t); - // props.setSubmitting(false); - // }); - // }; - - return ( - - - - - - {(props) => ( - - - {t("app_name")} - - - {t("register_navy")} - - - - - - - - - - )} - - - - - - - {t("RegisterPage.link_routing_back_to")}{" "} - {t("RegisterPage.link_routing_login_navy")} - - - - ); + if (!otpToken) { + return ( + + ); + } else { + return ( + + ); + } }; export default RegisterNavyComponent; diff --git a/src/components/register-welfare-services/sendToken.jsx b/src/components/register-welfare-services/sendToken.jsx index e69de29..3fa7f1c 100644 --- a/src/components/register-welfare-services/sendToken.jsx +++ b/src/components/register-welfare-services/sendToken.jsx @@ -0,0 +1,127 @@ +import StyledForm from "@/core/components/StyledForm"; +import { REGISTER } from "@/core/data/apiRoutes"; +import CenterLayout from "@/layouts/CenterLayout"; +import FullPageLayout from "@/layouts/FullPageLayout"; +// import useDirection from "@/lib/app/hooks/useDirection"; +import useUser from "@/lib/app/hooks/useUser"; +import LoginIcon from "@mui/icons-material/Login"; +import { + Box, + Button, + Container, + Paper, + Stack, + TextField, + Typography, +} from "@mui/material"; +import axios from "axios"; +import { Field, Formik } from "formik"; +import { useTranslations } from "next-intl"; +import Image from "next/image"; +import * as Yup from "yup"; + +const SendToken = ({ PhoneNumber, nationalId, typeId }) => { + const t = useTranslations(); + // const { directionApp } = useDirection(); + const { setToken } = useUser(); + + const initialValues = { + phone_number: PhoneNumber, + national_id: nationalId, + type_id: typeId, + verification_code: "", + }; + const validationSchema = Yup.object().shape({ + verification_code: Yup.string().required( + t("RegisterPage.error_message_required") + ), + }); + + const handleSubmit = async (values, props) => { + await axios + .post(REGISTER, { + phone_number: values.phone_number, + national_id: values.national_id, + type_id: values.type_id, + verification_code: values.verification_code, + }) + .then(function (response) { + setToken(response.data.token); + }) + .catch(function (error) { + // Notifications(directionApp, error.response, t); + props.setSubmitting(false); + }); + }; + + return ( + + + + + + {(props) => ( + + + {t("app_name")} + + + {t("register_navy")} + + + + + + + + + )} + + + + + + ); +}; + +export default SendToken; From 3c0fab50c68d46c7cc808f92f67ae4b067e8b0c7 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Thu, 13 Jul 2023 10:31:10 +0330 Subject: [PATCH 06/54] add Notification(Error Handling) --- src/components/first/index.jsx | 2 +- .../Notification/ErrorNotification.jsx | 55 +++++++++++++++++++ .../Notification/SuccessNotification.jsx | 44 +++++++++++++++ .../Notification/WarningNotification.jsx | 55 +++++++++++++++++++ src/core/components/Notification/index.jsx | 36 ++++++++++++ 5 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 src/core/components/Notification/ErrorNotification.jsx create mode 100644 src/core/components/Notification/SuccessNotification.jsx create mode 100644 src/core/components/Notification/WarningNotification.jsx create mode 100644 src/core/components/Notification/index.jsx diff --git a/src/components/first/index.jsx b/src/components/first/index.jsx index 24ef6bb..897f7cd 100644 --- a/src/components/first/index.jsx +++ b/src/components/first/index.jsx @@ -25,7 +25,7 @@ const FirstComponent = () => { {isAuth ? ( + + + ), + { + position: directionApp === "ltr" ? "top-left" : "top-right", + autoClose: false, + closeOnClick: false, + draggable: false, + } + ); +}; + +export default ErrorNotification; diff --git a/src/core/components/Notification/SuccessNotification.jsx b/src/core/components/Notification/SuccessNotification.jsx new file mode 100644 index 0000000..7f69107 --- /dev/null +++ b/src/core/components/Notification/SuccessNotification.jsx @@ -0,0 +1,44 @@ +import BeenhereIcon from "@mui/icons-material/Beenhere"; +import { Box, Typography } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { toast } from "react-toastify"; + +const SuccessNotification = (directionApp, status) => { + const t = useTranslations(); + toast( + () => ( + <> + + + + + + {t("success")} ({t("code")}: {status}) + + + {t("success_static_text")} + + + + + + ), + { + position: directionApp === "ltr" ? "top-left" : "top-right", + autoClose: 3000, + hideProgressBar: true, + pauseOnHover: true, + closeOnClick: false, + draggable: true, + } + ); +}; + +export default SuccessNotification; diff --git a/src/core/components/Notification/WarningNotification.jsx b/src/core/components/Notification/WarningNotification.jsx new file mode 100644 index 0000000..9507569 --- /dev/null +++ b/src/core/components/Notification/WarningNotification.jsx @@ -0,0 +1,55 @@ +import ReportIcon from "@mui/icons-material/Report"; +import { Box, Button, Divider, Typography } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { toast } from "react-toastify"; + +const WarningNotification = (directionApp, status) => { + const t = useTranslations(); + toast( + ({ closeToast }) => ( + <> + + + + + + {t("warning")} ({t("code")}: {status}) + + + {t("warning_static_text")} + + + + + + + + + ), + { + position: directionApp === "ltr" ? "top-left" : "top-right", + autoClose: false, + closeOnClick: false, + draggable: false, + } + ); +}; + +export default WarningNotification; diff --git a/src/core/components/Notification/index.jsx b/src/core/components/Notification/index.jsx new file mode 100644 index 0000000..8152780 --- /dev/null +++ b/src/core/components/Notification/index.jsx @@ -0,0 +1,36 @@ +import { toast } from "react-toastify"; +import ErrorNotification from "./ErrorNotification"; +import SuccessNotification from "./successNotification"; +import WarningNotification from "./warningNotification"; + +const Notifications = (directionApp, response) => { + toast.dismiss(); + switch (response.status) { + case 200: + SuccessNotification(directionApp, response.status); + break; + case 400: + ErrorNotification(directionApp, response.status); + break; + case 401: + ErrorNotification(directionApp, response.status); + break; + case 403: + ErrorNotification(directionApp, response.status); + break; + case 422: + ErrorNotification(directionApp, response.status, response.data.message); + break; + case 500: + WarningNotification(directionApp, response.status); + break; + case 503: + WarningNotification(directionApp, response.status); + break; + case 504: + WarningNotification(directionApp, response.status); + break; + } +}; + +export default Notifications; From ae60d656c23a88a662f38e06463baa12d594af6f Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Thu, 13 Jul 2023 11:42:11 +0330 Subject: [PATCH 07/54] complete notifications --- public/locales/fa/app.json | 8 ++++ src/components/login-navy/SendUserData.jsx | 22 +++++---- src/core/components/Notification/index.jsx | 36 --------------- .../ErrorNotification.jsx | 23 ++-------- .../SuccessNotification.jsx | 9 ++-- .../WarningNotification.jsx | 18 +------- src/core/components/notifications/index.jsx | 46 +++++++++++++++++++ 7 files changed, 76 insertions(+), 86 deletions(-) delete mode 100644 src/core/components/Notification/index.jsx rename src/core/components/{Notification => notifications}/ErrorNotification.jsx (58%) rename src/core/components/{Notification => notifications}/SuccessNotification.jsx (81%) rename src/core/components/{Notification => notifications}/WarningNotification.jsx (67%) create mode 100644 src/core/components/notifications/index.jsx diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index af54719..b00205e 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -8,6 +8,7 @@ "register_navy": "ثبت نام اعضای ناوگان", "login_welfare_services": "ورود اعضای خدمات رفاهی", "register_welfare_services": "ثبت نام اعضای خدمات رفاهی", + "pending": "درحال اجرا...", "user_navy": "ناوگان", "header": { "open_profile": "پروفایل", @@ -15,6 +16,13 @@ "change_password": "تغییر رمز عبور", "logout": "خروج" }, + "notifications": { + "error_static_text": "عملیات با خطا مواجه شد", + "success_static_text": "عملیات با موفقیت انجام شد", + "code": "کد", + "success": "موفق", + "error": "خطا" + }, "Titles": { "title_login_page": "صفحه ورود", "title_login_navy_page": "ورود اعضای ناوگان", diff --git a/src/components/login-navy/SendUserData.jsx b/src/components/login-navy/SendUserData.jsx index c3197b8..db8a018 100644 --- a/src/components/login-navy/SendUserData.jsx +++ b/src/components/login-navy/SendUserData.jsx @@ -1,5 +1,5 @@ -// import Notifications from "@/core/components/notifications"; import LinkRouting from "@/core/components/LinkRouting"; +import Notifications from "@/core/components/notifications"; import StyledForm from "@/core/components/StyledForm"; import { LOGIN_SEND_OTP_TOKEN } from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; @@ -8,14 +8,14 @@ import useDirection from "@/lib/app/hooks/useDirection"; import FingerprintIcon from "@mui/icons-material/Fingerprint"; import PersonAddIcon from "@mui/icons-material/PersonAdd"; import { - Box, - Button, - Container, - Grid, - Paper, - Stack, - TextField, - Typography + Box, + Button, + Container, + Grid, + Paper, + Stack, + TextField, + Typography } from "@mui/material"; import axios from "axios"; import { Field, Formik } from "formik"; @@ -39,16 +39,18 @@ const SendUserData = ({ setOtpToken, setPhoneNumber }) => { }); const handleSubmit = async (values, props) => { + Notifications(directionApp, t, undefined); await axios .post(LOGIN_SEND_OTP_TOKEN, { phone_number: values.phone_number, }) .then(function (response) { + Notifications(directionApp, t, response); setPhoneNumber(values.phone_number); setOtpToken(true); }) .catch(function (error) { - // Notifications(directionApp, error.response, t); + Notifications(directionApp, t, error.response); props.setSubmitting(false); }); }; diff --git a/src/core/components/Notification/index.jsx b/src/core/components/Notification/index.jsx deleted file mode 100644 index 8152780..0000000 --- a/src/core/components/Notification/index.jsx +++ /dev/null @@ -1,36 +0,0 @@ -import { toast } from "react-toastify"; -import ErrorNotification from "./ErrorNotification"; -import SuccessNotification from "./successNotification"; -import WarningNotification from "./warningNotification"; - -const Notifications = (directionApp, response) => { - toast.dismiss(); - switch (response.status) { - case 200: - SuccessNotification(directionApp, response.status); - break; - case 400: - ErrorNotification(directionApp, response.status); - break; - case 401: - ErrorNotification(directionApp, response.status); - break; - case 403: - ErrorNotification(directionApp, response.status); - break; - case 422: - ErrorNotification(directionApp, response.status, response.data.message); - break; - case 500: - WarningNotification(directionApp, response.status); - break; - case 503: - WarningNotification(directionApp, response.status); - break; - case 504: - WarningNotification(directionApp, response.status); - break; - } -}; - -export default Notifications; diff --git a/src/core/components/Notification/ErrorNotification.jsx b/src/core/components/notifications/ErrorNotification.jsx similarity index 58% rename from src/core/components/Notification/ErrorNotification.jsx rename to src/core/components/notifications/ErrorNotification.jsx index 4351aef..8e1b99a 100644 --- a/src/core/components/Notification/ErrorNotification.jsx +++ b/src/core/components/notifications/ErrorNotification.jsx @@ -1,10 +1,8 @@ import DangerousIcon from "@mui/icons-material/Dangerous"; -import { Box, Button, Divider, Typography } from "@mui/material"; +import { Box, Typography } from "@mui/material"; import { toast } from "react-toastify"; -import { useTranslations } from "next-intl"; -const ErrorNotification = (directionApp, status, message) => { - const t = useTranslations(); +const ErrorNotification = (directionApp, t, status, message) => { toast( ({ closeToast }) => ( <> @@ -20,27 +18,14 @@ const ErrorNotification = (directionApp, status, message) => { - {t("error")} ({t("code")}: {status}) + {t("notifications.error")} ({t("notifications.code")}: {status}) - {message && t("error_static_text")} + {message || t("notifications.error_static_text")} - - - ), { diff --git a/src/core/components/Notification/SuccessNotification.jsx b/src/core/components/notifications/SuccessNotification.jsx similarity index 81% rename from src/core/components/Notification/SuccessNotification.jsx rename to src/core/components/notifications/SuccessNotification.jsx index 7f69107..420e99a 100644 --- a/src/core/components/Notification/SuccessNotification.jsx +++ b/src/core/components/notifications/SuccessNotification.jsx @@ -1,10 +1,8 @@ import BeenhereIcon from "@mui/icons-material/Beenhere"; import { Box, Typography } from "@mui/material"; -import { useTranslations } from "next-intl"; import { toast } from "react-toastify"; -const SuccessNotification = (directionApp, status) => { - const t = useTranslations(); +const SuccessNotification = (directionApp, t, status) => { toast( () => ( <> @@ -20,10 +18,11 @@ const SuccessNotification = (directionApp, status) => { - {t("success")} ({t("code")}: {status}) + {t("notifications.success")} ({t("notifications.code")}:{" "} + {status}) - {t("success_static_text")} + {t("notifications.success_static_text")} diff --git a/src/core/components/Notification/WarningNotification.jsx b/src/core/components/notifications/WarningNotification.jsx similarity index 67% rename from src/core/components/Notification/WarningNotification.jsx rename to src/core/components/notifications/WarningNotification.jsx index 9507569..1451031 100644 --- a/src/core/components/Notification/WarningNotification.jsx +++ b/src/core/components/notifications/WarningNotification.jsx @@ -1,10 +1,8 @@ import ReportIcon from "@mui/icons-material/Report"; -import { Box, Button, Divider, Typography } from "@mui/material"; -import { useTranslations } from "next-intl"; +import { Box, Divider, Typography } from "@mui/material"; import { toast } from "react-toastify"; -const WarningNotification = (directionApp, status) => { - const t = useTranslations(); +const WarningNotification = (directionApp, t, status) => { toast( ({ closeToast }) => ( <> @@ -29,18 +27,6 @@ const WarningNotification = (directionApp, status) => { - - ), { diff --git a/src/core/components/notifications/index.jsx b/src/core/components/notifications/index.jsx new file mode 100644 index 0000000..b1f4b29 --- /dev/null +++ b/src/core/components/notifications/index.jsx @@ -0,0 +1,46 @@ +import { toast } from "react-toastify"; +import ErrorNotification from "./ErrorNotification"; +import SuccessNotification from "./successNotification"; +import WarningNotification from "./warningNotification"; + +const Notifications = async (directionApp, t, response) => { + console.log(directionApp, t, response); + const { status, data } = response != undefined ? response : "" + toast.dismiss(); + switch (status) { + case 200: + SuccessNotification(directionApp, t, status); + break; + case 400: + ErrorNotification(directionApp, t,status); + break; + case 401: + ErrorNotification(directionApp, t, status); + break; + case 403: + ErrorNotification(directionApp, t, status); + break; + case 422: + ErrorNotification(directionApp, t, status, data.message); + break; + case 500: + WarningNotification(directionApp, t, status); + break; + case 503: + WarningNotification(directionApp, t, status); + break; + case 504: + WarningNotification(directionApp, t, status); + break; + default: + toast(t("pending"), { + position: directionApp === "ltr" ? "top-left" : "top-right", + autoClose: false, + closeOnClick: false, + draggable: false, + }); + break; + } +}; + +export default Notifications; From e3923d81162f5a7688e162bd7f7ed01de8fdb0ca Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Thu, 13 Jul 2023 12:00:27 +0330 Subject: [PATCH 08/54] debug notification --- src/core/components/notifications/index.jsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/core/components/notifications/index.jsx b/src/core/components/notifications/index.jsx index b1f4b29..9e8e52b 100644 --- a/src/core/components/notifications/index.jsx +++ b/src/core/components/notifications/index.jsx @@ -44,3 +44,13 @@ const Notifications = async (directionApp, t, response) => { }; export default Notifications; + +/* +usage document + +** for pending use ( Notifications(directionApp, t, undefined) ) this before your request. +** for success use ( Notifications(directionApp, t, response) ) this inside .then() of your request. +** for Error and Warning use ( Notifications(directionApp, t, error.response) ) this inside .catche() of your request. + +end usage document +*/ From 4c5b042a6b5731310a4e36dda3c0ba0362fb1c94 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Thu, 13 Jul 2023 13:57:44 +0330 Subject: [PATCH 09/54] designing box of showing loan request --- .../dashboard/loan-follow-up/index.jsx | 165 +++++++++++++++++- 1 file changed, 163 insertions(+), 2 deletions(-) diff --git a/src/components/dashboard/loan-follow-up/index.jsx b/src/components/dashboard/loan-follow-up/index.jsx index e69147e..e05fa20 100644 --- a/src/components/dashboard/loan-follow-up/index.jsx +++ b/src/components/dashboard/loan-follow-up/index.jsx @@ -1,16 +1,177 @@ import CenterLayout from "@/layouts/CenterLayout"; import DashboardLayouts from "@/layouts/dashboardLayouts"; import useUser from "@/lib/app/hooks/useUser"; +import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; +import { + Avatar, + Box, + Card, + CardActions, + CardContent, + CardHeader, + Collapse, + Grid, + IconButton, + Stack, + Typography, +} from "@mui/material"; +import { styled } from "@mui/material/styles"; import { useTranslations } from "next-intl"; -import React from "react"; +import { useState } from "react"; + +const ExpandMore = styled((props) => { + const { expand, ...other } = props; + return ; +})(({ theme, expand }) => ({ + transform: !expand ? "rotate(0deg)" : "rotate(180deg)", + marginLeft: "auto", + transition: theme.transitions.create("transform", { + duration: theme.transitions.duration.shortest, + }), +})); const DashboardLoanFollowUpComponent = () => { const t = useTranslations(); const { token } = useUser(); + + const [expanded, setExpanded] = useState(false); + + const handleExpandClick = () => { + setExpanded(!expanded); + }; + return ( -

چه کشکی چه پشمی

+ + + + + + } + title="اسم اقاهه" + subheader="تاریخ اگه خواستیم" + /> + + + متن تست + + + + + + + + + + اطلاعات تکمیلی: + پارت دوم متن تست + پارت سه همون قبلی + در ادامه باید بگم که... + درپایان همینه که هست + + + + + + + + } + title="اسم اقاهه" + subheader="تاریخ اگه خواستیم" + /> + + + متن تست + + + + + + + + + + اطلاعات تکمیلی: + پارت دوم متن تست + پارت سه همون قبلی + در ادامه باید بگم که... + درپایان همینه که هست + + + + + + + + } + title="اسم اقاهه" + subheader="تاریخ اگه خواستیم" + /> + + + متن تست + + + + + + + + + + اطلاعات تکمیلی: + پارت دوم متن تست + پارت سه همون قبلی + در ادامه باید بگم که... + درپایان همینه که هست + + + + + +
); From 489a8bf6dc48905b1081c67b97fa09ccce99e44d Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Sat, 15 Jul 2023 11:20:21 +0330 Subject: [PATCH 10/54] add not found page and design follow up loan --- public/images/not-found.svg | 1 + public/locales/fa/app.json | 4 +++- src/components/not-found.jsx | 38 ++++++++++++++++++++++++++++++++++++ src/pages/404.jsx | 13 ++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 public/images/not-found.svg create mode 100644 src/components/not-found.jsx create mode 100644 src/pages/404.jsx diff --git a/public/images/not-found.svg b/public/images/not-found.svg new file mode 100644 index 0000000..8735cf8 --- /dev/null +++ b/public/images/not-found.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index b00205e..67cc090 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -10,6 +10,7 @@ "register_welfare_services": "ثبت نام اعضای خدمات رفاهی", "pending": "درحال اجرا...", "user_navy": "ناوگان", + "page_not_found": "صفحه مورد نظر یافت نشد", "header": { "open_profile": "پروفایل", "edit_profile": "ویرایش پروفایل", @@ -28,7 +29,8 @@ "title_login_navy_page": "ورود اعضای ناوگان", "title_login_welfare_services_page": "ورود اعضای خدمات رفاهی", "title_register_navy_page": "ثبت نام اعضای ناوگان", - "title_register_welfare_services_page": "ثبت نام اعضای خدمات رفاهی" + "title_register_welfare_services_page": "ثبت نام اعضای خدمات رفاهی", + "title_not_found": "یافت نشد" }, "sidebar": { "dashboard": "داشبورد", diff --git a/src/components/not-found.jsx b/src/components/not-found.jsx new file mode 100644 index 0000000..c699d84 --- /dev/null +++ b/src/components/not-found.jsx @@ -0,0 +1,38 @@ +import CenterLayout from "@/layouts/CenterLayout"; +import FullPageLayout from "@/layouts/FullPageLayout"; +import { Box, Button, Typography } from "@mui/material"; +import { NextLinkComposed } from "@/core/components/LinkRouting"; +import { useTranslations } from "next-intl"; +import Image from "next/image"; + +const NotFoundComponent = () => { + const t = useTranslations(); + return ( + + + + not found image + + + صفحه ای با این عنوان یافت نشد + + + + + ); +}; + +export default NotFoundComponent; diff --git a/src/pages/404.jsx b/src/pages/404.jsx new file mode 100644 index 0000000..9b75470 --- /dev/null +++ b/src/pages/404.jsx @@ -0,0 +1,13 @@ +import NotFoundComponent from "@/components/not-found"; +import Head from "next/head"; + +export default function NotFound() { + return ( + <> + + یافت نشد + + + + ); +} From 0717e6c754aa5b1f1b919fd59ec58800cdde61e8 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Sat, 15 Jul 2023 11:35:24 +0330 Subject: [PATCH 11/54] add dynamic text to sidebar header --- .../dashboardLayouts/sidebar/SidebarDrawer.jsx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/layouts/dashboardLayouts/sidebar/SidebarDrawer.jsx b/src/layouts/dashboardLayouts/sidebar/SidebarDrawer.jsx index 4c65885..466c743 100644 --- a/src/layouts/dashboardLayouts/sidebar/SidebarDrawer.jsx +++ b/src/layouts/dashboardLayouts/sidebar/SidebarDrawer.jsx @@ -1,10 +1,12 @@ +import useUser from "@/lib/app/hooks/useUser"; import { Divider, Stack, Toolbar, Typography } from "@mui/material"; import { useTranslations } from "next-intl"; import SidebarList from "./SidebarList"; -import StyledImage from "@/core/components/StyledImage"; const SidebarDrawer = ({ handleDrawerToggle }) => { + const { user } = useUser(); const t = useTranslations(); + return ( <> @@ -12,12 +14,7 @@ const SidebarDrawer = ({ handleDrawerToggle }) => { {t("app_short_name")} - - { - t("user_navy") /* make if on thease t("user_welfare_services") - t("user_navy") */ - } - + {user.type_name} From 8e277c33ca10fc398c107144dc4cf9b326e9d1d5 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Sat, 15 Jul 2023 17:07:56 +0330 Subject: [PATCH 12/54] split welfare and navy --- .../dashboard/loan-request/NavyForm.jsx | 441 +++++++++++++++++ .../loan-request/WelfareServicesForm.jsx | 53 +++ .../dashboard/loan-request/index.jsx | 448 +----------------- 3 files changed, 499 insertions(+), 443 deletions(-) create mode 100644 src/components/dashboard/loan-request/NavyForm.jsx create mode 100644 src/components/dashboard/loan-request/WelfareServicesForm.jsx diff --git a/src/components/dashboard/loan-request/NavyForm.jsx b/src/components/dashboard/loan-request/NavyForm.jsx new file mode 100644 index 0000000..04e45e6 --- /dev/null +++ b/src/components/dashboard/loan-request/NavyForm.jsx @@ -0,0 +1,441 @@ +import StyledForm from "@/core/components/StyledForm"; +import DataSaverOnIcon from "@mui/icons-material/DataSaverOn"; +import { Box, Button, Stack, TextField } from "@mui/material"; +import { Field, Formik } from "formik"; +import { useTranslations } from "next-intl"; +import Image from "next/image"; +import * as Yup from "yup"; + +const NavyForm = () => { + const t = useTranslations(); + + const initialValues = { + first_name: "", + last_name: "", + phone_number: "", + vehicle_type: "", + plate_number: "", + province: "", + navgan_id: "", + national_code: "", + birth_certificate_id: "", + national_card_img: "", + birth_certificate_img: "", + }; + + const validationSchema = Yup.object().shape({ + first_name: Yup.string().required(t("LoanRequest.error_message_required")), + last_name: Yup.string().required(t("LoanRequest.error_message_required")), + phone_number: Yup.string().required( + t("LoanRequest.error_message_required") + ), + vehicle_type: Yup.string().required( + t("LoanRequest.error_message_required") + ), + plate_number: Yup.string().required( + t("LoanRequest.error_message_required") + ), + province: Yup.string().required(t("LoanRequest.error_message_required")), + navgan_id: Yup.string().required(t("LoanRequest.error_message_required")), + national_code: Yup.string().required( + t("LoanRequest.error_message_required") + ), + birth_certificate_id: Yup.string().required( + t("LoanRequest.error_message_required") + ), + }); + + return ( + + {(props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {t("app_name")} + + + {t("app_name")} + + + + + + + + )} + + ); +}; + +export default NavyForm; diff --git a/src/components/dashboard/loan-request/WelfareServicesForm.jsx b/src/components/dashboard/loan-request/WelfareServicesForm.jsx new file mode 100644 index 0000000..eefaa15 --- /dev/null +++ b/src/components/dashboard/loan-request/WelfareServicesForm.jsx @@ -0,0 +1,53 @@ +import StyledForm from "@/core/components/StyledForm"; +import DataSaverOnIcon from "@mui/icons-material/DataSaverOn"; +import { Box, Button, Stack, TextField } from "@mui/material"; +import { Field, Formik } from "formik"; +import { useTranslations } from "next-intl"; +import Image from "next/image"; +import * as Yup from "yup"; + +const WelfareServicesForm = () => { + const t = useTranslations(); + + const initialValues = { + first_name: "", + last_name: "", + phone_number: "", + vehicle_type: "", + plate_number: "", + province: "", + navgan_id: "", + national_code: "", + birth_certificate_id: "", + national_card_img: "", + birth_certificate_img: "", + }; + + const validationSchema = Yup.object().shape({ + first_name: Yup.string().required(t("LoanRequest.error_message_required")), + last_name: Yup.string().required(t("LoanRequest.error_message_required")), + phone_number: Yup.string().required( + t("LoanRequest.error_message_required") + ), + vehicle_type: Yup.string().required( + t("LoanRequest.error_message_required") + ), + plate_number: Yup.string().required( + t("LoanRequest.error_message_required") + ), + province: Yup.string().required(t("LoanRequest.error_message_required")), + navgan_id: Yup.string().required(t("LoanRequest.error_message_required")), + national_code: Yup.string().required( + t("LoanRequest.error_message_required") + ), + birth_certificate_id: Yup.string().required( + t("LoanRequest.error_message_required") + ), + }); + + return ( +

ولفیر سرویس

+ ); +}; + +export default WelfareServicesForm; diff --git a/src/components/dashboard/loan-request/index.jsx b/src/components/dashboard/loan-request/index.jsx index b51837c..7f6f827 100644 --- a/src/components/dashboard/loan-request/index.jsx +++ b/src/components/dashboard/loan-request/index.jsx @@ -1,455 +1,17 @@ -import StyledForm from "@/core/components/StyledForm"; import CenterLayout from "@/layouts/CenterLayout"; import DashboardLayouts from "@/layouts/dashboardLayouts"; import useUser from "@/lib/app/hooks/useUser"; -import { Box, Button, Stack, TextField } from "@mui/material"; -import { Field, Formik } from "formik"; -import { useTranslations } from "next-intl"; -import Image from "next/image"; -import DataSaverOnIcon from "@mui/icons-material/DataSaverOn"; -import * as Yup from "yup"; +import NavyForm from "./NavyForm"; +import WelfareServicesForm from "./WelfareServicesForm"; const DashboardLoanRequestComponent = () => { - const t = useTranslations(); - const { token } = useUser(); - - const initialValues = { - first_name: "", - last_name: "", - phone_number: "", - vehicle_type: "", - plate_number: "", - province: "", - navgan_id: "", - national_code: "", - birth_certificate_id: "", - national_card_img: "", - birth_certificate_img: "", - }; - - const validationSchema = Yup.object().shape({ - first_name: Yup.string().required(t("LoanRequest.error_message_required")), - last_name: Yup.string().required(t("LoanRequest.error_message_required")), - phone_number: Yup.string().required( - t("LoanRequest.error_message_required") - ), - vehicle_type: Yup.string().required( - t("LoanRequest.error_message_required") - ), - plate_number: Yup.string().required( - t("LoanRequest.error_message_required") - ), - province: Yup.string().required(t("LoanRequest.error_message_required")), - navgan_id: Yup.string().required(t("LoanRequest.error_message_required")), - national_code: Yup.string().required( - t("LoanRequest.error_message_required") - ), - birth_certificate_id: Yup.string().required( - t("LoanRequest.error_message_required") - ), - }); + + const { token, user } = useUser(); return ( - - {(props) => ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {t("app_name")} - - - {t("app_name")} - - - - - - - - )} - + {user.type_id == 1 ? : } ); From 59acffe7fc12ce9723d6e9479dcdf59718735477 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Sun, 16 Jul 2023 11:01:43 +0330 Subject: [PATCH 13/54] make welfare and navy component for loan request --- .../dashboard/loan-request/NavyForm.jsx | 24 -- .../loan-request/WelfareServicesForm.jsx | 363 +++++++++++++++++- 2 files changed, 362 insertions(+), 25 deletions(-) diff --git a/src/components/dashboard/loan-request/NavyForm.jsx b/src/components/dashboard/loan-request/NavyForm.jsx index 04e45e6..fc7ed83 100644 --- a/src/components/dashboard/loan-request/NavyForm.jsx +++ b/src/components/dashboard/loan-request/NavyForm.jsx @@ -4,7 +4,6 @@ import { Box, Button, Stack, TextField } from "@mui/material"; import { Field, Formik } from "formik"; import { useTranslations } from "next-intl"; import Image from "next/image"; -import * as Yup from "yup"; const NavyForm = () => { const t = useTranslations(); @@ -23,33 +22,10 @@ const NavyForm = () => { birth_certificate_img: "", }; - const validationSchema = Yup.object().shape({ - first_name: Yup.string().required(t("LoanRequest.error_message_required")), - last_name: Yup.string().required(t("LoanRequest.error_message_required")), - phone_number: Yup.string().required( - t("LoanRequest.error_message_required") - ), - vehicle_type: Yup.string().required( - t("LoanRequest.error_message_required") - ), - plate_number: Yup.string().required( - t("LoanRequest.error_message_required") - ), - province: Yup.string().required(t("LoanRequest.error_message_required")), - navgan_id: Yup.string().required(t("LoanRequest.error_message_required")), - national_code: Yup.string().required( - t("LoanRequest.error_message_required") - ), - birth_certificate_id: Yup.string().required( - t("LoanRequest.error_message_required") - ), - }); - return ( {(props) => ( { }); return ( -

ولفیر سرویس

+ + {(props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {t("app_name")} + + + {t("app_name")} + + + + + + + + )} + ); }; From 3b170615e044328789492f1dac394c478ff1e7c2 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Sun, 16 Jul 2023 11:29:24 +0330 Subject: [PATCH 14/54] notification handling for register and login in navy and welfare --- src/components/login-navy/SendToken.jsx | 4 +++- src/components/login-welfare-services/SendUserData.jsx | 6 ++++-- src/components/login-welfare-services/sendToken.jsx | 2 ++ src/components/register-navy/SendToken.jsx | 4 +++- src/components/register-navy/SendUserData.jsx | 4 ++++ .../register-welfare-services/SendUserData.jsx | 5 +++++ src/components/register-welfare-services/sendToken.jsx | 9 ++++++--- 7 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/components/login-navy/SendToken.jsx b/src/components/login-navy/SendToken.jsx index d7fb84b..b274224 100644 --- a/src/components/login-navy/SendToken.jsx +++ b/src/components/login-navy/SendToken.jsx @@ -1,4 +1,4 @@ -// import Notifications from "@/core/components/notifications"; +import Notifications from "@/core/components/notifications"; import StyledForm from "@/core/components/StyledForm"; import { LOGIN } from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; @@ -38,12 +38,14 @@ const SendToken = ({ PhoneNumber }) => { }); const handleSubmit = async (values, props) => { + Notifications(directionApp, t, undefined); await axios .post(LOGIN, { phone_number: values.phone_number, verification_code: values.verification_code, }) .then(function (response) { + Notifications(directionApp, t, response); setToken(response.data.token); }) .catch(function (error) { diff --git a/src/components/login-welfare-services/SendUserData.jsx b/src/components/login-welfare-services/SendUserData.jsx index ec8072f..0a8280b 100644 --- a/src/components/login-welfare-services/SendUserData.jsx +++ b/src/components/login-welfare-services/SendUserData.jsx @@ -1,4 +1,4 @@ -// import Notifications from "@/core/components/notifications"; +import Notifications from "@/core/components/notifications"; import LinkRouting from "@/core/components/LinkRouting"; import StyledForm from "@/core/components/StyledForm"; import { LOGIN_SEND_OTP_TOKEN } from "@/core/data/apiRoutes"; @@ -39,16 +39,18 @@ const SendUserData = ({ setOtpToken, setPhoneNumber }) => { }); const handleSubmit = async (values, props) => { + Notifications(directionApp, t, undefined); await axios .post(LOGIN_SEND_OTP_TOKEN, { phone_number: values.phone_number, }) .then(function (response) { + Notifications(directionApp, t, response); setPhoneNumber(values.phone_number); setOtpToken(true); }) .catch(function (error) { - // Notifications(directionApp, error.response, t); + Notifications(directionApp, error.response, t); props.setSubmitting(false); }); }; diff --git a/src/components/login-welfare-services/sendToken.jsx b/src/components/login-welfare-services/sendToken.jsx index 00414b7..2ddefe2 100644 --- a/src/components/login-welfare-services/sendToken.jsx +++ b/src/components/login-welfare-services/sendToken.jsx @@ -38,12 +38,14 @@ const SendToken = ({ PhoneNumber }) => { }); const handleSubmit = async (values, props) => { + Notifications(directionApp, t, undefined); await axios .post(LOGIN, { phone_number: values.phone_number, verification_code: values.verification_code, }) .then(function (response) { + Notifications(directionApp, t, response); setToken(response.data.token); }) .catch(function (error) { diff --git a/src/components/register-navy/SendToken.jsx b/src/components/register-navy/SendToken.jsx index ab8a4ba..45d3606 100644 --- a/src/components/register-navy/SendToken.jsx +++ b/src/components/register-navy/SendToken.jsx @@ -37,6 +37,7 @@ const SendToken = ({ PhoneNumber, nationalId, navganId, typeId }) => { }); const handleSubmit = async (values, props) => { + Notifications(directionApp, t, undefined); await axios .post(REGISTER, { phone_number: values.phone_number, @@ -46,10 +47,11 @@ const SendToken = ({ PhoneNumber, nationalId, navganId, typeId }) => { verification_code: values.verification_code, }) .then(function (response) { + Notifications(directionApp, t, response); setToken(response.data.token); }) .catch(function (error) { - // Notifications(directionApp, error.response, t); + Notifications(directionApp, error.response, t); props.setSubmitting(false); }); }; diff --git a/src/components/register-navy/SendUserData.jsx b/src/components/register-navy/SendUserData.jsx index 8766d44..ff7431e 100644 --- a/src/components/register-navy/SendUserData.jsx +++ b/src/components/register-navy/SendUserData.jsx @@ -1,4 +1,5 @@ import LinkRouting from "@/core/components/LinkRouting"; +import Notifications from "@/core/components/notifications"; import StyledForm from "@/core/components/StyledForm"; import { REGISTER_SEND_OTP_TOKEN } from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; @@ -26,6 +27,7 @@ const SendUserData = ({ setTypeId, }) => { const t = useTranslations(); + const { directionApp } = useDirection(); const searchParams = useSearchParams(); const backUrlDecodedPath = searchParams.get("back_url"); @@ -47,6 +49,7 @@ const SendUserData = ({ }); const handleSubmit = async (values, props) => { + Notifications(directionApp, t, undefined); await axios .post(REGISTER_SEND_OTP_TOKEN, { type_id: values.type_id, @@ -55,6 +58,7 @@ const SendUserData = ({ phone_number: values.phone_number, }) .then(function (response) { + Notifications(directionApp, t, response); setPhoneNumber(values.phone_number); setNationalId(values.national_id); setNavganId(values.navgan_id); diff --git a/src/components/register-welfare-services/SendUserData.jsx b/src/components/register-welfare-services/SendUserData.jsx index ddf4933..b579131 100644 --- a/src/components/register-welfare-services/SendUserData.jsx +++ b/src/components/register-welfare-services/SendUserData.jsx @@ -1,8 +1,10 @@ import LinkRouting from "@/core/components/LinkRouting"; +import Notifications from "@/core/components/notifications"; import StyledForm from "@/core/components/StyledForm"; import { REGISTER_SEND_OTP_TOKEN } from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; +import useDirection from "@/lib/app/hooks/useDirection"; import FingerprintIcon from "@mui/icons-material/Fingerprint"; import { Box, @@ -27,6 +29,7 @@ const SendUserData = ({ setTypeId, }) => { const t = useTranslations(); + const { directionApp } = useDirection(); const searchParams = useSearchParams(); const backUrlDecodedPath = searchParams.get("back_url"); @@ -46,6 +49,7 @@ const SendUserData = ({ }); const handleSubmit = async (values, props) => { + Notifications(directionApp, t, undefined); await axios .post(REGISTER_SEND_OTP_TOKEN, { type_id: values.type_id, @@ -53,6 +57,7 @@ const SendUserData = ({ phone_number: values.phone_number, }) .then(function (response) { + Notifications(directionApp, t, response); setPhoneNumber(values.phone_number); setNationalId(values.national_id); setTypeId(values.type_id); diff --git a/src/components/register-welfare-services/sendToken.jsx b/src/components/register-welfare-services/sendToken.jsx index 3fa7f1c..02431cc 100644 --- a/src/components/register-welfare-services/sendToken.jsx +++ b/src/components/register-welfare-services/sendToken.jsx @@ -1,8 +1,9 @@ +import Notifications from "@/core/components/notifications"; import StyledForm from "@/core/components/StyledForm"; import { REGISTER } from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; -// import useDirection from "@/lib/app/hooks/useDirection"; +import useDirection from "@/lib/app/hooks/useDirection"; import useUser from "@/lib/app/hooks/useUser"; import LoginIcon from "@mui/icons-material/Login"; import { @@ -22,7 +23,7 @@ import * as Yup from "yup"; const SendToken = ({ PhoneNumber, nationalId, typeId }) => { const t = useTranslations(); - // const { directionApp } = useDirection(); + const { directionApp } = useDirection(); const { setToken } = useUser(); const initialValues = { @@ -38,6 +39,7 @@ const SendToken = ({ PhoneNumber, nationalId, typeId }) => { }); const handleSubmit = async (values, props) => { + Notifications(directionApp, t, undefined); await axios .post(REGISTER, { phone_number: values.phone_number, @@ -46,10 +48,11 @@ const SendToken = ({ PhoneNumber, nationalId, typeId }) => { verification_code: values.verification_code, }) .then(function (response) { + Notifications(directionApp, t, response); setToken(response.data.token); }) .catch(function (error) { - // Notifications(directionApp, error.response, t); + Notifications(directionApp, error.response, t); props.setSubmitting(false); }); }; From e440ca83e1dd6c5cfc0270953c03dbcaf7aa1acb Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Sun, 16 Jul 2023 11:43:47 +0330 Subject: [PATCH 15/54] debug notification --- src/components/login-navy/SendToken.jsx | 2 +- src/components/login-welfare-services/SendUserData.jsx | 2 +- src/components/login-welfare-services/sendToken.jsx | 2 +- src/components/register-navy/SendToken.jsx | 2 +- src/components/register-navy/SendUserData.jsx | 2 +- src/components/register-welfare-services/SendUserData.jsx | 2 +- src/components/register-welfare-services/sendToken.jsx | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/login-navy/SendToken.jsx b/src/components/login-navy/SendToken.jsx index b274224..cbbb0ee 100644 --- a/src/components/login-navy/SendToken.jsx +++ b/src/components/login-navy/SendToken.jsx @@ -49,7 +49,7 @@ const SendToken = ({ PhoneNumber }) => { setToken(response.data.token); }) .catch(function (error) { - Notifications(directionApp, error.response, t); + Notifications(directionApp, t, error.response); props.setSubmitting(false); }); }; diff --git a/src/components/login-welfare-services/SendUserData.jsx b/src/components/login-welfare-services/SendUserData.jsx index 0a8280b..3541261 100644 --- a/src/components/login-welfare-services/SendUserData.jsx +++ b/src/components/login-welfare-services/SendUserData.jsx @@ -50,7 +50,7 @@ const SendUserData = ({ setOtpToken, setPhoneNumber }) => { setOtpToken(true); }) .catch(function (error) { - Notifications(directionApp, error.response, t); + Notifications(directionApp, t, error.response); props.setSubmitting(false); }); }; diff --git a/src/components/login-welfare-services/sendToken.jsx b/src/components/login-welfare-services/sendToken.jsx index 2ddefe2..bd7e466 100644 --- a/src/components/login-welfare-services/sendToken.jsx +++ b/src/components/login-welfare-services/sendToken.jsx @@ -49,7 +49,7 @@ const SendToken = ({ PhoneNumber }) => { setToken(response.data.token); }) .catch(function (error) { - Notifications(directionApp, error.response, t); + Notifications(directionApp, t, error.response); props.setSubmitting(false); }); }; diff --git a/src/components/register-navy/SendToken.jsx b/src/components/register-navy/SendToken.jsx index 45d3606..d4156b8 100644 --- a/src/components/register-navy/SendToken.jsx +++ b/src/components/register-navy/SendToken.jsx @@ -51,7 +51,7 @@ const SendToken = ({ PhoneNumber, nationalId, navganId, typeId }) => { setToken(response.data.token); }) .catch(function (error) { - Notifications(directionApp, error.response, t); + Notifications(directionApp, t, error.response); props.setSubmitting(false); }); }; diff --git a/src/components/register-navy/SendUserData.jsx b/src/components/register-navy/SendUserData.jsx index ff7431e..bb13517 100644 --- a/src/components/register-navy/SendUserData.jsx +++ b/src/components/register-navy/SendUserData.jsx @@ -66,7 +66,7 @@ const SendUserData = ({ setOtpToken(true) }) .catch(function (error) { - Notifications(directionApp, error.response, t); + Notifications(directionApp, t, error.response); props.setSubmitting(false); }); }; diff --git a/src/components/register-welfare-services/SendUserData.jsx b/src/components/register-welfare-services/SendUserData.jsx index b579131..c74a1f4 100644 --- a/src/components/register-welfare-services/SendUserData.jsx +++ b/src/components/register-welfare-services/SendUserData.jsx @@ -64,7 +64,7 @@ const SendUserData = ({ setOtpToken(true); }) .catch(function (error) { - Notifications(directionApp, error.response, t); + Notifications(directionApp, t, error.response); props.setSubmitting(false); }); }; diff --git a/src/components/register-welfare-services/sendToken.jsx b/src/components/register-welfare-services/sendToken.jsx index 02431cc..7634f93 100644 --- a/src/components/register-welfare-services/sendToken.jsx +++ b/src/components/register-welfare-services/sendToken.jsx @@ -52,7 +52,7 @@ const SendToken = ({ PhoneNumber, nationalId, typeId }) => { setToken(response.data.token); }) .catch(function (error) { - Notifications(directionApp, error.response, t); + Notifications(directionApp, t, error.response); props.setSubmitting(false); }); }; From 74acce64ccdf442dc7d0895b85c19d205959c7b8 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Sun, 16 Jul 2023 11:57:14 +0330 Subject: [PATCH 16/54] show diffrent between welfare and navy to user --- src/components/dashboard/loan-request/index.jsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/components/dashboard/loan-request/index.jsx b/src/components/dashboard/loan-request/index.jsx index 7f6f827..3b5d31f 100644 --- a/src/components/dashboard/loan-request/index.jsx +++ b/src/components/dashboard/loan-request/index.jsx @@ -3,14 +3,25 @@ import DashboardLayouts from "@/layouts/dashboardLayouts"; import useUser from "@/lib/app/hooks/useUser"; import NavyForm from "./NavyForm"; import WelfareServicesForm from "./WelfareServicesForm"; +import { Divider, Chip, Box } from "@mui/material"; +import { useTranslations } from "next-intl"; const DashboardLoanRequestComponent = () => { - - const { token, user } = useUser(); + const t = useTranslations(); + const { user } = useUser(); return ( + + + + + {user.type_id == 1 ? : } From e0b63a6f74a7a9b3b97154de902b808ad17642a3 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Sun, 16 Jul 2023 12:07:04 +0330 Subject: [PATCH 17/54] add notification in pages that do not have that --- src/components/login-welfare-services/sendToken.jsx | 2 +- src/components/register-navy/SendToken.jsx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/login-welfare-services/sendToken.jsx b/src/components/login-welfare-services/sendToken.jsx index bd7e466..4d14dd1 100644 --- a/src/components/login-welfare-services/sendToken.jsx +++ b/src/components/login-welfare-services/sendToken.jsx @@ -1,4 +1,4 @@ -// import Notifications from "@/core/components/notifications"; +import Notifications from "@/core/components/notifications"; import StyledForm from "@/core/components/StyledForm"; import { LOGIN } from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; diff --git a/src/components/register-navy/SendToken.jsx b/src/components/register-navy/SendToken.jsx index d4156b8..fcba709 100644 --- a/src/components/register-navy/SendToken.jsx +++ b/src/components/register-navy/SendToken.jsx @@ -1,8 +1,9 @@ +import Notifications from "@/core/components/notifications"; import StyledForm from "@/core/components/StyledForm"; import { REGISTER } from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; -// import useDirection from "@/lib/app/hooks/useDirection"; +import useDirection from "@/lib/app/hooks/useDirection"; import useUser from "@/lib/app/hooks/useUser"; import LoginIcon from "@mui/icons-material/Login"; import { @@ -20,7 +21,7 @@ import * as Yup from "yup"; const SendToken = ({ PhoneNumber, nationalId, navganId, typeId }) => { const t = useTranslations(); - // const { directionApp } = useDirection(); + const { directionApp } = useDirection(); const { setToken } = useUser(); const initialValues = { From 285e8bb2bffe0aff50024d9fdbefdb466a8c5a83 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Tue, 18 Jul 2023 16:48:31 +0330 Subject: [PATCH 18/54] add image uploading and document uploading system by a reusable component named UploadSystem --- public/images/upload-image.svg | 1 + public/locales/fa/app.json | 11 +- .../dashboard/loan-follow-up/index.jsx | 188 ++++++--------- .../dashboard/loan-request/NavyForm.jsx | 99 ++++---- .../loan-request/WelfareServicesForm.jsx | 220 +++++++++--------- src/components/first/index.jsx | 1 + src/components/register-navy/SendToken.jsx | 1 + src/components/register-navy/SendUserData.jsx | 2 + .../SendUserData.jsx | 1 + .../register-welfare-services/sendToken.jsx | 1 + src/core/components/Messages.jsx | 1 + src/core/components/UploadSystem.jsx | 163 +++++++++++++ src/core/data/apiRoutes.js | 2 + 13 files changed, 400 insertions(+), 291 deletions(-) create mode 100644 public/images/upload-image.svg create mode 100644 src/core/components/UploadSystem.jsx diff --git a/public/images/upload-image.svg b/public/images/upload-image.svg new file mode 100644 index 0000000..3bbca65 --- /dev/null +++ b/public/images/upload-image.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 67cc090..138c4b9 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -11,6 +11,7 @@ "pending": "درحال اجرا...", "user_navy": "ناوگان", "page_not_found": "صفحه مورد نظر یافت نشد", + "delete": "حذف", "header": { "open_profile": "پروفایل", "edit_profile": "ویرایش پروفایل", @@ -83,10 +84,8 @@ "error_message_required": "اجباری!", "text_field_phone_number": "شماره تلفن", "text_field_enter_your_phone_number": "شماره تلفن خود را وارد کنید", - "text_field_first_name": "نام", - "text_field_enter_your_first_name": "نام خود را وارد کنید", - "text_field_last_name": "نام خانوادگی", - "text_field_enter_your_last_name": "نام خانوادگی خود را وارد کنید", + "text_field_name": "نام", + "text_field_enter_your_name": "نام خود را وارد کنید", "text_field_vehicle_type": "نام وسیله نقلیه", "text_field_enter_your_vehicle_type": "نام وسیله نقلیه خود را وارد کنید", "text_field_province": "استان", @@ -95,8 +94,8 @@ "text_field_enter_your_navgan_id": "شماره ناوگان خود را وارد کنید", "text_field_national_code": "کد ملی", "text_field_enter_your_national_code": "کد ملی خود را وارد کنید", - "text_field_birth_certificate_id": "شماره شناسنامه", - "text_field_enter_your_birth_certificate_id": "شماره شناسنامه خود را وارد کنید", + "text_field_shenasname_id": "شماره شناسنامه", + "text_field_enter_your_shenasname_id": "شماره شناسنامه خود را وارد کنید", "text_field_plate_number": "شماره پلاک", "text_field_enter_your_plate_number": "شماره پلاک خود را وارد کنید", "button_submit": "ثبت درخواست" diff --git a/src/components/dashboard/loan-follow-up/index.jsx b/src/components/dashboard/loan-follow-up/index.jsx index e05fa20..1b211af 100644 --- a/src/components/dashboard/loan-follow-up/index.jsx +++ b/src/components/dashboard/loan-follow-up/index.jsx @@ -1,11 +1,8 @@ -import CenterLayout from "@/layouts/CenterLayout"; import DashboardLayouts from "@/layouts/dashboardLayouts"; import useUser from "@/lib/app/hooks/useUser"; import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; import { - Avatar, - Box, - Card, + Avatar, Card, CardActions, CardContent, CardHeader, @@ -13,7 +10,7 @@ import { Grid, IconButton, Stack, - Typography, + Typography } from "@mui/material"; import { styled } from "@mui/material/styles"; import { useTranslations } from "next-intl"; @@ -30,19 +27,42 @@ const ExpandMore = styled((props) => { }), })); +const data = [ + { + name: "جان دو", + date: "۱۳۹۹/۰۴/۲۵", + description: + "لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ و با استفاده از طراحان گرافیک است.", + }, + { + name: "جین اسمیت", + date: "۱۳۹۹/۰۴/۲۶", + description: "نُلا ویته الیت لیبرو آ، آ فارِترا آوگوه.", + }, + { + name: "مایک جانسون", + date: "۱۳۹۹/۰۴/۲۷", + description: + "دوئیس مولیس، است نُن کُمُدو لُکتوس، نیسی ارات پورتیتور لیگولا.", + }, +]; + const DashboardLoanFollowUpComponent = () => { const t = useTranslations(); const { token } = useUser(); - const [expanded, setExpanded] = useState(false); + const [expanded, setExpanded] = useState([]); - const handleExpandClick = () => { - setExpanded(!expanded); + const handleExpandClick = (index) => { + setExpanded((prevExpanded) => { + const newExpanded = [...prevExpanded]; + newExpanded[index] = !newExpanded[index]; + return newExpanded; + }); }; return ( - { container columnSpacing={2} rowSpacing={2} - sx={{ alignItems: "center", justifyContent: "center" }} + sx={{ alignItems: "start", justifyContent: "center" }} > - - - - } - title="اسم اقاهه" - subheader="تاریخ اگه خواستیم" - /> - - - متن تست - - - - - - - - + {data.map((item, index) => ( + + + + } + title={item.name} + subheader={item.date} + /> - اطلاعات تکمیلی: - پارت دوم متن تست - پارت سه همون قبلی - در ادامه باید بگم که... - درپایان همینه که هست + + متن تست + - - - - - - - } - title="اسم اقاهه" - subheader="تاریخ اگه خواستیم" - /> - - - متن تست - - - - - - - - - - اطلاعات تکمیلی: - پارت دوم متن تست - پارت سه همون قبلی - در ادامه باید بگم که... - درپایان همینه که هست - - - - - - - - } - title="اسم اقاهه" - subheader="تاریخ اگه خواستیم" - /> - - - متن تست - - - - - - - - - - اطلاعات تکمیلی: - پارت دوم متن تست - پارت سه همون قبلی - در ادامه باید بگم که... - درپایان همینه که هست - - - - + + handleExpandClick(index)} + aria-expanded={expanded[index]} + aria-label="show more" + > + + + + + + اطلاعات تکمیلی: + {item.description} + + + +
+ ))} - ); }; diff --git a/src/components/dashboard/loan-request/NavyForm.jsx b/src/components/dashboard/loan-request/NavyForm.jsx index fc7ed83..7686862 100644 --- a/src/components/dashboard/loan-request/NavyForm.jsx +++ b/src/components/dashboard/loan-request/NavyForm.jsx @@ -1,4 +1,6 @@ +import Notifications from "@/core/components/notifications"; import StyledForm from "@/core/components/StyledForm"; +import useDirection from "@/lib/app/hooks/useDirection"; import DataSaverOnIcon from "@mui/icons-material/DataSaverOn"; import { Box, Button, Stack, TextField } from "@mui/material"; import { Field, Formik } from "formik"; @@ -7,26 +9,45 @@ import Image from "next/image"; const NavyForm = () => { const t = useTranslations(); + const { directionApp } = useDirection(); const initialValues = { - first_name: "", - last_name: "", + name: "", phone_number: "", vehicle_type: "", plate_number: "", province: "", navgan_id: "", national_code: "", - birth_certificate_id: "", + shenasname_id: "", national_card_img: "", - birth_certificate_img: "", + shenasname_img: "", + }; + + const handleSubmit = async (values, props) => { + Notifications(directionApp, t, undefined); + await axios + .post(SEND_LOAN_REQUEST_NAVGAN, { + name: values.name, + phone_number: values.phone_number, + vehicle_type: values.vehicle_type, + plate_number: values.plate_number, + province_id: values.province, + navgan_id: values.navgan_id, + national_code: values.national_code, + shenasname_id: values.shenasname_id, + }) + .then(function (response) { + Notifications(directionApp, t, response); + }) + .catch(function (error) { + Notifications(directionApp, t, error.response); + props.setSubmitting(false); + }); }; return ( - + {(props) => ( { - - - { diff --git a/src/components/dashboard/loan-request/WelfareServicesForm.jsx b/src/components/dashboard/loan-request/WelfareServicesForm.jsx index 0bca6ff..4ea21b6 100644 --- a/src/components/dashboard/loan-request/WelfareServicesForm.jsx +++ b/src/components/dashboard/loan-request/WelfareServicesForm.jsx @@ -1,31 +1,71 @@ +import Notifications from "@/core/components/notifications"; import StyledForm from "@/core/components/StyledForm"; +import UploadSystem from "@/core/components/UploadSystem"; +import { SEND_LOAN_REQUEST_WELFARE } from "@/core/data/apiRoutes"; +import useDirection from "@/lib/app/hooks/useDirection"; import DataSaverOnIcon from "@mui/icons-material/DataSaverOn"; import { Box, Button, Stack, TextField } from "@mui/material"; +import axios from "axios"; import { Field, Formik } from "formik"; import { useTranslations } from "next-intl"; -import Image from "next/image"; +import { useState } from "react"; import * as Yup from "yup"; const WelfareServicesForm = () => { const t = useTranslations(); + const { directionApp } = useDirection(); + // upload files + const [selectedImageShenasname, setSelectedImageShenasname] = useState( + "/images/upload-image.svg" + ); + const [fileTypeShenasname, setFileTypeShenasname] = useState(null); + const [fileNameShenasname, setFileNameShenasname] = useState(null); + const [selectedImageNationalCard, setSelectedImageNationalCard] = useState( + "/images/upload-image.svg" + ); + const [fileTypeNationalCard, setFileTypeNationalCard] = useState(null); + const [fileNameNationalCard, setFileNameNationalCard] = useState(null); + + const handleUploadChangeShenasname = (event, setFieldValue) => { + const uploadedFile = event.target?.files?.[0]; + const fileType = event.target.files[0].type; + const fileName = event.target.files[0].name; + if (uploadedFile) { + setSelectedImageShenasname(URL.createObjectURL(uploadedFile)); + setFileTypeShenasname(fileType); + setFileNameShenasname(fileName); + setFieldValue("shenasname_img", uploadedFile); + } + }; + const handleUploadChangeNationalCard = (event, setFieldValue) => { + const uploadedFile = event.target?.files?.[0]; + const fileType = event.target.files[0].type; + const fileName = event.target.files[0].name; + if (uploadedFile) { + setSelectedImageNationalCard(URL.createObjectURL(uploadedFile)); + setFileTypeNationalCard(fileType); + setFileNameNationalCard(fileName); + setFieldValue("national_card_img", uploadedFile); + } + }; + // end upload files + + // initial values, validation and request action of form const initialValues = { - first_name: "", - last_name: "", + name: "", phone_number: "", vehicle_type: "", plate_number: "", province: "", - navgan_id: "", national_code: "", - birth_certificate_id: "", - national_card_img: "", - birth_certificate_img: "", + shenasname_id: "", + national_card_img: null, + shenasname_img: null, }; const validationSchema = Yup.object().shape({ - first_name: Yup.string().required(t("LoanRequest.error_message_required")), - last_name: Yup.string().required(t("LoanRequest.error_message_required")), + name: Yup.string().required(t("LoanRequest.error_message_required")), phone_number: Yup.string().required( t("LoanRequest.error_message_required") ), @@ -36,19 +76,45 @@ const WelfareServicesForm = () => { t("LoanRequest.error_message_required") ), province: Yup.string().required(t("LoanRequest.error_message_required")), - navgan_id: Yup.string().required(t("LoanRequest.error_message_required")), national_code: Yup.string().required( t("LoanRequest.error_message_required") ), - birth_certificate_id: Yup.string().required( + shenasname_id: Yup.string().required( t("LoanRequest.error_message_required") ), }); + const handleSubmit = async (values, props) => { + Notifications(directionApp, t, undefined); + console.log(values.national_card_img); + console.log(values.shenasname_img); + await axios + .post(SEND_LOAN_REQUEST_WELFARE, { + name: values.name, + phone_number: values.phone_number, + vehicle_type: values.vehicle_type, + plate_number: values.plate_number, + province_id: values.province, + navgan_id: values.navgan_id, + national_code: values.national_code, + shenasname_id: values.shenasname_id, + national_card_image: values.national_card_img, + shenasname_image: values.shenasname_img, + }) + .then(function (response) { + Notifications(directionApp, t, response); + }) + .catch(function (error) { + Notifications(directionApp, t, error.response); + props.setSubmitting(false); + }); + }; + // end initial values, validation and request action of form + return ( {(props) => ( @@ -79,50 +145,15 @@ const WelfareServicesForm = () => { - - - { width: "100%", }} > - - - { @@ -365,24 +368,32 @@ const WelfareServicesForm = () => { width: "100%", }} > - - {t("app_name")} - - - {t("app_name")} - + + handleUploadChangeShenasname(e, props.setFieldValue) + } + setselectedImage={setSelectedImageShenasname} + setFieldValue={props.setFieldValue} + fieldname="shenasname_img" + fileType={fileTypeShenasname} + fileName={fileNameShenasname} + imageAlt={t("app_name")} + imageSize={[300 /*width*/, 150 /*height*/]} + /> + + handleUploadChangeNationalCard(e, props.setFieldValue) + } + setselectedImage={setSelectedImageNationalCard} + setFieldValue={props.setFieldValue} + fieldname="national_card_img" + fileType={fileTypeNationalCard} + fileName={fileNameNationalCard} + imageAlt={t("app_name")} + imageSize={[300 /*width*/, 150 /*height*/]} + /> { flexDirection: { xs: "column", sm: "row" }, alignItems: "center", mx: "auto", + my: 2, width: { xs: "100%", sm: "30%", md: "25%" }, }} > diff --git a/src/components/first/index.jsx b/src/components/first/index.jsx index 897f7cd..edd3a8a 100644 --- a/src/components/first/index.jsx +++ b/src/components/first/index.jsx @@ -19,6 +19,7 @@ const FirstComponent = () => { alt={t("app_name")} width={300} height={200} + priority /> {t("app_name")} diff --git a/src/components/register-navy/SendToken.jsx b/src/components/register-navy/SendToken.jsx index fcba709..62bbb86 100644 --- a/src/components/register-navy/SendToken.jsx +++ b/src/components/register-navy/SendToken.jsx @@ -76,6 +76,7 @@ const SendToken = ({ PhoneNumber, nationalId, navganId, typeId }) => { fill src="/images/register.svg" alt={t("app_name")} + priority /> diff --git a/src/components/register-navy/SendUserData.jsx b/src/components/register-navy/SendUserData.jsx index bb13517..1433266 100644 --- a/src/components/register-navy/SendUserData.jsx +++ b/src/components/register-navy/SendUserData.jsx @@ -4,6 +4,7 @@ import StyledForm from "@/core/components/StyledForm"; import { REGISTER_SEND_OTP_TOKEN } from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; +import useDirection from "@/lib/app/hooks/useDirection"; import FingerprintIcon from "@mui/icons-material/Fingerprint"; import { Box, @@ -90,6 +91,7 @@ const SendUserData = ({ fill src="/images/register.svg" alt={t("app_name")} + priority /> diff --git a/src/components/register-welfare-services/SendUserData.jsx b/src/components/register-welfare-services/SendUserData.jsx index c74a1f4..07fb6e0 100644 --- a/src/components/register-welfare-services/SendUserData.jsx +++ b/src/components/register-welfare-services/SendUserData.jsx @@ -88,6 +88,7 @@ const SendUserData = ({ fill src="/images/register.svg" alt={t("app_name")} + priority /> diff --git a/src/components/register-welfare-services/sendToken.jsx b/src/components/register-welfare-services/sendToken.jsx index 7634f93..5d5af44 100644 --- a/src/components/register-welfare-services/sendToken.jsx +++ b/src/components/register-welfare-services/sendToken.jsx @@ -76,6 +76,7 @@ const SendToken = ({ PhoneNumber, nationalId, typeId }) => { fill src="/images/register.svg" alt={t("app_name")} + priority /> diff --git a/src/core/components/Messages.jsx b/src/core/components/Messages.jsx index db6a980..2bd45c8 100644 --- a/src/core/components/Messages.jsx +++ b/src/core/components/Messages.jsx @@ -11,6 +11,7 @@ const Message = ({ text, actions }) => { alt="loading loan facilities" width={100} height={100} + priority /> {text} {actions} diff --git a/src/core/components/UploadSystem.jsx b/src/core/components/UploadSystem.jsx new file mode 100644 index 0000000..b60552a --- /dev/null +++ b/src/core/components/UploadSystem.jsx @@ -0,0 +1,163 @@ +import { Box, Button, TextField, Typography } from "@mui/material"; +import { useTranslations } from "next-intl"; +import Image from "next/image"; +import DeleteForeverIcon from "@mui/icons-material/DeleteForever"; +import { useRef } from "react"; + +const UploadSystem = ({ + selectedImage, + setselectedImage, + handleUploadChange, + fieldname, + setFieldValue, + imageAlt, + imageSize, + fileType, + fileName, +}) => { + const t = useTranslations(); + const fileInputRef = useRef(null); + + const handleClick = () => { + fileInputRef.current.click(); + }; + const handleDeleteImage = () => { + setselectedImage("/images/upload-image.svg"); + setFieldValue(fieldname, null); + }; + + const isDocumentFormat = (fileType) => { + const documentFormats = [ + "application/pdf", + "application/msword", + "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + "application/vnd.ms-excel", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + ]; + return documentFormats.includes(fileType); + }; + + return ( + + {selectedImage === "/images/upload-image.svg" ? ( + {imageAlt} + ) : fileType && fileType.startsWith("image/") ? ( + {imageAlt} + ) : ( + fileType && + isDocumentFormat(fileType) && ( + + + {fileName} + + + ) + )} + + + + + ); +}; + +export default UploadSystem; + + + +//////****** usage document ******///////// +// 1.) use component inside your page +// 2.) list of props that you need to send is down below +// 2.1) selectedImage // this value come from useState that you need to write on your own component +// 2.2) handleUploadChange // use on your own component (explain below more) you should set it to {(e) =>handleUploadChange[your special name]](e, props.setFieldValue)} +// 2.3) setFieldValue // for setting value of file to null when user click on Delete button. you should set it to {props.setFieldValue} +// 2.4) fieldname name that file field has on your formik initialValues. +// 2.5) fileType // type of your file shows its document image etc... +// 2.6) imageAlt // alt of your image. +// 2.7) imageSize // this is size of your image box and value type is like that imageSize={ [width , height] }. +// 2.9) setselectedImage // for making box empty when user click on delete button (explain below more) + +// const [selectedImage[your special name]], setSelectedImage[your special name]] = useState( +// "/images/upload-image.svg" // default image +// ); +// const [fileType[your special name], setFileType[your special name]] = useState(null); +// const [fileName[your special name], setFileName[your special name]] = useState(null); + + +// const handleUploadChange[your special name]] = (event, setFieldValue) => { +// const uploadedFile = event.target?.files?.[0]; +// const fileType = event.target.files[0].type; +// const fileName = event.target.files[0].name; +// if (uploadedFile) { // just check file is uploaded or not +// setSelectedImage[your special name]](URL.createObjectURL(uploadedFile)); // set image value +// setFileType[your special name]](fileType); // set fileType +// setFileName[your special name]](fileName); // set fileName +// setFieldValue("[your special name]]_img", uploadedFile); set field value for sending data (this automaticaly append value in initial state) +// } +// }; +//////****** end usage document ******///////// diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index b4a2241..ebbd73c 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -5,5 +5,7 @@ export const LOGIN = BASE_URL + "/login"; export const REGISTER_SEND_OTP_TOKEN = BASE_URL + "/register/send_otp"; export const REGISTER = BASE_URL + "/register"; export const USER_INFO = BASE_URL + "/profile/info"; +export const SEND_LOAN_REQUEST_NAVGAN = BASE_URL + "/navgan/store_loan"; +export const SEND_LOAN_REQUEST_WELFARE = BASE_URL + "/navgan/store_loan"; From 7df12b0f450d842dd62ca7362650c0807729d527 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Wed, 19 Jul 2023 10:34:46 +0330 Subject: [PATCH 19/54] debug uploading system --- public/locales/fa/app.json | 4 +++- .../dashboard/loan-request/WelfareServicesForm.jsx | 6 ++++-- src/core/components/UploadSystem.jsx | 13 +++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 138c4b9..9359b01 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -98,6 +98,8 @@ "text_field_enter_your_shenasname_id": "شماره شناسنامه خود را وارد کنید", "text_field_plate_number": "شماره پلاک", "text_field_enter_your_plate_number": "شماره پلاک خود را وارد کنید", - "button_submit": "ثبت درخواست" + "button_submit": "ثبت درخواست", + "file_field_shenasname_image": "تصویر شناسنامه", + "file_field_national_card_image": "تصویر کارت ملی" } } diff --git a/src/components/dashboard/loan-request/WelfareServicesForm.jsx b/src/components/dashboard/loan-request/WelfareServicesForm.jsx index 4ea21b6..335da6c 100644 --- a/src/components/dashboard/loan-request/WelfareServicesForm.jsx +++ b/src/components/dashboard/loan-request/WelfareServicesForm.jsx @@ -29,9 +29,9 @@ const WelfareServicesForm = () => { const handleUploadChangeShenasname = (event, setFieldValue) => { const uploadedFile = event.target?.files?.[0]; - const fileType = event.target.files[0].type; - const fileName = event.target.files[0].name; if (uploadedFile) { + const fileType = event.target?.files?.[0].type; + const fileName = event.target?.files?.[0].name; setSelectedImageShenasname(URL.createObjectURL(uploadedFile)); setFileTypeShenasname(fileType); setFileNameShenasname(fileName); @@ -380,6 +380,7 @@ const WelfareServicesForm = () => { fileName={fileNameShenasname} imageAlt={t("app_name")} imageSize={[300 /*width*/, 150 /*height*/]} + label={t("LoanRequest.file_field_shenasname_image")} /> { fileName={fileNameNationalCard} imageAlt={t("app_name")} imageSize={[300 /*width*/, 150 /*height*/]} + label={t("LoanRequest.file_field_national_card_image")} /> { const t = useTranslations(); const fileInputRef = useRef(null); @@ -39,6 +40,17 @@ const UploadSystem = ({ return ( + + {label} + {selectedImage === "/images/upload-image.svg" ? ( Date: Thu, 20 Jul 2023 10:39:58 +0330 Subject: [PATCH 20/54] file input design --- .../dashboard/loan-request/NavyForm.jsx | 227 ++++++++++++------ .../loan-request/WelfareServicesForm.jsx | 33 ++- src/core/components/SelectBox.jsx | 55 +++++ src/core/data/apiRoutes.js | 1 + 4 files changed, 235 insertions(+), 81 deletions(-) create mode 100644 src/core/components/SelectBox.jsx diff --git a/src/components/dashboard/loan-request/NavyForm.jsx b/src/components/dashboard/loan-request/NavyForm.jsx index 7686862..9e7c40c 100644 --- a/src/components/dashboard/loan-request/NavyForm.jsx +++ b/src/components/dashboard/loan-request/NavyForm.jsx @@ -1,16 +1,84 @@ import Notifications from "@/core/components/notifications"; +import SelectBox from "@/core/components/SelectBox"; import StyledForm from "@/core/components/StyledForm"; +import UploadSystem from "@/core/components/UploadSystem"; +import { + GET_PROVINCE_LIST, + SEND_LOAN_REQUEST_NAVGAN, +} from "@/core/data/apiRoutes"; import useDirection from "@/lib/app/hooks/useDirection"; +import useUser from "@/lib/app/hooks/useUser"; import DataSaverOnIcon from "@mui/icons-material/DataSaverOn"; import { Box, Button, Stack, TextField } from "@mui/material"; +import axios from "axios"; import { Field, Formik } from "formik"; import { useTranslations } from "next-intl"; -import Image from "next/image"; +import { useEffect, useState } from "react"; +import * as Yup from "yup"; const NavyForm = () => { const t = useTranslations(); const { directionApp } = useDirection(); + const { token } = useUser(); + // get province list + const [provinceList, setProvinceList] = useState([]); + useEffect(() => { + axios + .get(GET_PROVINCE_LIST, { + headers: { Authorization: `Bearer ${token}` }, + }) + .then(({ data }) => { + const formattedData = data.map((province, index) => ({ + id: index, + name: province.name, + value: province.id, + })); + setProvinceList(formattedData); + }) + .catch((error) => { + Notifications(directionApp, t, error.response); + }); + }, []); + // end get province list + + // upload files + const [selectedImageShenasname, setSelectedImageShenasname] = useState( + "/images/upload-image.svg" + ); + const [fileTypeShenasname, setFileTypeShenasname] = useState(null); + const [fileNameShenasname, setFileNameShenasname] = useState(null); + const [selectedImageNationalCard, setSelectedImageNationalCard] = useState( + "/images/upload-image.svg" + ); + const [fileTypeNationalCard, setFileTypeNationalCard] = useState(null); + const [fileNameNationalCard, setFileNameNationalCard] = useState(null); + + const handleUploadChangeShenasname = (event, setFieldValue) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const fileType = event.target?.files?.[0].type; + const fileName = event.target?.files?.[0].name; + setSelectedImageShenasname(URL.createObjectURL(uploadedFile)); + setFileTypeShenasname(fileType); + setFileNameShenasname(fileName); + setFieldValue("shenasname_img", uploadedFile); + } + }; + const handleUploadChangeNationalCard = (event, setFieldValue) => { + const uploadedFile = event.target?.files?.[0]; + const fileType = event.target.files[0].type; + const fileName = event.target.files[0].name; + if (uploadedFile) { + setSelectedImageNationalCard(URL.createObjectURL(uploadedFile)); + setFileTypeNationalCard(fileType); + setFileNameNationalCard(fileName); + setFieldValue("national_card_img", uploadedFile); + } + }; + // end upload files + + // initial values const initialValues = { name: "", phone_number: "", @@ -20,22 +88,57 @@ const NavyForm = () => { navgan_id: "", national_code: "", shenasname_id: "", - national_card_img: "", - shenasname_img: "", + national_card_img: null, + shenasname_img: null, }; + // end initial values + // validation + const validationSchema = Yup.object().shape({ + name: Yup.string().required(t("LoanRequest.error_message_required")), + phone_number: Yup.string().required( + t("LoanRequest.error_message_required") + ), + vehicle_type: Yup.string().required( + t("LoanRequest.error_message_required") + ), + plate_number: Yup.string().required( + t("LoanRequest.error_message_required") + ), + navgan_id: Yup.string().required(t("LoanRequest.error_message_required")), + province: Yup.string().required(t("LoanRequest.error_message_required")), + national_code: Yup.string().required( + t("LoanRequest.error_message_required") + ), + shenasname_id: Yup.string().required( + t("LoanRequest.error_message_required") + ), + }); + // end validation + + // submit const handleSubmit = async (values, props) => { Notifications(directionApp, t, undefined); + const formData = new FormData(); + formData.append("name", values.name); + formData.append("phone_number", values.phone_number); + formData.append("vehicle_type", values.vehicle_type); + formData.append("plate_number", values.plate_number); + formData.append("province_id", values.province); + formData.append("navgan_id", values.navgan_id); + formData.append("national_code", values.national_code); + formData.append("shenasname_id", values.shenasname_id); + if (values.shenasname_img != null) + formData.append("shenasname_image", values.shenasname_img); + if (values.national_card_img != null) + formData.append("national_card_image", values.national_card_img); + await axios - .post(SEND_LOAN_REQUEST_NAVGAN, { - name: values.name, - phone_number: values.phone_number, - vehicle_type: values.vehicle_type, - plate_number: values.plate_number, - province_id: values.province, - navgan_id: values.navgan_id, - national_code: values.national_code, - shenasname_id: values.shenasname_id, + .post(SEND_LOAN_REQUEST_NAVGAN, formData, { + headers: { + Authorization: `Bearer ${token}`, + "Content-Type": "multipart/form-data", + }, }) .then(function (response) { Notifications(directionApp, t, response); @@ -45,9 +148,14 @@ const NavyForm = () => { props.setSubmitting(false); }); }; + // end submit return ( - + {(props) => ( { name="name" variant="outlined" size="small" - InputProps={{ - readOnly: true, - }} label={t("LoanRequest.text_field_name")} placeholder={t("LoanRequest.text_field_enter_your_name")} type={"text"} @@ -103,9 +208,6 @@ const NavyForm = () => { name="phone_number" variant="outlined" size="small" - InputProps={{ - readOnly: true, - }} label={t("LoanRequest.text_field_phone_number")} placeholder={t( "LoanRequest.text_field_enter_your_phone_number" @@ -147,9 +249,6 @@ const NavyForm = () => { name="vehicle_type" variant="outlined" size="small" - InputProps={{ - readOnly: true, - }} label={t("LoanRequest.text_field_vehicle_type")} placeholder={t( "LoanRequest.text_field_enter_your_vehicle_type" @@ -181,9 +280,6 @@ const NavyForm = () => { name="plate_number" variant="outlined" size="small" - InputProps={{ - readOnly: true, - }} label={t("LoanRequest.text_field_plate_number")} placeholder={t( "LoanRequest.text_field_enter_your_plate_number" @@ -210,25 +306,20 @@ const NavyForm = () => { }} > @@ -255,9 +346,6 @@ const NavyForm = () => { name="navgan_id" variant="outlined" size="small" - InputProps={{ - readOnly: true, - }} label={t("LoanRequest.text_field_navgan_id")} placeholder={t("LoanRequest.text_field_enter_your_navgan_id")} type={"text"} @@ -285,9 +373,6 @@ const NavyForm = () => { name="national_code" variant="outlined" size="small" - InputProps={{ - readOnly: true, - }} label={t("LoanRequest.text_field_national_code")} placeholder={t( "LoanRequest.text_field_enter_your_national_code" @@ -319,17 +404,13 @@ const NavyForm = () => { name="shenasname_id" variant="outlined" size="small" - InputProps={{ - readOnly: true, - }} label={t("LoanRequest.text_field_shenasname_id")} placeholder={t( "LoanRequest.text_field_enter_your_shenasname_id" )} type={"text"} error={ - props.touched.shenasname_id && - props.errors.shenasname_id + props.touched.shenasname_id && props.errors.shenasname_id ? true : false } @@ -351,24 +432,34 @@ const NavyForm = () => { width: "100%", }} > - - {t("app_name")} - - - {t("app_name")} - + + handleUploadChangeShenasname(e, props.setFieldValue) + } + setselectedImage={setSelectedImageShenasname} + setFieldValue={props.setFieldValue} + fieldname="shenasname_img" + fileType={fileTypeShenasname} + fileName={fileNameShenasname} + imageAlt={t("app_name")} + imageSize={[300 /*width*/, 150 /*height*/]} + label={t("LoanRequest.file_field_shenasname_image")} + /> + + handleUploadChangeNationalCard(e, props.setFieldValue) + } + setselectedImage={setSelectedImageNationalCard} + setFieldValue={props.setFieldValue} + fieldname="national_card_img" + fileType={fileTypeNationalCard} + fileName={fileNameNationalCard} + imageAlt={t("app_name")} + imageSize={[300 /*width*/, 150 /*height*/]} + label={t("LoanRequest.file_field_national_card_image")} + /> { const t = useTranslations(); const { directionApp } = useDirection(); + const { token } = useUser(); // upload files const [selectedImageShenasname, setSelectedImageShenasname] = useState( @@ -86,20 +88,25 @@ const WelfareServicesForm = () => { const handleSubmit = async (values, props) => { Notifications(directionApp, t, undefined); - console.log(values.national_card_img); - console.log(values.shenasname_img); + const formData = new FormData(); + formData.append("name", values.name); + formData.append("phone_number", values.phone_number); + formData.append("vehicle_type", values.vehicle_type); + formData.append("plate_number", values.plate_number); + formData.append("province_id", values.province); + formData.append("national_code", values.national_code); + formData.append("shenasname_id", values.shenasname_id); + if (values.shenasname_img != null) + formData.append("shenasname_image", values.shenasname_img); + if (values.national_card_img != null) + formData.append("national_card_image", values.national_card_img); + await axios - .post(SEND_LOAN_REQUEST_WELFARE, { - name: values.name, - phone_number: values.phone_number, - vehicle_type: values.vehicle_type, - plate_number: values.plate_number, - province_id: values.province, - navgan_id: values.navgan_id, - national_code: values.national_code, - shenasname_id: values.shenasname_id, - national_card_image: values.national_card_img, - shenasname_image: values.shenasname_img, + .post(SEND_LOAN_REQUEST_WELFARE, formData, { + headers: { + Authorization: `Bearer ${token}`, + "Content-Type": "multipart/form-data", + }, }) .then(function (response) { Notifications(directionApp, t, response); diff --git a/src/core/components/SelectBox.jsx b/src/core/components/SelectBox.jsx new file mode 100644 index 0000000..ea39d54 --- /dev/null +++ b/src/core/components/SelectBox.jsx @@ -0,0 +1,55 @@ +import { + FormControl, + FormHelperText, + InputLabel, + MenuItem, + Select, +} from "@mui/material"; + +function SelectBox({ + select, + selectType, + selectors, + label, + setFieldValue, + setFieldTouched, + error, + helperText, +}) { + const handleChange = (event) => { + setFieldValue(selectType, event.target.value); + }; + const handleBlur = () => { + setFieldTouched(select, true); + }; + return ( + + {label} + + {helperText} + + ); +} + +export default SelectBox; diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index ebbd73c..87b4390 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -7,5 +7,6 @@ export const REGISTER = BASE_URL + "/register"; export const USER_INFO = BASE_URL + "/profile/info"; export const SEND_LOAN_REQUEST_NAVGAN = BASE_URL + "/navgan/store_loan"; export const SEND_LOAN_REQUEST_WELFARE = BASE_URL + "/navgan/store_loan"; +export const GET_PROVINCE_LIST = BASE_URL + "/provinces"; From a9929e8a09928cd3f7af7291840ce7972c90e1b7 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Mon, 24 Jul 2023 12:52:58 +0330 Subject: [PATCH 21/54] add publish script and work on registery pages --- package.json | 1 + public/locales/fa/app.json | 5 ++- src/components/register-navy/SendToken.jsx | 39 ++++++++++++++++++- src/components/register-navy/SendUserData.jsx | 9 +++-- src/components/register-navy/index.jsx | 4 ++ src/core/data/headerProfileItems.jsx | 12 ------ src/layouts/AppLayout.jsx | 18 ++++++++- .../dashboardLayouts/header/ProfileData.jsx | 3 -- 8 files changed, 68 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index cbb68a7..cd0e072 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "dev": "next dev", "build": "next build", "start": "next start", + "publish-3001": "next start -p 3001", "lint": "next lint" }, "dependencies": { diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 9359b01..84ffa11 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -71,7 +71,10 @@ "text_field_enter_your_navgan_id": "شماره ناوگان خود را وارد کنید", "error_message_required": "اجباری!", "button_request_verification": "دریافت کد یکبارمصرف", - "button_submit": "ورود" + "button_submit": "ورود", + "button_back_to_send_data": "بازگشت", + "sent_token_to": "ارسال پیامک به شماره", + "change_phone_number": "تغییر شماره" }, "Dashboard": { "dashboard_page": "داشبورد" diff --git a/src/components/register-navy/SendToken.jsx b/src/components/register-navy/SendToken.jsx index 62bbb86..376e18b 100644 --- a/src/components/register-navy/SendToken.jsx +++ b/src/components/register-navy/SendToken.jsx @@ -1,3 +1,4 @@ +import LinkRouting from "@/core/components/LinkRouting"; import Notifications from "@/core/components/notifications"; import StyledForm from "@/core/components/StyledForm"; import { REGISTER } from "@/core/data/apiRoutes"; @@ -6,12 +7,17 @@ import FullPageLayout from "@/layouts/FullPageLayout"; import useDirection from "@/lib/app/hooks/useDirection"; import useUser from "@/lib/app/hooks/useUser"; import LoginIcon from "@mui/icons-material/Login"; +import ReplyAllIcon from "@mui/icons-material/ReplyAll"; import { Box, Button, Container, + Grid, + Link, Paper, - Stack, TextField, Typography + Stack, + TextField, + Typography, } from "@mui/material"; import axios from "axios"; import { Field, Formik } from "formik"; @@ -19,7 +25,7 @@ import { useTranslations } from "next-intl"; import Image from "next/image"; import * as Yup from "yup"; -const SendToken = ({ PhoneNumber, nationalId, navganId, typeId }) => { +const SendToken = ({ PhoneNumber, nationalId, navganId, typeId, setOtpToken }) => { const t = useTranslations(); const { directionApp } = useDirection(); const { setToken } = useUser(); @@ -106,6 +112,33 @@ const SendToken = ({ PhoneNumber, nationalId, navganId, typeId }) => { : null } /> + {/* + + + */} + {/* */} + + {/* */} + {/* */} diff --git a/src/components/register-navy/SendUserData.jsx b/src/components/register-navy/SendUserData.jsx index 1433266..5bb09f4 100644 --- a/src/components/register-navy/SendUserData.jsx +++ b/src/components/register-navy/SendUserData.jsx @@ -23,8 +23,11 @@ import * as Yup from "yup"; const SendUserData = ({ setOtpToken, setPhoneNumber, + PhoneNumber, setNationalId, + nationalId, setNavganId, + navganId, setTypeId, }) => { const t = useTranslations(); @@ -35,9 +38,9 @@ const SendUserData = ({ const initialValues = { type_id: "1", - phone_number: "", - national_id: "", - navgan_id: "", + phone_number: PhoneNumber, + national_id: nationalId, + navgan_id: navganId, }; const validationSchema = Yup.object().shape({ phone_number: Yup.string().required( diff --git a/src/components/register-navy/index.jsx b/src/components/register-navy/index.jsx index 7a136c7..89b3596 100644 --- a/src/components/register-navy/index.jsx +++ b/src/components/register-navy/index.jsx @@ -17,6 +17,9 @@ const RegisterNavyComponent = () => { setNationalId={setNationalId} setNavganId={setNavganId} setTypeId={setTypeId} + PhoneNumber={PhoneNumber} + nationalId={nationalId} + navganId={navganId} /> ); } else { @@ -26,6 +29,7 @@ const RegisterNavyComponent = () => { nationalId={nationalId} navganId={navganId} typeId={typeId} + setOtpToken={setOtpToken} /> ); } diff --git a/src/core/data/headerProfileItems.jsx b/src/core/data/headerProfileItems.jsx index 63e661a..90831ba 100644 --- a/src/core/data/headerProfileItems.jsx +++ b/src/core/data/headerProfileItems.jsx @@ -2,18 +2,6 @@ import BorderColorIcon from "@mui/icons-material/BorderColor"; import PasswordIcon from "@mui/icons-material/Password"; const headerProfileItems = [ - { - key: 0, - name: "header.edit_profile", - route: "/dashboard/edit-profile", - icon: , - }, - { - key: 1, - name: "header.change_password", - route: "/dashboard/change-password", - icon: , - }, ]; export default headerProfileItems; diff --git a/src/layouts/AppLayout.jsx b/src/layouts/AppLayout.jsx index 2f7988e..fc4445f 100644 --- a/src/layouts/AppLayout.jsx +++ b/src/layouts/AppLayout.jsx @@ -1,4 +1,5 @@ import theme from "@/core/utils/theme"; +import useLanguage from "@/lib/app/hooks/useLanguage"; import useLoading from "@/lib/app/hooks/useLoading"; import useUser from "@/lib/app/hooks/useUser"; import Head from "next/head"; @@ -6,11 +7,17 @@ import NextNProgress from "nextjs-progressbar"; import { useEffect } from "react"; function AppLayout({ children, isBot }) { + const { languageIsReady } = useLanguage(); const { setLoadingPage } = useLoading(); - const { token, isAuth } = useUser(); + const { userChangedLanguage, token, isAuth } = useUser(); useEffect(() => { + if (languageIsReady) { if (token) { if (isAuth) { + if (userChangedLanguage) { + setLoadingPage(true); + return; + } setLoadingPage(false); return; } @@ -19,7 +26,14 @@ function AppLayout({ children, isBot }) { } setLoadingPage(false); return; - }, [token, isAuth]); + } + setLoadingPage(true); + }, [languageIsReady, token, isAuth, userChangedLanguage]); + + if (!isBot) { + if (userChangedLanguage) return; + if (!languageIsReady) return; + } return ( <> diff --git a/src/layouts/dashboardLayouts/header/ProfileData.jsx b/src/layouts/dashboardLayouts/header/ProfileData.jsx index c3fdf58..eb25403 100644 --- a/src/layouts/dashboardLayouts/header/ProfileData.jsx +++ b/src/layouts/dashboardLayouts/header/ProfileData.jsx @@ -10,9 +10,6 @@ export default function ProfileData() { alt="User Image" src={user.user_avatar} /> - - {user.user_username} - ); } From afcc799d95a59381519a23399e37a42170555b5b Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Mon, 24 Jul 2023 14:32:52 +0330 Subject: [PATCH 22/54] add change phone number button and refer action in both login register of navy and welfare --- public/locales/fa/app.json | 2 +- src/components/login-navy/SendToken.jsx | 22 ++++++- src/components/login-navy/SendUserData.jsx | 4 +- src/components/login-navy/index.jsx | 8 ++- .../login-welfare-services/SendUserData.jsx | 4 +- .../login-welfare-services/index.jsx | 8 ++- .../login-welfare-services/sendToken.jsx | 24 +++++++- src/components/register-navy/SendToken.jsx | 60 +++++++++---------- .../SendUserData.jsx | 6 +- .../register-welfare-services/index.jsx | 4 +- .../register-welfare-services/sendToken.jsx | 24 +++++++- 11 files changed, 116 insertions(+), 50 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 84ffa11..2461a38 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -73,7 +73,7 @@ "button_request_verification": "دریافت کد یکبارمصرف", "button_submit": "ورود", "button_back_to_send_data": "بازگشت", - "sent_token_to": "ارسال پیامک به شماره", + "sent_token_to": "ارسال کد یکبار مصرف به شماره", "change_phone_number": "تغییر شماره" }, "Dashboard": { diff --git a/src/components/login-navy/SendToken.jsx b/src/components/login-navy/SendToken.jsx index cbbb0ee..26eb4f7 100644 --- a/src/components/login-navy/SendToken.jsx +++ b/src/components/login-navy/SendToken.jsx @@ -5,6 +5,7 @@ import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import useDirection from "@/lib/app/hooks/useDirection"; import useUser from "@/lib/app/hooks/useUser"; +import ChangeCircleIcon from "@mui/icons-material/ChangeCircle"; import LoginIcon from "@mui/icons-material/Login"; import { Box, @@ -22,7 +23,7 @@ import { useTranslations } from "next-intl"; import Image from "next/image"; import * as Yup from "yup"; -const SendToken = ({ PhoneNumber }) => { +const SendToken = ({ PhoneNumber, setOtpToken }) => { const t = useTranslations(); const { directionApp } = useDirection(); const { setToken } = useUser(); @@ -81,6 +82,25 @@ const SendToken = ({ PhoneNumber }) => { + + + {t("RegisterPage.sent_token_to")}: {PhoneNumber}{" "} + + + { +const SendUserData = ({ setOtpToken, setPhoneNumber, PhoneNumber }) => { const t = useTranslations(); const { directionApp } = useDirection(); @@ -32,7 +32,7 @@ const SendUserData = ({ setOtpToken, setPhoneNumber }) => { const backUrlDecodedPath = searchParams.get("back_url"); const initialValues = { - phone_number: "", + phone_number: PhoneNumber, }; const validationSchema = Yup.object().shape({ phone_number: Yup.string().required(t("LoginPage.error_message_required")), diff --git a/src/components/login-navy/index.jsx b/src/components/login-navy/index.jsx index ba30668..2ea750f 100644 --- a/src/components/login-navy/index.jsx +++ b/src/components/login-navy/index.jsx @@ -8,10 +8,14 @@ const LoginComponent = () => { if (!otpToken) { return ( - + ); } else { - return ; + return ; } }; diff --git a/src/components/login-welfare-services/SendUserData.jsx b/src/components/login-welfare-services/SendUserData.jsx index 3541261..d9f5e2b 100644 --- a/src/components/login-welfare-services/SendUserData.jsx +++ b/src/components/login-welfare-services/SendUserData.jsx @@ -24,7 +24,7 @@ import Image from "next/image"; import { useSearchParams } from "next/navigation"; import * as Yup from "yup"; -const SendUserData = ({ setOtpToken, setPhoneNumber }) => { +const SendUserData = ({ setOtpToken, setPhoneNumber, PhoneNumber }) => { const t = useTranslations(); const { directionApp } = useDirection(); @@ -32,7 +32,7 @@ const SendUserData = ({ setOtpToken, setPhoneNumber }) => { const backUrlDecodedPath = searchParams.get("back_url"); const initialValues = { - phone_number: "", + phone_number: PhoneNumber, }; const validationSchema = Yup.object().shape({ phone_number: Yup.string().required(t("LoginPage.error_message_required")), diff --git a/src/components/login-welfare-services/index.jsx b/src/components/login-welfare-services/index.jsx index ba30668..2ea750f 100644 --- a/src/components/login-welfare-services/index.jsx +++ b/src/components/login-welfare-services/index.jsx @@ -8,10 +8,14 @@ const LoginComponent = () => { if (!otpToken) { return ( - + ); } else { - return ; + return ; } }; diff --git a/src/components/login-welfare-services/sendToken.jsx b/src/components/login-welfare-services/sendToken.jsx index 4d14dd1..2193883 100644 --- a/src/components/login-welfare-services/sendToken.jsx +++ b/src/components/login-welfare-services/sendToken.jsx @@ -6,6 +6,7 @@ import FullPageLayout from "@/layouts/FullPageLayout"; import useDirection from "@/lib/app/hooks/useDirection"; import useUser from "@/lib/app/hooks/useUser"; import LoginIcon from "@mui/icons-material/Login"; +import ChangeCircleIcon from "@mui/icons-material/ChangeCircle"; import { Box, Button, @@ -22,7 +23,7 @@ import { useTranslations } from "next-intl"; import Image from "next/image"; import * as Yup from "yup"; -const SendToken = ({ PhoneNumber }) => { +const SendToken = ({ PhoneNumber, setOtpToken }) => { const t = useTranslations(); const { directionApp } = useDirection(); const { setToken } = useUser(); @@ -77,10 +78,29 @@ const SendToken = ({ PhoneNumber }) => { /> - {t("login_navy")} + {t("login_welfare_services")} + + + {t("RegisterPage.sent_token_to")}: {PhoneNumber}{" "} + + + { +const SendToken = ({ + PhoneNumber, + nationalId, + navganId, + typeId, + setOtpToken, +}) => { const t = useTranslations(); const { directionApp } = useDirection(); const { setToken } = useUser(); @@ -90,6 +94,25 @@ const SendToken = ({ PhoneNumber, nationalId, navganId, typeId, setOtpToken }) = + + + {t("RegisterPage.sent_token_to")}: {PhoneNumber}{" "} + + + - {/* - - - */} - {/* */} - - {/* */} - {/* */} diff --git a/src/components/register-welfare-services/SendUserData.jsx b/src/components/register-welfare-services/SendUserData.jsx index 07fb6e0..ce818fa 100644 --- a/src/components/register-welfare-services/SendUserData.jsx +++ b/src/components/register-welfare-services/SendUserData.jsx @@ -27,6 +27,8 @@ const SendUserData = ({ setPhoneNumber, setNationalId, setTypeId, + PhoneNumber, + nationalId, }) => { const t = useTranslations(); const { directionApp } = useDirection(); @@ -36,8 +38,8 @@ const SendUserData = ({ const initialValues = { type_id: "2", - phone_number: "", - national_id: "", + phone_number: PhoneNumber, + national_id: nationalId, }; const validationSchema = Yup.object().shape({ phone_number: Yup.string().required( diff --git a/src/components/register-welfare-services/index.jsx b/src/components/register-welfare-services/index.jsx index 24678eb..a2fc649 100644 --- a/src/components/register-welfare-services/index.jsx +++ b/src/components/register-welfare-services/index.jsx @@ -6,7 +6,6 @@ const RegisterNavyComponent = () => { const [otpToken, setOtpToken] = useState(false); const [PhoneNumber, setPhoneNumber] = useState(""); const [nationalId, setNationalId] = useState(""); - const [navganId, setNavganId] = useState(""); const [typeId, setTypeId] = useState(""); if (!otpToken) { @@ -16,6 +15,8 @@ const RegisterNavyComponent = () => { setPhoneNumber={setPhoneNumber} setNationalId={setNationalId} setTypeId={setTypeId} + PhoneNumber={PhoneNumber} + nationalId={nationalId} /> ); } else { @@ -24,6 +25,7 @@ const RegisterNavyComponent = () => { PhoneNumber={PhoneNumber} nationalId={nationalId} typeId={typeId} + setOtpToken={setOtpToken} /> ); } diff --git a/src/components/register-welfare-services/sendToken.jsx b/src/components/register-welfare-services/sendToken.jsx index 5d5af44..b1e3651 100644 --- a/src/components/register-welfare-services/sendToken.jsx +++ b/src/components/register-welfare-services/sendToken.jsx @@ -6,6 +6,7 @@ import FullPageLayout from "@/layouts/FullPageLayout"; import useDirection from "@/lib/app/hooks/useDirection"; import useUser from "@/lib/app/hooks/useUser"; import LoginIcon from "@mui/icons-material/Login"; +import ChangeCircleIcon from "@mui/icons-material/ChangeCircle"; import { Box, Button, @@ -21,7 +22,7 @@ import { useTranslations } from "next-intl"; import Image from "next/image"; import * as Yup from "yup"; -const SendToken = ({ PhoneNumber, nationalId, typeId }) => { +const SendToken = ({ PhoneNumber, nationalId, typeId, setOtpToken }) => { const t = useTranslations(); const { directionApp } = useDirection(); const { setToken } = useUser(); @@ -80,10 +81,29 @@ const SendToken = ({ PhoneNumber, nationalId, typeId }) => { /> - {t("register_navy")} + {t("register_welfare_services")} + + + {t("RegisterPage.sent_token_to")}: {PhoneNumber}{" "} + + + Date: Mon, 24 Jul 2023 16:23:26 +0330 Subject: [PATCH 23/54] debug for lunching project --- public/locales/fa/app.json | 8 ++- src/components/login-navy/SendToken.jsx | 65 +++++++++++++++++---- src/components/login-navy/index.jsx | 10 +++- src/core/components/notifications/index.jsx | 4 +- 4 files changed, 71 insertions(+), 16 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 2461a38..b2b1a92 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -56,7 +56,10 @@ "link_routing_main_page": "صفحه اصلی", "error_message_required": "اجباری!", "button_make_account": "ایجاد حساب", - "button_request_verification": "دریافت کد یکبارمصرف" + "button_request_verification": "دریافت کد یکبارمصرف", + "resend_code": "ارسال دوباره کد", + "Resend_code_in": "ارسال مجدد کد در", + "seconds_later": "ثانیه دیگر" }, "RegisterPage": { "link_routing_back_to": "بازگشت به", @@ -74,7 +77,8 @@ "button_submit": "ورود", "button_back_to_send_data": "بازگشت", "sent_token_to": "ارسال کد یکبار مصرف به شماره", - "change_phone_number": "تغییر شماره" + "change_phone_number": "تغییر شماره", + "resend_code": "ارسال دوباره کد" }, "Dashboard": { "dashboard_page": "داشبورد" diff --git a/src/components/login-navy/SendToken.jsx b/src/components/login-navy/SendToken.jsx index 26eb4f7..65acff8 100644 --- a/src/components/login-navy/SendToken.jsx +++ b/src/components/login-navy/SendToken.jsx @@ -1,6 +1,6 @@ import Notifications from "@/core/components/notifications"; import StyledForm from "@/core/components/StyledForm"; -import { LOGIN } from "@/core/data/apiRoutes"; +import { LOGIN, LOGIN_SEND_OTP_TOKEN } from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import useDirection from "@/lib/app/hooks/useDirection"; @@ -8,22 +8,24 @@ import useUser from "@/lib/app/hooks/useUser"; import ChangeCircleIcon from "@mui/icons-material/ChangeCircle"; import LoginIcon from "@mui/icons-material/Login"; import { - Box, - Button, - Container, - Grid, - Paper, - Stack, - TextField, - Typography + Box, + Button, + Container, + Grid, + Link, + Paper, + Stack, + TextField, + Typography, } from "@mui/material"; import axios from "axios"; import { Field, Formik } from "formik"; import { useTranslations } from "next-intl"; import Image from "next/image"; +import { useEffect } from "react"; import * as Yup from "yup"; -const SendToken = ({ PhoneNumber, setOtpToken }) => { +const SendToken = ({ PhoneNumber, setOtpToken, timer, setTimer }) => { const t = useTranslations(); const { directionApp } = useDirection(); const { setToken } = useUser(); @@ -55,6 +57,35 @@ const SendToken = ({ PhoneNumber, setOtpToken }) => { }); }; + useEffect(() => { + let interval; + if (timer > 0) { + interval = setInterval(() => { + setTimer((prevTimer) => prevTimer - 1); + }, 1000); + } else { + clearInterval(interval); + } + + return () => clearInterval(interval); + }, [timer]); + + const handleResendClick = async () => { + if (timer != 0) return + Notifications(directionApp, t, undefined); + await axios + .post(LOGIN_SEND_OTP_TOKEN, { + phone_number: PhoneNumber, + }) + .then(function (response) { + Notifications(directionApp, t, response); + setTimer(30); + }) + .catch(function (error) { + Notifications(directionApp, t, error.response); + }); + }; + return ( @@ -90,7 +121,7 @@ const SendToken = ({ PhoneNumber, setOtpToken }) => { }} > - {t("RegisterPage.sent_token_to")}: {PhoneNumber}{" "} + {t("RegisterPage.sent_token_to")}: {PhoneNumber} + + {timer > 0 + ? `${t("LoginPage.Resend_code_in")}: ${timer} ${t( + "LoginPage.seconds_later" + )}` + : t("LoginPage.resend_code")} + diff --git a/src/components/login-navy/index.jsx b/src/components/login-navy/index.jsx index 2ea750f..957fcf5 100644 --- a/src/components/login-navy/index.jsx +++ b/src/components/login-navy/index.jsx @@ -5,6 +5,7 @@ import SendToken from "./SendToken"; const LoginComponent = () => { const [otpToken, setOtpToken] = useState(false); const [PhoneNumber, setPhoneNumber] = useState(""); + const [timer, setTimer] = useState(30); if (!otpToken) { return ( @@ -15,7 +16,14 @@ const LoginComponent = () => { /> ); } else { - return ; + return ( + + ); } }; diff --git a/src/core/components/notifications/index.jsx b/src/core/components/notifications/index.jsx index 9e8e52b..e3432c5 100644 --- a/src/core/components/notifications/index.jsx +++ b/src/core/components/notifications/index.jsx @@ -1,7 +1,7 @@ import { toast } from "react-toastify"; import ErrorNotification from "./ErrorNotification"; -import SuccessNotification from "./successNotification"; -import WarningNotification from "./warningNotification"; +import SuccessNotification from "./SuccessNotification"; +import WarningNotification from "./WarningNotification"; const Notifications = async (directionApp, t, response) => { console.log(directionApp, t, response); From befe7c5eebc0fe03d9895628970f116d8796733a Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Mon, 24 Jul 2023 16:39:15 +0330 Subject: [PATCH 24/54] debug launch --- src/components/login-navy/SendToken.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/login-navy/SendToken.jsx b/src/components/login-navy/SendToken.jsx index 65acff8..08a0de6 100644 --- a/src/components/login-navy/SendToken.jsx +++ b/src/components/login-navy/SendToken.jsx @@ -71,6 +71,7 @@ const SendToken = ({ PhoneNumber, setOtpToken, timer, setTimer }) => { }, [timer]); const handleResendClick = async () => { + // work on it if (timer != 0) return Notifications(directionApp, t, undefined); await axios From 5e565ea5d77796540d4933c4edc38eeabe715b65 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Mon, 24 Jul 2023 16:41:16 +0330 Subject: [PATCH 25/54] debug launch --- src/components/register-welfare-services/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/register-welfare-services/index.jsx b/src/components/register-welfare-services/index.jsx index a2fc649..b62e482 100644 --- a/src/components/register-welfare-services/index.jsx +++ b/src/components/register-welfare-services/index.jsx @@ -1,5 +1,5 @@ import { useState } from "react"; -import SendToken from "./SendToken"; +import SendToken from "./sendToken"; import SendUserData from "./SendUserData"; const RegisterNavyComponent = () => { From 5dae8eb48d26b645a1e7f8f94081ad44d26cf008 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Mon, 24 Jul 2023 16:47:48 +0330 Subject: [PATCH 26/54] debug launch --- src/components/login-welfare-services/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/login-welfare-services/index.jsx b/src/components/login-welfare-services/index.jsx index 2ea750f..304e4a4 100644 --- a/src/components/login-welfare-services/index.jsx +++ b/src/components/login-welfare-services/index.jsx @@ -1,6 +1,6 @@ import SendUserData from "./SendUserData"; import { useState } from "react"; -import SendToken from "./SendToken"; +import SendToken from "./sendToken"; const LoginComponent = () => { const [otpToken, setOtpToken] = useState(false); From 94a53702b099aa242a280bfd4155be0efbef0a8a Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Sat, 29 Jul 2023 16:24:29 +0330 Subject: [PATCH 27/54] Resend Token Core Component --- src/components/login-navy/SendToken.jsx | 66 +++++------------- src/components/login-navy/SendUserData.jsx | 11 ++- src/components/login-navy/index.jsx | 9 ++- src/core/components/ResendToken.jsx | 77 +++++++++++++++++++++ src/core/components/notifications/index.jsx | 1 - 5 files changed, 111 insertions(+), 53 deletions(-) create mode 100644 src/core/components/ResendToken.jsx diff --git a/src/components/login-navy/SendToken.jsx b/src/components/login-navy/SendToken.jsx index 08a0de6..e831c17 100644 --- a/src/components/login-navy/SendToken.jsx +++ b/src/components/login-navy/SendToken.jsx @@ -1,6 +1,7 @@ import Notifications from "@/core/components/notifications"; +import ResendToken from "@/core/components/ResendToken"; import StyledForm from "@/core/components/StyledForm"; -import { LOGIN, LOGIN_SEND_OTP_TOKEN } from "@/core/data/apiRoutes"; +import { LOGIN } from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import useDirection from "@/lib/app/hooks/useDirection"; @@ -11,21 +12,24 @@ import { Box, Button, Container, - Grid, - Link, - Paper, + Grid, Paper, Stack, TextField, - Typography, + Typography } from "@mui/material"; import axios from "axios"; import { Field, Formik } from "formik"; import { useTranslations } from "next-intl"; import Image from "next/image"; -import { useEffect } from "react"; import * as Yup from "yup"; -const SendToken = ({ PhoneNumber, setOtpToken, timer, setTimer }) => { +const SendToken = ({ + PhoneNumber, + setOtpToken, + timer, + setTimer, + initialTimerValue, +}) => { const t = useTranslations(); const { directionApp } = useDirection(); const { setToken } = useUser(); @@ -57,36 +61,6 @@ const SendToken = ({ PhoneNumber, setOtpToken, timer, setTimer }) => { }); }; - useEffect(() => { - let interval; - if (timer > 0) { - interval = setInterval(() => { - setTimer((prevTimer) => prevTimer - 1); - }, 1000); - } else { - clearInterval(interval); - } - - return () => clearInterval(interval); - }, [timer]); - - const handleResendClick = async () => { - // work on it - if (timer != 0) return - Notifications(directionApp, t, undefined); - await axios - .post(LOGIN_SEND_OTP_TOKEN, { - phone_number: PhoneNumber, - }) - .then(function (response) { - Notifications(directionApp, t, response); - setTimer(30); - }) - .catch(function (error) { - Notifications(directionApp, t, error.response); - }); - }; - return ( @@ -169,18 +143,12 @@ const SendToken = ({ PhoneNumber, setOtpToken, timer, setTimer }) => { - - {timer > 0 - ? `${t("LoginPage.Resend_code_in")}: ${timer} ${t( - "LoginPage.seconds_later" - )}` - : t("LoginPage.resend_code")} - + diff --git a/src/components/login-navy/SendUserData.jsx b/src/components/login-navy/SendUserData.jsx index 26b4d52..6b01af9 100644 --- a/src/components/login-navy/SendUserData.jsx +++ b/src/components/login-navy/SendUserData.jsx @@ -15,7 +15,7 @@ import { Paper, Stack, TextField, - Typography + Typography, } from "@mui/material"; import axios from "axios"; import { Field, Formik } from "formik"; @@ -24,7 +24,13 @@ import Image from "next/image"; import { useSearchParams } from "next/navigation"; import * as Yup from "yup"; -const SendUserData = ({ setOtpToken, setPhoneNumber, PhoneNumber }) => { +const SendUserData = ({ + setOtpToken, + setPhoneNumber, + PhoneNumber, + setTimer, + initialTimerValue, +}) => { const t = useTranslations(); const { directionApp } = useDirection(); @@ -48,6 +54,7 @@ const SendUserData = ({ setOtpToken, setPhoneNumber, PhoneNumber }) => { Notifications(directionApp, t, response); setPhoneNumber(values.phone_number); setOtpToken(true); + setTimer(initialTimerValue); }) .catch(function (error) { Notifications(directionApp, t, error.response); diff --git a/src/components/login-navy/index.jsx b/src/components/login-navy/index.jsx index 957fcf5..9d3f404 100644 --- a/src/components/login-navy/index.jsx +++ b/src/components/login-navy/index.jsx @@ -5,7 +5,11 @@ import SendToken from "./SendToken"; const LoginComponent = () => { const [otpToken, setOtpToken] = useState(false); const [PhoneNumber, setPhoneNumber] = useState(""); - const [timer, setTimer] = useState(30); + + // For Resend Token (read ResendToken Component Doc) + const initialTimerValue = 30; + const [timer, setTimer] = useState(initialTimerValue); + // End For Resend Token if (!otpToken) { return ( @@ -13,6 +17,8 @@ const LoginComponent = () => { setOtpToken={setOtpToken} setPhoneNumber={setPhoneNumber} PhoneNumber={PhoneNumber} + initialTimerValue={initialTimerValue} + setTimer={setTimer} /> ); } else { @@ -21,6 +27,7 @@ const LoginComponent = () => { PhoneNumber={PhoneNumber} setOtpToken={setOtpToken} timer={timer} + initialTimerValue={initialTimerValue} setTimer={setTimer} /> ); diff --git a/src/core/components/ResendToken.jsx b/src/core/components/ResendToken.jsx new file mode 100644 index 0000000..9bfc474 --- /dev/null +++ b/src/core/components/ResendToken.jsx @@ -0,0 +1,77 @@ +import Notifications from "@/core/components/notifications"; +import useDirection from "@/lib/app/hooks/useDirection"; +import { Typography } from "@mui/material"; +import axios from "axios"; +import { useTranslations } from "next-intl"; +import { useEffect } from "react"; +import { LOGIN_SEND_OTP_TOKEN } from "../data/apiRoutes"; + +const ResendToken = ({ initialTimerValue, timer, setTimer, PhoneNumber }) => { + const t = useTranslations(); + const { directionApp } = useDirection(); + + // Countdown Timer + useEffect(() => { + let interval; + if (timer > 0) { + interval = setInterval(() => { + setTimer((prevTimer) => prevTimer - 1); + }, 1000); + } else { + clearInterval(interval); + } + + return () => clearInterval(interval); + }, [timer]); + // End Countdown Timer + + // Handle Resend Token + const handleResendClick = async () => { + // work on it + if (timer != 0) return; + Notifications(directionApp, t, undefined); + await axios + .post(LOGIN_SEND_OTP_TOKEN, { + phone_number: PhoneNumber, + }) + .then(function (response) { + Notifications(directionApp, t, response); + setTimer(initialTimerValue); + }) + .catch(function (error) { + Notifications(directionApp, t, error.response); + }); + }; + // End Handle Resend Token + + return ( + <> + {timer > 0 ? ( + + {t("LoginPage.Resend_code_in")}: {timer} + {t("LoginPage.seconds_later")} + + ) : ( + + {t("LoginPage.resend_code")} + + )} + + ); +}; + +export default ResendToken; + + +//////****** usage document ******///////// +// 1.) use component inside your page +// 2.) list of props that you need to send is down below +// 2.1) initialTimerValue **** Delay Time For Sending Token +// 2.2) timer **** Timer Of Resending Token +// 2.3) setTimer **** Set Timer Of Resend (note: every places in your components if you are requesting for getting token you should use this prop like this setTimer(initialTimerValue) ) +// 2.4) PhoneNumber **** Phone Number That Should Recive Token diff --git a/src/core/components/notifications/index.jsx b/src/core/components/notifications/index.jsx index e3432c5..f27d437 100644 --- a/src/core/components/notifications/index.jsx +++ b/src/core/components/notifications/index.jsx @@ -4,7 +4,6 @@ import SuccessNotification from "./SuccessNotification"; import WarningNotification from "./WarningNotification"; const Notifications = async (directionApp, t, response) => { - console.log(directionApp, t, response); const { status, data } = response != undefined ? response : "" toast.dismiss(); switch (status) { From 07725cfe81ba5af80cfcf086274ea85c5763094e Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Mon, 31 Jul 2023 15:13:07 +0330 Subject: [PATCH 28/54] redesign and make more flexible login register system --- public/locales/fa/app.json | 19 +- src/components/first/index.jsx | 50 ++---- .../login-welfare-services/SendUserData.jsx | 166 ------------------ .../login-welfare-services/index.jsx | 22 --- .../login-welfare-services/sendToken.jsx | 152 ---------------- .../{login-navy => login}/SendToken.jsx | 17 +- .../{login-navy => login}/SendUserData.jsx | 8 +- .../{login-navy => login}/index.jsx | 2 +- src/components/register-navy/SendToken.jsx | 160 ----------------- src/components/register-navy/index.jsx | 38 ---- .../register-welfare-services/index.jsx | 34 ---- .../RequestOtp.jsx} | 56 ++---- src/components/register/index.jsx | 98 +++++++++++ .../navy/UserRegister.jsx} | 114 +++++++----- src/components/register/navy/index.jsx | 37 ++++ .../welfare-services/UserRegister.jsx} | 75 ++++++-- .../register/welfare-services/index.jsx | 37 ++++ src/core/components/ResendToken.jsx | 33 ++-- src/core/data/apiRoutes.js | 7 +- .../{login-welfare-services.jsx => login.jsx} | 4 +- .../{login-navy.jsx => register/index.jsx} | 8 +- .../navy/index.jsx} | 6 +- .../welfare-services/index.jsx} | 6 +- 23 files changed, 385 insertions(+), 764 deletions(-) delete mode 100644 src/components/login-welfare-services/SendUserData.jsx delete mode 100644 src/components/login-welfare-services/index.jsx delete mode 100644 src/components/login-welfare-services/sendToken.jsx rename src/components/{login-navy => login}/SendToken.jsx (91%) rename src/components/{login-navy => login}/SendUserData.jsx (96%) rename src/components/{login-navy => login}/index.jsx (100%) delete mode 100644 src/components/register-navy/SendToken.jsx delete mode 100644 src/components/register-navy/index.jsx delete mode 100644 src/components/register-welfare-services/index.jsx rename src/components/{register-welfare-services/SendUserData.jsx => register/RequestOtp.jsx} (74%) create mode 100644 src/components/register/index.jsx rename src/components/{register-navy/SendUserData.jsx => register/navy/UserRegister.jsx} (66%) create mode 100644 src/components/register/navy/index.jsx rename src/components/{register-welfare-services/sendToken.jsx => register/welfare-services/UserRegister.jsx} (67%) create mode 100644 src/components/register/welfare-services/index.jsx rename src/pages/{login-welfare-services.jsx => login.jsx} (85%) rename src/pages/{login-navy.jsx => register/index.jsx} (81%) rename src/pages/{register-navy.jsx => register/navy/index.jsx} (85%) rename src/pages/{register-welfare-services.jsx => register/welfare-services/index.jsx} (84%) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index b2b1a92..f1b9ed2 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -4,14 +4,16 @@ "dashboard": "داشبورد", "first_page": "خوش آمدید", "login": "ورود", - "login_navy": "ورود اعضای ناوگان", + "login_user_panel": "ورود به پنل کاربران", "register_navy": "ثبت نام اعضای ناوگان", - "login_welfare_services": "ورود اعضای خدمات رفاهی", "register_welfare_services": "ثبت نام اعضای خدمات رفاهی", "pending": "درحال اجرا...", "user_navy": "ناوگان", "page_not_found": "صفحه مورد نظر یافت نشد", "delete": "حذف", + "resend_code": "ارسال مجدد کد", + "Resend_code_in": "ارسال مجدد کد در", + "seconds_later": "ثانیه دیگر", "header": { "open_profile": "پروفایل", "edit_profile": "ویرایش پروفایل", @@ -27,6 +29,7 @@ }, "Titles": { "title_login_page": "صفحه ورود", + "title_register_page": "صفحه ثبت نام", "title_login_navy_page": "ورود اعضای ناوگان", "title_login_welfare_services_page": "ورود اعضای خدمات رفاهی", "title_register_navy_page": "ثبت نام اعضای ناوگان", @@ -57,13 +60,13 @@ "error_message_required": "اجباری!", "button_make_account": "ایجاد حساب", "button_request_verification": "دریافت کد یکبارمصرف", - "resend_code": "ارسال دوباره کد", - "Resend_code_in": "ارسال مجدد کد در", - "seconds_later": "ثانیه دیگر" + "sent_token_to": "ارسال کد یکبار مصرف به شماره", + "change_phone_number": "تغییر شماره" }, "RegisterPage": { "link_routing_back_to": "بازگشت به", - "link_routing_login_navy": "صفحه ورود", + "link_routing_register": "صفحه انتخاب نوع ثبت نام", + "link_routing_login": "صفحه ورود", "text_field_phone_number": "شماره تلفن", "text_field_enter_your_phone_number": "شماره تلفن خود را وارد کنید", "text_field_verification_code": "کد یکبار مصرف", @@ -74,11 +77,11 @@ "text_field_enter_your_navgan_id": "شماره ناوگان خود را وارد کنید", "error_message_required": "اجباری!", "button_request_verification": "دریافت کد یکبارمصرف", - "button_submit": "ورود", + "button_submit": "ثبت و ورود", "button_back_to_send_data": "بازگشت", "sent_token_to": "ارسال کد یکبار مصرف به شماره", "change_phone_number": "تغییر شماره", - "resend_code": "ارسال دوباره کد" + "complete_information": "مشخصات" }, "Dashboard": { "dashboard_page": "داشبورد" diff --git a/src/components/first/index.jsx b/src/components/first/index.jsx index edd3a8a..1436752 100644 --- a/src/components/first/index.jsx +++ b/src/components/first/index.jsx @@ -4,7 +4,7 @@ import StyledImage from "@/core/components/StyledImage"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import useUser from "@/lib/app/hooks/useUser"; -import { Box, Button, Grid, Typography } from "@mui/material"; +import { Button, Typography } from "@mui/material"; import { useTranslations } from "next-intl"; const FirstComponent = () => { @@ -35,43 +35,17 @@ const FirstComponent = () => { {t("dashboard")} ) : ( - - - - - - - - - - + )} diff --git a/src/components/login-welfare-services/SendUserData.jsx b/src/components/login-welfare-services/SendUserData.jsx deleted file mode 100644 index d9f5e2b..0000000 --- a/src/components/login-welfare-services/SendUserData.jsx +++ /dev/null @@ -1,166 +0,0 @@ -import Notifications from "@/core/components/notifications"; -import LinkRouting from "@/core/components/LinkRouting"; -import StyledForm from "@/core/components/StyledForm"; -import { LOGIN_SEND_OTP_TOKEN } from "@/core/data/apiRoutes"; -import CenterLayout from "@/layouts/CenterLayout"; -import FullPageLayout from "@/layouts/FullPageLayout"; -import useDirection from "@/lib/app/hooks/useDirection"; -import FingerprintIcon from "@mui/icons-material/Fingerprint"; -import PersonAddIcon from "@mui/icons-material/PersonAdd"; -import { - Box, - Button, - Container, - Grid, - Paper, - Stack, - TextField, - Typography, -} from "@mui/material"; -import axios from "axios"; -import { Field, Formik } from "formik"; -import { useTranslations } from "next-intl"; -import Image from "next/image"; -import { useSearchParams } from "next/navigation"; -import * as Yup from "yup"; - -const SendUserData = ({ setOtpToken, setPhoneNumber, PhoneNumber }) => { - const t = useTranslations(); - const { directionApp } = useDirection(); - - const searchParams = useSearchParams(); - const backUrlDecodedPath = searchParams.get("back_url"); - - const initialValues = { - phone_number: PhoneNumber, - }; - const validationSchema = Yup.object().shape({ - phone_number: Yup.string().required(t("LoginPage.error_message_required")), - }); - - const handleSubmit = async (values, props) => { - Notifications(directionApp, t, undefined); - await axios - .post(LOGIN_SEND_OTP_TOKEN, { - phone_number: values.phone_number, - }) - .then(function (response) { - Notifications(directionApp, t, response); - setPhoneNumber(values.phone_number); - setOtpToken(true); - }) - .catch(function (error) { - Notifications(directionApp, t, error.response); - props.setSubmitting(false); - }); - }; - - return ( - - - - - - {(props) => ( - - - {t("app_name")} - - - {t("login_welfare_services")} - - - - - - - - - - - - - - - - - - )} - - - - - - - {t("LoginPage.link_routing_back_to")}{" "} - {backUrlDecodedPath - ? t("LoginPage.link_routing_previuos_page") - : t("LoginPage.link_routing_main_page")} - - - - ); -}; - -export default SendUserData; diff --git a/src/components/login-welfare-services/index.jsx b/src/components/login-welfare-services/index.jsx deleted file mode 100644 index 304e4a4..0000000 --- a/src/components/login-welfare-services/index.jsx +++ /dev/null @@ -1,22 +0,0 @@ -import SendUserData from "./SendUserData"; -import { useState } from "react"; -import SendToken from "./sendToken"; - -const LoginComponent = () => { - const [otpToken, setOtpToken] = useState(false); - const [PhoneNumber, setPhoneNumber] = useState(""); - - if (!otpToken) { - return ( - - ); - } else { - return ; - } -}; - -export default LoginComponent; diff --git a/src/components/login-welfare-services/sendToken.jsx b/src/components/login-welfare-services/sendToken.jsx deleted file mode 100644 index 2193883..0000000 --- a/src/components/login-welfare-services/sendToken.jsx +++ /dev/null @@ -1,152 +0,0 @@ -import Notifications from "@/core/components/notifications"; -import StyledForm from "@/core/components/StyledForm"; -import { LOGIN } from "@/core/data/apiRoutes"; -import CenterLayout from "@/layouts/CenterLayout"; -import FullPageLayout from "@/layouts/FullPageLayout"; -import useDirection from "@/lib/app/hooks/useDirection"; -import useUser from "@/lib/app/hooks/useUser"; -import LoginIcon from "@mui/icons-material/Login"; -import ChangeCircleIcon from "@mui/icons-material/ChangeCircle"; -import { - Box, - Button, - Container, - Grid, - Paper, - Stack, - TextField, - Typography, -} from "@mui/material"; -import axios from "axios"; -import { Field, Formik } from "formik"; -import { useTranslations } from "next-intl"; -import Image from "next/image"; -import * as Yup from "yup"; - -const SendToken = ({ PhoneNumber, setOtpToken }) => { - const t = useTranslations(); - const { directionApp } = useDirection(); - const { setToken } = useUser(); - - const initialValues = { - phone_number: PhoneNumber, - verification_code: "", - }; - const validationSchema = Yup.object().shape({ - verification_code: Yup.string().required( - t("LoginPage.error_message_required") - ), - }); - - const handleSubmit = async (values, props) => { - Notifications(directionApp, t, undefined); - await axios - .post(LOGIN, { - phone_number: values.phone_number, - verification_code: values.verification_code, - }) - .then(function (response) { - Notifications(directionApp, t, response); - setToken(response.data.token); - }) - .catch(function (error) { - Notifications(directionApp, t, error.response); - props.setSubmitting(false); - }); - }; - - return ( - - - - - - {(props) => ( - - - {t("app_name")} - - - {t("login_welfare_services")} - - - - - - {t("RegisterPage.sent_token_to")}: {PhoneNumber}{" "} - - - - - - - - - - - - - )} - - - - - - ); -}; - -export default SendToken; diff --git a/src/components/login-navy/SendToken.jsx b/src/components/login/SendToken.jsx similarity index 91% rename from src/components/login-navy/SendToken.jsx rename to src/components/login/SendToken.jsx index e831c17..6567084 100644 --- a/src/components/login-navy/SendToken.jsx +++ b/src/components/login/SendToken.jsx @@ -12,10 +12,11 @@ import { Box, Button, Container, - Grid, Paper, + Grid, + Paper, Stack, TextField, - Typography + Typography, } from "@mui/material"; import axios from "axios"; import { Field, Formik } from "formik"; @@ -84,27 +85,29 @@ const SendToken = ({ /> - {t("login_navy")} + {t("login")} - - {t("RegisterPage.sent_token_to")}: {PhoneNumber} + + {t("LoginPage.sent_token_to")}: {PhoneNumber} { Notifications(directionApp, t, undefined); await axios - .post(LOGIN_SEND_OTP_TOKEN, { + .post(SEND_OTP_TOKEN, { phone_number: values.phone_number, }) .then(function (response) { @@ -85,7 +85,7 @@ const SendUserData = ({ /> - {t("login_navy")} + {t("Titles.title_login_page")} @@ -119,7 +119,7 @@ const SendUserData = ({ }} > - + - - - - - - - )} - - - - - - ); -}; - -export default SendToken; diff --git a/src/components/register-navy/index.jsx b/src/components/register-navy/index.jsx deleted file mode 100644 index 89b3596..0000000 --- a/src/components/register-navy/index.jsx +++ /dev/null @@ -1,38 +0,0 @@ -import { useState } from "react"; -import SendToken from "./SendToken"; -import SendUserData from "./SendUserData"; - -const RegisterNavyComponent = () => { - const [otpToken, setOtpToken] = useState(false); - const [PhoneNumber, setPhoneNumber] = useState(""); - const [nationalId, setNationalId] = useState(""); - const [navganId, setNavganId] = useState(""); - const [typeId, setTypeId] = useState(""); - - if (!otpToken) { - return ( - - ); - } else { - return ( - - ); - } -}; - -export default RegisterNavyComponent; diff --git a/src/components/register-welfare-services/index.jsx b/src/components/register-welfare-services/index.jsx deleted file mode 100644 index b62e482..0000000 --- a/src/components/register-welfare-services/index.jsx +++ /dev/null @@ -1,34 +0,0 @@ -import { useState } from "react"; -import SendToken from "./sendToken"; -import SendUserData from "./SendUserData"; - -const RegisterNavyComponent = () => { - const [otpToken, setOtpToken] = useState(false); - const [PhoneNumber, setPhoneNumber] = useState(""); - const [nationalId, setNationalId] = useState(""); - const [typeId, setTypeId] = useState(""); - - if (!otpToken) { - return ( - - ); - } else { - return ( - - ); - } -}; - -export default RegisterNavyComponent; diff --git a/src/components/register-welfare-services/SendUserData.jsx b/src/components/register/RequestOtp.jsx similarity index 74% rename from src/components/register-welfare-services/SendUserData.jsx rename to src/components/register/RequestOtp.jsx index ce818fa..3c209d9 100644 --- a/src/components/register-welfare-services/SendUserData.jsx +++ b/src/components/register/RequestOtp.jsx @@ -1,7 +1,7 @@ import LinkRouting from "@/core/components/LinkRouting"; import Notifications from "@/core/components/notifications"; import StyledForm from "@/core/components/StyledForm"; -import { REGISTER_SEND_OTP_TOKEN } from "@/core/data/apiRoutes"; +import { SEND_OTP_TOKEN } from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import useDirection from "@/lib/app/hooks/useDirection"; @@ -22,13 +22,12 @@ import Image from "next/image"; import { useSearchParams } from "next/navigation"; import * as Yup from "yup"; -const SendUserData = ({ +const RequestOtp = ({ setOtpToken, setPhoneNumber, - setNationalId, - setTypeId, PhoneNumber, - nationalId, + setTimer, + initialTimerValue, }) => { const t = useTranslations(); const { directionApp } = useDirection(); @@ -37,33 +36,25 @@ const SendUserData = ({ const backUrlDecodedPath = searchParams.get("back_url"); const initialValues = { - type_id: "2", phone_number: PhoneNumber, - national_id: nationalId, }; const validationSchema = Yup.object().shape({ phone_number: Yup.string().required( t("RegisterPage.error_message_required") ), - national_id: Yup.string().required( - t("RegisterPage.error_message_required") - ), }); const handleSubmit = async (values, props) => { Notifications(directionApp, t, undefined); await axios - .post(REGISTER_SEND_OTP_TOKEN, { - type_id: values.type_id, - national_id: values.national_id, + .post(SEND_OTP_TOKEN, { phone_number: values.phone_number, }) .then(function (response) { Notifications(directionApp, t, response); setPhoneNumber(values.phone_number); - setNationalId(values.national_id); - setTypeId(values.type_id); setOtpToken(true); + setTimer(initialTimerValue); }) .catch(function (error) { Notifications(directionApp, t, error.response); @@ -88,13 +79,13 @@ const SendUserData = ({ > {t("app_name")} - {t("register_welfare_services")} + {t("Titles.title_register_page")} @@ -120,27 +111,6 @@ const SendUserData = ({ : null } /> - + ) : ( + + + + + + + + + + + )} + + + + {t("RegisterPage.link_routing_back_to")}{" "} + {backUrlDecodedPath + ? t("RegisterPage.link_routing_previuos_page") + : t("RegisterPage.link_routing_login")} + + + + ); +}; + +export default RegisterComponent; diff --git a/src/components/register-navy/SendUserData.jsx b/src/components/register/navy/UserRegister.jsx similarity index 66% rename from src/components/register-navy/SendUserData.jsx rename to src/components/register/navy/UserRegister.jsx index 5bb09f4..e9d618a 100644 --- a/src/components/register-navy/SendUserData.jsx +++ b/src/components/register/navy/UserRegister.jsx @@ -1,49 +1,51 @@ -import LinkRouting from "@/core/components/LinkRouting"; import Notifications from "@/core/components/notifications"; import StyledForm from "@/core/components/StyledForm"; -import { REGISTER_SEND_OTP_TOKEN } from "@/core/data/apiRoutes"; +import { REGISTER } from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import useDirection from "@/lib/app/hooks/useDirection"; -import FingerprintIcon from "@mui/icons-material/Fingerprint"; +import LoginIcon from "@mui/icons-material/Login"; +import ChangeCircleIcon from "@mui/icons-material/ChangeCircle"; import { Box, Button, + Chip, Container, + Divider, Paper, - Stack, TextField, Typography + Stack, + TextField, + Typography, } from "@mui/material"; import axios from "axios"; import { Field, Formik } from "formik"; import { useTranslations } from "next-intl"; import Image from "next/image"; -import { useSearchParams } from "next/navigation"; import * as Yup from "yup"; +import ResendToken from "@/core/components/ResendToken"; +import useUser from "@/lib/app/hooks/useUser"; -const SendUserData = ({ - setOtpToken, - setPhoneNumber, +const UserRegister = ({ PhoneNumber, - setNationalId, - nationalId, - setNavganId, - navganId, - setTypeId, + setOtpToken, + initialTimerValue, + timer, + setTimer, }) => { const t = useTranslations(); const { directionApp } = useDirection(); - - const searchParams = useSearchParams(); - const backUrlDecodedPath = searchParams.get("back_url"); + const { setToken } = useUser(); const initialValues = { type_id: "1", + verification_code: "", phone_number: PhoneNumber, - national_id: nationalId, - navgan_id: navganId, + national_id: "", + navgan_id: "", }; + const validationSchema = Yup.object().shape({ - phone_number: Yup.string().required( + verification_code: Yup.string().required( t("RegisterPage.error_message_required") ), national_id: Yup.string().required( @@ -54,20 +56,19 @@ const SendUserData = ({ const handleSubmit = async (values, props) => { Notifications(directionApp, t, undefined); + console.log(initialValues); await axios - .post(REGISTER_SEND_OTP_TOKEN, { + .post(REGISTER, { type_id: values.type_id, national_id: values.national_id, navgan_id: values.navgan_id, phone_number: values.phone_number, + verification_code: values.verification_code, }) .then(function (response) { Notifications(directionApp, t, response); - setPhoneNumber(values.phone_number); - setNationalId(values.national_id); - setNavganId(values.navgan_id); - setTypeId(values.type_id); - setOtpToken(true) + setOtpToken(true); + setToken(response.data.token); }) .catch(function (error) { Notifications(directionApp, t, error.response); @@ -102,28 +103,58 @@ const SendUserData = ({ + + + {t("LoginPage.sent_token_to")}: {PhoneNumber} + + + + + + + } + endIcon={} disabled={props.isSubmitting ? true : false} > - {t("RegisterPage.button_request_verification")} + {t("RegisterPage.button_submit")} @@ -184,21 +215,8 @@ const SendUserData = ({ - - - {t("RegisterPage.link_routing_back_to")}{" "} - {t("RegisterPage.link_routing_login_navy")} - - ); }; -export default SendUserData; +export default UserRegister; diff --git a/src/components/register/navy/index.jsx b/src/components/register/navy/index.jsx new file mode 100644 index 0000000..f3c5938 --- /dev/null +++ b/src/components/register/navy/index.jsx @@ -0,0 +1,37 @@ +import { useState } from "react"; +import RequestOtp from "../RequestOtp"; +import UserRegister from "./UserRegister"; + +const NavyComponent = () => { + const [otpToken, setOtpToken] = useState(false); + const [PhoneNumber, setPhoneNumber] = useState(""); + + // For Resend Token (read ResendToken Component Doc) + const initialTimerValue = 30; + const [timer, setTimer] = useState(initialTimerValue); + // End For Resend Token + + if (!otpToken) { + return ( + + ); + } else { + return ( + + ); + } +}; + +export default NavyComponent; diff --git a/src/components/register-welfare-services/sendToken.jsx b/src/components/register/welfare-services/UserRegister.jsx similarity index 67% rename from src/components/register-welfare-services/sendToken.jsx rename to src/components/register/welfare-services/UserRegister.jsx index b1e3651..c15db81 100644 --- a/src/components/register-welfare-services/sendToken.jsx +++ b/src/components/register/welfare-services/UserRegister.jsx @@ -4,13 +4,14 @@ import { REGISTER } from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import useDirection from "@/lib/app/hooks/useDirection"; -import useUser from "@/lib/app/hooks/useUser"; import LoginIcon from "@mui/icons-material/Login"; import ChangeCircleIcon from "@mui/icons-material/ChangeCircle"; import { Box, Button, + Chip, Container, + Divider, Paper, Stack, TextField, @@ -21,35 +22,49 @@ import { Field, Formik } from "formik"; import { useTranslations } from "next-intl"; import Image from "next/image"; import * as Yup from "yup"; +import ResendToken from "@/core/components/ResendToken"; +import useUser from "@/lib/app/hooks/useUser"; -const SendToken = ({ PhoneNumber, nationalId, typeId, setOtpToken }) => { +const UserRegister = ({ + PhoneNumber, + setOtpToken, + initialTimerValue, + timer, + setTimer, +}) => { const t = useTranslations(); const { directionApp } = useDirection(); const { setToken } = useUser(); const initialValues = { - phone_number: PhoneNumber, - national_id: nationalId, - type_id: typeId, + type_id: "2", verification_code: "", + phone_number: PhoneNumber, + national_id: "", }; + const validationSchema = Yup.object().shape({ verification_code: Yup.string().required( t("RegisterPage.error_message_required") ), + national_id: Yup.string().required( + t("RegisterPage.error_message_required") + ), }); const handleSubmit = async (values, props) => { Notifications(directionApp, t, undefined); + console.log(initialValues); await axios .post(REGISTER, { - phone_number: values.phone_number, - national_id: values.national_id, type_id: values.type_id, + national_id: values.national_id, + phone_number: values.phone_number, verification_code: values.verification_code, }) .then(function (response) { Notifications(directionApp, t, response); + setOtpToken(true); setToken(response.data.token); }) .catch(function (error) { @@ -87,30 +102,32 @@ const SendToken = ({ PhoneNumber, nationalId, typeId, setOtpToken }) => { - - {t("RegisterPage.sent_token_to")}: {PhoneNumber}{" "} + + {t("LoginPage.sent_token_to")}: {PhoneNumber} { : null } /> + + + + + + ) : ( + )} ); @@ -67,7 +71,6 @@ const ResendToken = ({ initialTimerValue, timer, setTimer, PhoneNumber }) => { export default ResendToken; - //////****** usage document ******///////// // 1.) use component inside your page // 2.) list of props that you need to send is down below diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index 87b4390..77d4932 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -1,12 +1,13 @@ const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL + "/api"; -export const LOGIN_SEND_OTP_TOKEN = BASE_URL + "/login/send_otp"; +// export const LOGIN_SEND_OTP_TOKEN = BASE_URL + "/login/send_otp"; export const LOGIN = BASE_URL + "/login"; -export const REGISTER_SEND_OTP_TOKEN = BASE_URL + "/register/send_otp"; +// export const REGISTER_SEND_OTP_TOKEN = BASE_URL + "/register/send_otp"; +export const SEND_OTP_TOKEN = BASE_URL + "/otp"; export const REGISTER = BASE_URL + "/register"; export const USER_INFO = BASE_URL + "/profile/info"; export const SEND_LOAN_REQUEST_NAVGAN = BASE_URL + "/navgan/store_loan"; -export const SEND_LOAN_REQUEST_WELFARE = BASE_URL + "/navgan/store_loan"; +export const SEND_LOAN_REQUEST_WELFARE = BASE_URL + "/khadamat/store_loan"; export const GET_PROVINCE_LIST = BASE_URL + "/provinces"; diff --git a/src/pages/login-welfare-services.jsx b/src/pages/login.jsx similarity index 85% rename from src/pages/login-welfare-services.jsx rename to src/pages/login.jsx index f58412f..af22c17 100644 --- a/src/pages/login-welfare-services.jsx +++ b/src/pages/login.jsx @@ -1,4 +1,4 @@ -import LoginComponent from "@/components/login-welfare-services"; +import LoginComponent from "@/components/login"; import TitlePage from "@/core/components/TitlePage"; import WithoutAuthMiddleware from "@/middlewares/WithoutAuth"; import { parse } from "next-useragent"; @@ -10,7 +10,7 @@ export default function Login() { const { directionApp } = useDirection(); return ( - + {directionApp === "rtl" ? : } diff --git a/src/pages/login-navy.jsx b/src/pages/register/index.jsx similarity index 81% rename from src/pages/login-navy.jsx rename to src/pages/register/index.jsx index c358adf..c24f3f6 100644 --- a/src/pages/login-navy.jsx +++ b/src/pages/register/index.jsx @@ -1,4 +1,4 @@ -import LoginComponent from "@/components/login-navy"; +import RegisterComponent from "@/components/register"; import TitlePage from "@/core/components/TitlePage"; import WithoutAuthMiddleware from "@/middlewares/WithoutAuth"; import { parse } from "next-useragent"; @@ -6,12 +6,12 @@ import "react-toastify/dist/ReactToastify.css"; import { ToastContainer } from "react-toastify"; import useDirection from "@/lib/app/hooks/useDirection"; -export default function LoginNavy() { +export default function Register() { const { directionApp } = useDirection(); return ( - - + + {directionApp === "rtl" ? : } ); diff --git a/src/pages/register-navy.jsx b/src/pages/register/navy/index.jsx similarity index 85% rename from src/pages/register-navy.jsx rename to src/pages/register/navy/index.jsx index 7a6512f..4326d9d 100644 --- a/src/pages/register-navy.jsx +++ b/src/pages/register/navy/index.jsx @@ -1,4 +1,4 @@ -import RegisterNavyComponent from "@/components/register-navy"; +import NavyComponent from "@/components/register/navy"; import TitlePage from "@/core/components/TitlePage"; import WithoutAuthMiddleware from "@/middlewares/WithoutAuth"; import { parse } from "next-useragent"; @@ -6,12 +6,12 @@ import "react-toastify/dist/ReactToastify.css"; import { ToastContainer } from "react-toastify"; import useDirection from "@/lib/app/hooks/useDirection"; -export default function RegisterNavy() { +export default function Register() { const { directionApp } = useDirection(); return ( - + {directionApp === "rtl" ? : } ); diff --git a/src/pages/register-welfare-services.jsx b/src/pages/register/welfare-services/index.jsx similarity index 84% rename from src/pages/register-welfare-services.jsx rename to src/pages/register/welfare-services/index.jsx index bc2477f..ee6e603 100644 --- a/src/pages/register-welfare-services.jsx +++ b/src/pages/register/welfare-services/index.jsx @@ -1,4 +1,4 @@ -import RegisterComponent from "@/components/register-welfare-services"; +import WelfareServicesComponent from "@/components/register/welfare-services"; import TitlePage from "@/core/components/TitlePage"; import WithoutAuthMiddleware from "@/middlewares/WithoutAuth"; import { parse } from "next-useragent"; @@ -6,12 +6,12 @@ import "react-toastify/dist/ReactToastify.css"; import { ToastContainer } from "react-toastify"; import useDirection from "@/lib/app/hooks/useDirection"; -export default function RegisterWelfareServices() { +export default function Register() { const { directionApp } = useDirection(); return ( - + {directionApp === "rtl" ? : } ); From 51228f3c02bfbdd86e99efd696e9b470bc94475b Mon Sep 17 00:00:00 2001 From: Amirhossein Mahmoodi Date: Mon, 31 Jul 2023 15:27:34 +0330 Subject: [PATCH 29/54] recode and add editor config --- .editorconfig | 485 +++++++++ .gitignore | 3 +- README.md | 68 +- jsconfig.json | 8 +- next.config.js | 12 +- public/fontiran.scss | 131 +-- public/images/change-password.svg | 65 +- public/images/dashboard.svg | 105 +- public/images/loading.svg | 43 +- public/images/login.svg | 61 +- public/images/not-found.svg | 91 +- public/images/register.svg | 87 +- public/images/upload-image.svg | 93 +- public/locales/fa/datatable.js | 180 ++-- src/components/dashboard/first/index.jsx | 2 +- .../dashboard/loan-follow-up/index.jsx | 207 ++-- .../dashboard/loan-request/NavyForm.jsx | 933 +++++++++--------- .../loan-request/WelfareServicesForm.jsx | 828 ++++++++-------- .../dashboard/loan-request/index.jsx | 40 +- src/components/first/index.jsx | 88 +- src/components/login/SendToken.jsx | 283 +++--- src/components/login/SendUserData.jsx | 297 +++--- src/components/login/index.jsx | 56 +- src/components/not-found.jsx | 58 +- src/components/register/RequestOtp.jsx | 256 +++-- src/components/register/index.jsx | 169 ++-- src/components/register/navy/UserRegister.jsx | 390 ++++---- src/components/register/navy/index.jsx | 56 +- .../welfare-services/UserRegister.jsx | 342 ++++--- .../register/welfare-services/index.jsx | 56 +- src/core/components/LinkRouting.jsx | 176 ++-- src/core/components/LoadingHardPage.jsx | 70 +- src/core/components/Messages.jsx | 32 +- src/core/components/PasswordField.jsx | 52 +- src/core/components/ResendToken.jsx | 122 +-- src/core/components/SelectBox.jsx | 94 +- src/core/components/StyledForm.jsx | 4 +- src/core/components/StyledImage.jsx | 2 +- src/core/components/TitlePage.jsx | 20 +- src/core/components/UploadSystem.jsx | 257 +++-- src/core/components/isBotHandler.jsx | 8 +- .../notifications/ErrorNotification.jsx | 68 +- .../notifications/SuccessNotification.jsx | 74 +- .../notifications/WarningNotification.jsx | 70 +- src/core/components/notifications/index.jsx | 74 +- src/core/data/headerProfileItems.jsx | 6 +- src/core/data/sidebarMenu.jsx | 46 +- src/core/utils/createEmotionCache.jsx | 48 +- src/core/utils/theme-rtl.jsx | 12 +- src/core/utils/theme.jsx | 26 +- src/layouts/AppLayout.jsx | 168 ++-- src/layouts/CenterLayout.jsx | 26 +- src/layouts/FullPageLayout.jsx | 32 +- src/layouts/MuiLayout.jsx | 118 ++- src/layouts/ScrollableLayout.jsx | 38 +- .../breadcrumbs/BreadcrumbItem.jsx | 28 +- .../dashboardLayouts/breadcrumbs/index.jsx | 78 +- .../dashboardLayouts/header/ProfileData.jsx | 22 +- .../dashboardLayouts/header/ProfileMenu.jsx | 105 +- .../header/ProfileOptionLogOut.jsx | 90 +- .../header/ProfileOptions.jsx | 88 +- src/layouts/dashboardLayouts/header/index.jsx | 136 ++- src/layouts/dashboardLayouts/index.jsx | 70 +- .../sidebar/SidebarDrawer.jsx | 38 +- .../dashboardLayouts/sidebar/SidebarList.jsx | 94 +- .../sidebar/SidebarListItem.jsx | 105 +- .../sidebar/SidebarListSubItem.jsx | 90 +- .../dashboardLayouts/sidebar/index.jsx | 80 +- src/lib/app/contexts/language.jsx | 178 ++-- src/lib/app/contexts/loading.jsx | 18 +- src/lib/app/contexts/user.jsx | 201 ++-- src/lib/app/hooks/useDirection.jsx | 8 +- src/lib/app/hooks/useLanguage.jsx | 38 +- src/lib/app/hooks/useLoading.jsx | 8 +- src/lib/app/hooks/useUser.jsx | 60 +- src/middlewares/WithAuth.jsx | 68 +- src/middlewares/WithoutAuth.jsx | 92 +- src/pages/404.jsx | 16 +- src/pages/_app.jsx | 44 +- src/pages/_document.jsx | 104 +- src/pages/dashboard/index.jsx | 30 +- src/pages/dashboard/loan-follow-up/index.jsx | 30 +- src/pages/dashboard/loan-request/index.jsx | 30 +- src/pages/index.jsx | 30 +- src/pages/login.jsx | 36 +- src/pages/register/index.jsx | 36 +- src/pages/register/navy/index.jsx | 36 +- src/pages/register/welfare-services/index.jsx | 36 +- 88 files changed, 5121 insertions(+), 4138 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..05e5a39 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,485 @@ +root = true + +[*] +charset = utf-8 +end_of_line = crlf +indent_size = 4 +indent_style = space +insert_final_newline = false +max_line_length = 120 +tab_width = 4 +ij_continuation_indent_size = 4 +ij_formatter_off_tag = @formatter:off +ij_formatter_on_tag = @formatter:on +ij_formatter_tags_enabled = true +ij_smart_tabs = false +ij_visual_guides = none +ij_wrap_on_typing = false + +[*.css] +ij_css_align_closing_brace_with_properties = false +ij_css_blank_lines_around_nested_selector = 1 +ij_css_blank_lines_between_blocks = 1 +ij_css_block_comment_add_space = false +ij_css_brace_placement = end_of_line +ij_css_enforce_quotes_on_format = false +ij_css_hex_color_long_format = false +ij_css_hex_color_lower_case = false +ij_css_hex_color_short_format = false +ij_css_hex_color_upper_case = false +ij_css_keep_blank_lines_in_code = 2 +ij_css_keep_indents_on_empty_lines = false +ij_css_keep_single_line_blocks = false +ij_css_properties_order = font, font-family, font-size, font-weight, font-style, font-variant, font-size-adjust, font-stretch, line-height, position, z-index, top, right, bottom, left, display, visibility, float, clear, overflow, overflow-x, overflow-y, clip, zoom, align-content, align-items, align-self, flex, flex-flow, flex-basis, flex-direction, flex-grow, flex-shrink, flex-wrap, justify-content, order, box-sizing, width, min-width, max-width, height, min-height, max-height, margin, margin-top, margin-right, margin-bottom, margin-left, padding, padding-top, padding-right, padding-bottom, padding-left, table-layout, empty-cells, caption-side, border-spacing, border-collapse, list-style, list-style-position, list-style-type, list-style-image, content, quotes, counter-reset, counter-increment, resize, cursor, user-select, nav-index, nav-up, nav-right, nav-down, nav-left, transition, transition-delay, transition-timing-function, transition-duration, transition-property, transform, transform-origin, animation, animation-name, animation-duration, animation-play-state, animation-timing-function, animation-delay, animation-iteration-count, animation-direction, text-align, text-align-last, vertical-align, white-space, text-decoration, text-emphasis, text-emphasis-color, text-emphasis-style, text-emphasis-position, text-indent, text-justify, letter-spacing, word-spacing, text-outline, text-transform, text-wrap, text-overflow, text-overflow-ellipsis, text-overflow-mode, word-wrap, word-break, tab-size, hyphens, pointer-events, opacity, color, border, border-width, border-style, border-color, border-top, border-top-width, border-top-style, border-top-color, border-right, border-right-width, border-right-style, border-right-color, border-bottom, border-bottom-width, border-bottom-style, border-bottom-color, border-left, border-left-width, border-left-style, border-left-color, border-radius, border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius, border-image, border-image-source, border-image-slice, border-image-width, border-image-outset, border-image-repeat, outline, outline-width, outline-style, outline-color, outline-offset, background, background-color, background-image, background-repeat, background-attachment, background-position, background-position-x, background-position-y, background-clip, background-origin, background-size, box-decoration-break, box-shadow, text-shadow +ij_css_space_after_colon = true +ij_css_space_before_opening_brace = true +ij_css_use_double_quotes = true +ij_css_value_alignment = do_not_align + +[*.sass] +indent_size = 2 +ij_sass_align_closing_brace_with_properties = false +ij_sass_blank_lines_around_nested_selector = 1 +ij_sass_blank_lines_between_blocks = 1 +ij_sass_brace_placement = 0 +ij_sass_enforce_quotes_on_format = false +ij_sass_hex_color_long_format = false +ij_sass_hex_color_lower_case = false +ij_sass_hex_color_short_format = false +ij_sass_hex_color_upper_case = false +ij_sass_keep_blank_lines_in_code = 2 +ij_sass_keep_indents_on_empty_lines = false +ij_sass_keep_single_line_blocks = false +ij_sass_line_comment_add_space = false +ij_sass_line_comment_at_first_column = false +ij_sass_properties_order = font, font-family, font-size, font-weight, font-style, font-variant, font-size-adjust, font-stretch, line-height, position, z-index, top, right, bottom, left, display, visibility, float, clear, overflow, overflow-x, overflow-y, clip, zoom, align-content, align-items, align-self, flex, flex-flow, flex-basis, flex-direction, flex-grow, flex-shrink, flex-wrap, justify-content, order, box-sizing, width, min-width, max-width, height, min-height, max-height, margin, margin-top, margin-right, margin-bottom, margin-left, padding, padding-top, padding-right, padding-bottom, padding-left, table-layout, empty-cells, caption-side, border-spacing, border-collapse, list-style, list-style-position, list-style-type, list-style-image, content, quotes, counter-reset, counter-increment, resize, cursor, user-select, nav-index, nav-up, nav-right, nav-down, nav-left, transition, transition-delay, transition-timing-function, transition-duration, transition-property, transform, transform-origin, animation, animation-name, animation-duration, animation-play-state, animation-timing-function, animation-delay, animation-iteration-count, animation-direction, text-align, text-align-last, vertical-align, white-space, text-decoration, text-emphasis, text-emphasis-color, text-emphasis-style, text-emphasis-position, text-indent, text-justify, letter-spacing, word-spacing, text-outline, text-transform, text-wrap, text-overflow, text-overflow-ellipsis, text-overflow-mode, word-wrap, word-break, tab-size, hyphens, pointer-events, opacity, color, border, border-width, border-style, border-color, border-top, border-top-width, border-top-style, border-top-color, border-right, border-right-width, border-right-style, border-right-color, border-bottom, border-bottom-width, border-bottom-style, border-bottom-color, border-left, border-left-width, border-left-style, border-left-color, border-radius, border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius, border-image, border-image-source, border-image-slice, border-image-width, border-image-outset, border-image-repeat, outline, outline-width, outline-style, outline-color, outline-offset, background, background-color, background-image, background-repeat, background-attachment, background-position, background-position-x, background-position-y, background-clip, background-origin, background-size, box-decoration-break, box-shadow, text-shadow +ij_sass_space_after_colon = true +ij_sass_space_before_opening_brace = true +ij_sass_use_double_quotes = true +ij_sass_value_alignment = 0 + +[*.scss] +indent_size = 2 +ij_scss_align_closing_brace_with_properties = false +ij_scss_blank_lines_around_nested_selector = 1 +ij_scss_blank_lines_between_blocks = 1 +ij_scss_block_comment_add_space = false +ij_scss_brace_placement = 0 +ij_scss_enforce_quotes_on_format = false +ij_scss_hex_color_long_format = false +ij_scss_hex_color_lower_case = false +ij_scss_hex_color_short_format = false +ij_scss_hex_color_upper_case = false +ij_scss_keep_blank_lines_in_code = 2 +ij_scss_keep_indents_on_empty_lines = false +ij_scss_keep_single_line_blocks = false +ij_scss_line_comment_add_space = false +ij_scss_line_comment_at_first_column = false +ij_scss_properties_order = font, font-family, font-size, font-weight, font-style, font-variant, font-size-adjust, font-stretch, line-height, position, z-index, top, right, bottom, left, display, visibility, float, clear, overflow, overflow-x, overflow-y, clip, zoom, align-content, align-items, align-self, flex, flex-flow, flex-basis, flex-direction, flex-grow, flex-shrink, flex-wrap, justify-content, order, box-sizing, width, min-width, max-width, height, min-height, max-height, margin, margin-top, margin-right, margin-bottom, margin-left, padding, padding-top, padding-right, padding-bottom, padding-left, table-layout, empty-cells, caption-side, border-spacing, border-collapse, list-style, list-style-position, list-style-type, list-style-image, content, quotes, counter-reset, counter-increment, resize, cursor, user-select, nav-index, nav-up, nav-right, nav-down, nav-left, transition, transition-delay, transition-timing-function, transition-duration, transition-property, transform, transform-origin, animation, animation-name, animation-duration, animation-play-state, animation-timing-function, animation-delay, animation-iteration-count, animation-direction, text-align, text-align-last, vertical-align, white-space, text-decoration, text-emphasis, text-emphasis-color, text-emphasis-style, text-emphasis-position, text-indent, text-justify, letter-spacing, word-spacing, text-outline, text-transform, text-wrap, text-overflow, text-overflow-ellipsis, text-overflow-mode, word-wrap, word-break, tab-size, hyphens, pointer-events, opacity, color, border, border-width, border-style, border-color, border-top, border-top-width, border-top-style, border-top-color, border-right, border-right-width, border-right-style, border-right-color, border-bottom, border-bottom-width, border-bottom-style, border-bottom-color, border-left, border-left-width, border-left-style, border-left-color, border-radius, border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius, border-image, border-image-source, border-image-slice, border-image-width, border-image-outset, border-image-repeat, outline, outline-width, outline-style, outline-color, outline-offset, background, background-color, background-image, background-repeat, background-attachment, background-position, background-position-x, background-position-y, background-clip, background-origin, background-size, box-decoration-break, box-shadow, text-shadow +ij_scss_space_after_colon = true +ij_scss_space_before_opening_brace = true +ij_scss_use_double_quotes = true +ij_scss_value_alignment = 0 + +[{*.ats,*.cts,*.mts,*.ts}] +ij_continuation_indent_size = 4 +ij_typescript_align_imports = false +ij_typescript_align_multiline_array_initializer_expression = false +ij_typescript_align_multiline_binary_operation = false +ij_typescript_align_multiline_chained_methods = false +ij_typescript_align_multiline_extends_list = false +ij_typescript_align_multiline_for = true +ij_typescript_align_multiline_parameters = true +ij_typescript_align_multiline_parameters_in_calls = false +ij_typescript_align_multiline_ternary_operation = false +ij_typescript_align_object_properties = 0 +ij_typescript_align_union_types = false +ij_typescript_align_var_statements = 0 +ij_typescript_array_initializer_new_line_after_left_brace = false +ij_typescript_array_initializer_right_brace_on_new_line = false +ij_typescript_array_initializer_wrap = off +ij_typescript_assignment_wrap = off +ij_typescript_binary_operation_sign_on_next_line = false +ij_typescript_binary_operation_wrap = off +ij_typescript_blacklist_imports = rxjs/Rx, node_modules/**, **/node_modules/**, @angular/material, @angular/material/typings/** +ij_typescript_blank_lines_after_imports = 1 +ij_typescript_blank_lines_around_class = 1 +ij_typescript_blank_lines_around_field = 0 +ij_typescript_blank_lines_around_field_in_interface = 0 +ij_typescript_blank_lines_around_function = 1 +ij_typescript_blank_lines_around_method = 1 +ij_typescript_blank_lines_around_method_in_interface = 1 +ij_typescript_block_brace_style = end_of_line +ij_typescript_block_comment_add_space = false +ij_typescript_block_comment_at_first_column = true +ij_typescript_call_parameters_new_line_after_left_paren = false +ij_typescript_call_parameters_right_paren_on_new_line = false +ij_typescript_call_parameters_wrap = off +ij_typescript_catch_on_new_line = false +ij_typescript_chained_call_dot_on_new_line = true +ij_typescript_class_brace_style = end_of_line +ij_typescript_comma_on_new_line = false +ij_typescript_do_while_brace_force = never +ij_typescript_else_on_new_line = false +ij_typescript_enforce_trailing_comma = keep +ij_typescript_enum_constants_wrap = on_every_item +ij_typescript_extends_keyword_wrap = off +ij_typescript_extends_list_wrap = off +ij_typescript_field_prefix = _ +ij_typescript_file_name_style = relaxed +ij_typescript_finally_on_new_line = false +ij_typescript_for_brace_force = never +ij_typescript_for_statement_new_line_after_left_paren = false +ij_typescript_for_statement_right_paren_on_new_line = false +ij_typescript_for_statement_wrap = off +ij_typescript_force_quote_style = false +ij_typescript_force_semicolon_style = false +ij_typescript_function_expression_brace_style = end_of_line +ij_typescript_if_brace_force = never +ij_typescript_import_merge_members = global +ij_typescript_import_prefer_absolute_path = global +ij_typescript_import_sort_members = true +ij_typescript_import_sort_module_name = false +ij_typescript_import_use_node_resolution = true +ij_typescript_imports_wrap = on_every_item +ij_typescript_indent_case_from_switch = true +ij_typescript_indent_chained_calls = true +ij_typescript_indent_package_children = 0 +ij_typescript_jsdoc_include_types = false +ij_typescript_jsx_attribute_value = braces +ij_typescript_keep_blank_lines_in_code = 2 +ij_typescript_keep_first_column_comment = true +ij_typescript_keep_indents_on_empty_lines = false +ij_typescript_keep_line_breaks = true +ij_typescript_keep_simple_blocks_in_one_line = false +ij_typescript_keep_simple_methods_in_one_line = false +ij_typescript_line_comment_add_space = true +ij_typescript_line_comment_at_first_column = false +ij_typescript_method_brace_style = end_of_line +ij_typescript_method_call_chain_wrap = off +ij_typescript_method_parameters_new_line_after_left_paren = false +ij_typescript_method_parameters_right_paren_on_new_line = false +ij_typescript_method_parameters_wrap = off +ij_typescript_object_literal_wrap = on_every_item +ij_typescript_object_types_wrap = on_every_item +ij_typescript_parentheses_expression_new_line_after_left_paren = false +ij_typescript_parentheses_expression_right_paren_on_new_line = false +ij_typescript_place_assignment_sign_on_next_line = false +ij_typescript_prefer_as_type_cast = false +ij_typescript_prefer_explicit_types_function_expression_returns = false +ij_typescript_prefer_explicit_types_function_returns = false +ij_typescript_prefer_explicit_types_vars_fields = false +ij_typescript_prefer_parameters_wrap = false +ij_typescript_reformat_c_style_comments = false +ij_typescript_space_after_colon = true +ij_typescript_space_after_comma = true +ij_typescript_space_after_dots_in_rest_parameter = false +ij_typescript_space_after_generator_mult = true +ij_typescript_space_after_property_colon = true +ij_typescript_space_after_quest = true +ij_typescript_space_after_type_colon = true +ij_typescript_space_after_unary_not = false +ij_typescript_space_before_async_arrow_lparen = true +ij_typescript_space_before_catch_keyword = true +ij_typescript_space_before_catch_left_brace = true +ij_typescript_space_before_catch_parentheses = true +ij_typescript_space_before_class_lbrace = true +ij_typescript_space_before_class_left_brace = true +ij_typescript_space_before_colon = true +ij_typescript_space_before_comma = false +ij_typescript_space_before_do_left_brace = true +ij_typescript_space_before_else_keyword = true +ij_typescript_space_before_else_left_brace = true +ij_typescript_space_before_finally_keyword = true +ij_typescript_space_before_finally_left_brace = true +ij_typescript_space_before_for_left_brace = true +ij_typescript_space_before_for_parentheses = true +ij_typescript_space_before_for_semicolon = false +ij_typescript_space_before_function_left_parenth = true +ij_typescript_space_before_generator_mult = false +ij_typescript_space_before_if_left_brace = true +ij_typescript_space_before_if_parentheses = true +ij_typescript_space_before_method_call_parentheses = false +ij_typescript_space_before_method_left_brace = true +ij_typescript_space_before_method_parentheses = false +ij_typescript_space_before_property_colon = false +ij_typescript_space_before_quest = true +ij_typescript_space_before_switch_left_brace = true +ij_typescript_space_before_switch_parentheses = true +ij_typescript_space_before_try_left_brace = true +ij_typescript_space_before_type_colon = false +ij_typescript_space_before_unary_not = false +ij_typescript_space_before_while_keyword = true +ij_typescript_space_before_while_left_brace = true +ij_typescript_space_before_while_parentheses = true +ij_typescript_spaces_around_additive_operators = true +ij_typescript_spaces_around_arrow_function_operator = true +ij_typescript_spaces_around_assignment_operators = true +ij_typescript_spaces_around_bitwise_operators = true +ij_typescript_spaces_around_equality_operators = true +ij_typescript_spaces_around_logical_operators = true +ij_typescript_spaces_around_multiplicative_operators = true +ij_typescript_spaces_around_relational_operators = true +ij_typescript_spaces_around_shift_operators = true +ij_typescript_spaces_around_unary_operator = false +ij_typescript_spaces_within_array_initializer_brackets = false +ij_typescript_spaces_within_brackets = false +ij_typescript_spaces_within_catch_parentheses = false +ij_typescript_spaces_within_for_parentheses = false +ij_typescript_spaces_within_if_parentheses = false +ij_typescript_spaces_within_imports = false +ij_typescript_spaces_within_interpolation_expressions = false +ij_typescript_spaces_within_method_call_parentheses = false +ij_typescript_spaces_within_method_parentheses = false +ij_typescript_spaces_within_object_literal_braces = false +ij_typescript_spaces_within_object_type_braces = true +ij_typescript_spaces_within_parentheses = false +ij_typescript_spaces_within_switch_parentheses = false +ij_typescript_spaces_within_type_assertion = false +ij_typescript_spaces_within_union_types = true +ij_typescript_spaces_within_while_parentheses = false +ij_typescript_special_else_if_treatment = true +ij_typescript_ternary_operation_signs_on_next_line = false +ij_typescript_ternary_operation_wrap = off +ij_typescript_union_types_wrap = on_every_item +ij_typescript_use_chained_calls_group_indents = false +ij_typescript_use_double_quotes = true +ij_typescript_use_explicit_js_extension = auto +ij_typescript_use_path_mapping = always +ij_typescript_use_public_modifier = false +ij_typescript_use_semicolon_after_statement = true +ij_typescript_var_declaration_wrap = normal +ij_typescript_while_brace_force = never +ij_typescript_while_on_new_line = false +ij_typescript_wrap_comments = false + +[{*.cjs,*.js}] +ij_continuation_indent_size = 4 +ij_javascript_align_imports = false +ij_javascript_align_multiline_array_initializer_expression = false +ij_javascript_align_multiline_binary_operation = false +ij_javascript_align_multiline_chained_methods = false +ij_javascript_align_multiline_extends_list = false +ij_javascript_align_multiline_for = true +ij_javascript_align_multiline_parameters = true +ij_javascript_align_multiline_parameters_in_calls = false +ij_javascript_align_multiline_ternary_operation = false +ij_javascript_align_object_properties = 0 +ij_javascript_align_union_types = false +ij_javascript_align_var_statements = 0 +ij_javascript_array_initializer_new_line_after_left_brace = false +ij_javascript_array_initializer_right_brace_on_new_line = false +ij_javascript_array_initializer_wrap = off +ij_javascript_assignment_wrap = off +ij_javascript_binary_operation_sign_on_next_line = false +ij_javascript_binary_operation_wrap = off +ij_javascript_blacklist_imports = rxjs/Rx, node_modules/**, **/node_modules/**, @angular/material, @angular/material/typings/** +ij_javascript_blank_lines_after_imports = 1 +ij_javascript_blank_lines_around_class = 1 +ij_javascript_blank_lines_around_field = 0 +ij_javascript_blank_lines_around_function = 1 +ij_javascript_blank_lines_around_method = 1 +ij_javascript_block_brace_style = end_of_line +ij_javascript_block_comment_add_space = false +ij_javascript_block_comment_at_first_column = true +ij_javascript_call_parameters_new_line_after_left_paren = false +ij_javascript_call_parameters_right_paren_on_new_line = false +ij_javascript_call_parameters_wrap = off +ij_javascript_catch_on_new_line = false +ij_javascript_chained_call_dot_on_new_line = true +ij_javascript_class_brace_style = end_of_line +ij_javascript_comma_on_new_line = false +ij_javascript_do_while_brace_force = never +ij_javascript_else_on_new_line = false +ij_javascript_enforce_trailing_comma = keep +ij_javascript_extends_keyword_wrap = off +ij_javascript_extends_list_wrap = off +ij_javascript_field_prefix = _ +ij_javascript_file_name_style = relaxed +ij_javascript_finally_on_new_line = false +ij_javascript_for_brace_force = never +ij_javascript_for_statement_new_line_after_left_paren = false +ij_javascript_for_statement_right_paren_on_new_line = false +ij_javascript_for_statement_wrap = off +ij_javascript_force_quote_style = false +ij_javascript_force_semicolon_style = false +ij_javascript_function_expression_brace_style = end_of_line +ij_javascript_if_brace_force = never +ij_javascript_import_merge_members = global +ij_javascript_import_prefer_absolute_path = global +ij_javascript_import_sort_members = true +ij_javascript_import_sort_module_name = false +ij_javascript_import_use_node_resolution = true +ij_javascript_imports_wrap = on_every_item +ij_javascript_indent_case_from_switch = true +ij_javascript_indent_chained_calls = true +ij_javascript_indent_package_children = 0 +ij_javascript_jsx_attribute_value = braces +ij_javascript_keep_blank_lines_in_code = 2 +ij_javascript_keep_first_column_comment = true +ij_javascript_keep_indents_on_empty_lines = false +ij_javascript_keep_line_breaks = true +ij_javascript_keep_simple_blocks_in_one_line = false +ij_javascript_keep_simple_methods_in_one_line = false +ij_javascript_line_comment_add_space = true +ij_javascript_line_comment_at_first_column = false +ij_javascript_method_brace_style = end_of_line +ij_javascript_method_call_chain_wrap = off +ij_javascript_method_parameters_new_line_after_left_paren = false +ij_javascript_method_parameters_right_paren_on_new_line = false +ij_javascript_method_parameters_wrap = off +ij_javascript_object_literal_wrap = on_every_item +ij_javascript_object_types_wrap = on_every_item +ij_javascript_parentheses_expression_new_line_after_left_paren = false +ij_javascript_parentheses_expression_right_paren_on_new_line = false +ij_javascript_place_assignment_sign_on_next_line = false +ij_javascript_prefer_as_type_cast = false +ij_javascript_prefer_explicit_types_function_expression_returns = false +ij_javascript_prefer_explicit_types_function_returns = false +ij_javascript_prefer_explicit_types_vars_fields = false +ij_javascript_prefer_parameters_wrap = false +ij_javascript_reformat_c_style_comments = false +ij_javascript_space_after_colon = true +ij_javascript_space_after_comma = true +ij_javascript_space_after_dots_in_rest_parameter = false +ij_javascript_space_after_generator_mult = true +ij_javascript_space_after_property_colon = true +ij_javascript_space_after_quest = true +ij_javascript_space_after_type_colon = true +ij_javascript_space_after_unary_not = false +ij_javascript_space_before_async_arrow_lparen = true +ij_javascript_space_before_catch_keyword = true +ij_javascript_space_before_catch_left_brace = true +ij_javascript_space_before_catch_parentheses = true +ij_javascript_space_before_class_lbrace = true +ij_javascript_space_before_class_left_brace = true +ij_javascript_space_before_colon = true +ij_javascript_space_before_comma = false +ij_javascript_space_before_do_left_brace = true +ij_javascript_space_before_else_keyword = true +ij_javascript_space_before_else_left_brace = true +ij_javascript_space_before_finally_keyword = true +ij_javascript_space_before_finally_left_brace = true +ij_javascript_space_before_for_left_brace = true +ij_javascript_space_before_for_parentheses = true +ij_javascript_space_before_for_semicolon = false +ij_javascript_space_before_function_left_parenth = true +ij_javascript_space_before_generator_mult = false +ij_javascript_space_before_if_left_brace = true +ij_javascript_space_before_if_parentheses = true +ij_javascript_space_before_method_call_parentheses = false +ij_javascript_space_before_method_left_brace = true +ij_javascript_space_before_method_parentheses = false +ij_javascript_space_before_property_colon = false +ij_javascript_space_before_quest = true +ij_javascript_space_before_switch_left_brace = true +ij_javascript_space_before_switch_parentheses = true +ij_javascript_space_before_try_left_brace = true +ij_javascript_space_before_type_colon = false +ij_javascript_space_before_unary_not = false +ij_javascript_space_before_while_keyword = true +ij_javascript_space_before_while_left_brace = true +ij_javascript_space_before_while_parentheses = true +ij_javascript_spaces_around_additive_operators = true +ij_javascript_spaces_around_arrow_function_operator = true +ij_javascript_spaces_around_assignment_operators = true +ij_javascript_spaces_around_bitwise_operators = true +ij_javascript_spaces_around_equality_operators = true +ij_javascript_spaces_around_logical_operators = true +ij_javascript_spaces_around_multiplicative_operators = true +ij_javascript_spaces_around_relational_operators = true +ij_javascript_spaces_around_shift_operators = true +ij_javascript_spaces_around_unary_operator = false +ij_javascript_spaces_within_array_initializer_brackets = false +ij_javascript_spaces_within_brackets = false +ij_javascript_spaces_within_catch_parentheses = false +ij_javascript_spaces_within_for_parentheses = false +ij_javascript_spaces_within_if_parentheses = false +ij_javascript_spaces_within_imports = false +ij_javascript_spaces_within_interpolation_expressions = false +ij_javascript_spaces_within_method_call_parentheses = false +ij_javascript_spaces_within_method_parentheses = false +ij_javascript_spaces_within_object_literal_braces = false +ij_javascript_spaces_within_object_type_braces = true +ij_javascript_spaces_within_parentheses = false +ij_javascript_spaces_within_switch_parentheses = false +ij_javascript_spaces_within_type_assertion = false +ij_javascript_spaces_within_union_types = true +ij_javascript_spaces_within_while_parentheses = false +ij_javascript_special_else_if_treatment = true +ij_javascript_ternary_operation_signs_on_next_line = false +ij_javascript_ternary_operation_wrap = off +ij_javascript_union_types_wrap = on_every_item +ij_javascript_use_chained_calls_group_indents = false +ij_javascript_use_double_quotes = true +ij_javascript_use_explicit_js_extension = auto +ij_javascript_use_path_mapping = always +ij_javascript_use_public_modifier = false +ij_javascript_use_semicolon_after_statement = true +ij_javascript_var_declaration_wrap = normal +ij_javascript_while_brace_force = never +ij_javascript_while_on_new_line = false +ij_javascript_wrap_comments = false + +[{*.har,*.jsb2,*.jsb3,*.json,.babelrc,.eslintrc,.prettierrc,.stylelintrc,bowerrc,jest.config}] +indent_size = 2 +ij_json_array_wrapping = split_into_lines +ij_json_keep_blank_lines_in_code = 0 +ij_json_keep_indents_on_empty_lines = false +ij_json_keep_line_breaks = true +ij_json_keep_trailing_comma = false +ij_json_object_wrapping = split_into_lines +ij_json_property_alignment = do_not_align +ij_json_space_after_colon = true +ij_json_space_after_comma = true +ij_json_space_before_colon = false +ij_json_space_before_comma = false +ij_json_spaces_within_braces = false +ij_json_spaces_within_brackets = false +ij_json_wrap_long_lines = false + +[{*.htm,*.html,*.ng,*.sht,*.shtm,*.shtml}] +ij_html_add_new_line_before_tags = body, div, p, form, h1, h2, h3 +ij_html_align_attributes = true +ij_html_align_text = false +ij_html_attribute_wrap = normal +ij_html_block_comment_add_space = false +ij_html_block_comment_at_first_column = true +ij_html_do_not_align_children_of_min_lines = 0 +ij_html_do_not_break_if_inline_tags = title, h1, h2, h3, h4, h5, h6, p +ij_html_do_not_indent_children_of_tags = html, body, thead, tbody, tfoot +ij_html_enforce_quotes = false +ij_html_inline_tags = a, abbr, acronym, b, basefont, bdo, big, br, cite, cite, code, dfn, em, font, i, img, input, kbd, label, q, s, samp, select, small, span, strike, strong, sub, sup, textarea, tt, u, var +ij_html_keep_blank_lines = 2 +ij_html_keep_indents_on_empty_lines = false +ij_html_keep_line_breaks = true +ij_html_keep_line_breaks_in_text = true +ij_html_keep_whitespaces = false +ij_html_keep_whitespaces_inside = span, pre, textarea +ij_html_line_comment_at_first_column = true +ij_html_new_line_after_last_attribute = never +ij_html_new_line_before_first_attribute = never +ij_html_quote_style = double +ij_html_remove_new_line_before_tags = br +ij_html_space_after_tag_name = false +ij_html_space_around_equality_in_attribute = false +ij_html_space_inside_empty_tag = false +ij_html_text_wrap = normal + +[{*.markdown,*.md}] +ij_markdown_force_one_space_after_blockquote_symbol = true +ij_markdown_force_one_space_after_header_symbol = true +ij_markdown_force_one_space_after_list_bullet = true +ij_markdown_force_one_space_between_words = true +ij_markdown_format_tables = true +ij_markdown_insert_quote_arrows_on_wrap = true +ij_markdown_keep_indents_on_empty_lines = false +ij_markdown_keep_line_breaks_inside_text_blocks = true +ij_markdown_max_lines_around_block_elements = 1 +ij_markdown_max_lines_around_header = 1 +ij_markdown_max_lines_between_paragraphs = 1 +ij_markdown_min_lines_around_block_elements = 1 +ij_markdown_min_lines_around_header = 1 +ij_markdown_min_lines_between_paragraphs = 1 +ij_markdown_wrap_text_if_long = true +ij_markdown_wrap_text_inside_blockquotes = true diff --git a/.gitignore b/.gitignore index e9618a3..4e572ed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules .next -.env.local \ No newline at end of file +.env.local +.idea \ No newline at end of file diff --git a/README.md b/README.md index 500a317..20bc2ee 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,18 @@ # loan-facilities-user - - ## Getting started To make it easy for you to get started with GitLab, here's a list of recommended next steps. -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! +Already a pro? Just edit this README.md and make it your own. Want to make it +easy? [Use the template at the bottom](#editing-this-readme)! ## Add your files -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: +- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) + or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files +- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) + or push an existing Git repository with the following command: ``` cd existing_repo @@ -46,47 +47,82 @@ Use the built-in continuous integration in GitLab. # Editing this README -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template. +When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to +structure it however you want - this is just a starting point!). Thank you +to [makeareadme.com](https://www.makeareadme.com/) for this template. ## Suggestions for a good README -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. + +Every project is different, so consider which of these sections apply to yours. The sections used in the template are +suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long +is better than too short. If you think your README is too long, consider utilizing another form of documentation rather +than cutting out information. ## Name + Choose a self-explaining name for your project. ## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. + +Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be +unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your +project, this is a good place to list differentiating factors. ## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. + +On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the +project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. ## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. + +Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see +GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. ## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. + +Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. +However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing +specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a +specific context like a particular programming language version or operating system or has dependencies that have to be +installed manually, also add a Requirements subsection. ## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. + +Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of +usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably +include in the README. ## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. + +Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, +etc. ## Roadmap + If you have ideas for releases in the future, it is a good idea to list them in the README. ## Contributing + State if you are open to contributions and what your requirements are for accepting them. -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. +For people who want to make changes to your project, it's helpful to have some documentation on how to get started. +Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps +explicit. These instructions could also be useful to your future self. -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. +You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce +the likelihood that the changes inadvertently break something. Having instructions for running tests is especially +helpful if it requires external setup, such as starting a Selenium server for testing in a browser. ## Authors and acknowledgment + Show your appreciation to those who have contributed to the project. ## License + For open source projects, say how it is licensed. ## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. + +If you have run out of energy or time for your project, put a note at the top of the README saying that development has +slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or +owner, allowing your project to keep going. You can also make an explicit request for maintainers. diff --git a/jsconfig.json b/jsconfig.json index f6a30b1..fcd02aa 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -1,8 +1,12 @@ { "compilerOptions": { "paths": { - "@/*": ["./src/*"], - "&/*": ["./public/*"], + "@/*": [ + "./src/*" + ], + "&/*": [ + "./public/*" + ] } } } diff --git a/next.config.js b/next.config.js index 03fb527..409876a 100644 --- a/next.config.js +++ b/next.config.js @@ -1,12 +1,12 @@ /** @type {import('next').NextConfig} */ const nextConfig = { - reactStrictMode: true, - i18n: { - defaultLocale: 'fa', - locales: ['fa'], - localeDetection: false, - }, + reactStrictMode: true, + i18n: { + defaultLocale: 'fa', + locales: ['fa'], + localeDetection: false, + }, } module.exports = nextConfig diff --git a/public/fontiran.scss b/public/fontiran.scss index e263b42..ffa1438 100644 --- a/public/fontiran.scss +++ b/public/fontiran.scss @@ -17,80 +17,87 @@ This set of fonts are used in this project under the license: (.....) * **/ @font-face { - font-family: IRANSans; - font-style: normal; - font-weight: 900; - src: url('./fonts/eot/IRANSansWeb_Black.eot'); - src: url('./fonts/eot/IRANSansWeb_Black.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ - url('./fonts/woff2/IRANSansWeb_Black.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ - url('./fonts/woff/IRANSansWeb_Black.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/IRANSansWeb_Black.ttf') format('truetype'); + font-family: IRANSans; + font-style: normal; + font-weight: 900; + src: url('./fonts/eot/IRANSansWeb_Black.eot'); + src: url('./fonts/eot/IRANSansWeb_Black.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff2/IRANSansWeb_Black.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ + url('./fonts/woff/IRANSansWeb_Black.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/IRANSansWeb_Black.ttf') format('truetype'); } + @font-face { - font-family: IRANSans; - font-style: normal; - font-weight: bold; - src: url('./fonts/eot/IRANSansWeb_Bold.eot'); - src: url('./fonts/eot/IRANSansWeb_Bold.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ - url('./fonts/woff2/IRANSansWeb_Bold.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ - url('./fonts/woff/IRANSansWeb_Bold.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/IRANSansWeb_Bold.ttf') format('truetype'); + font-family: IRANSans; + font-style: normal; + font-weight: bold; + src: url('./fonts/eot/IRANSansWeb_Bold.eot'); + src: url('./fonts/eot/IRANSansWeb_Bold.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff2/IRANSansWeb_Bold.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ + url('./fonts/woff/IRANSansWeb_Bold.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/IRANSansWeb_Bold.ttf') format('truetype'); } + @font-face { - font-family: IRANSans; - font-style: normal; - font-weight: 500; - src: url('./fonts/eot/IRANSansWeb_Medium.eot'); - src: url('./fonts/eot/IRANSansWeb_Medium.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ - url('./fonts/woff2/IRANSansWeb_Medium.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ - url('./fonts/woff/IRANSansWeb_Medium.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/IRANSansWeb_Medium.ttf') format('truetype'); + font-family: IRANSans; + font-style: normal; + font-weight: 500; + src: url('./fonts/eot/IRANSansWeb_Medium.eot'); + src: url('./fonts/eot/IRANSansWeb_Medium.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff2/IRANSansWeb_Medium.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ + url('./fonts/woff/IRANSansWeb_Medium.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/IRANSansWeb_Medium.ttf') format('truetype'); } + @font-face { - font-family: IRANSans; - font-style: normal; - font-weight: 300; - src: url('./fonts/eot/IRANSansWeb_Light.eot'); - src: url('./fonts/eot/IRANSansWeb_Light.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ - url('./fonts/woff2/IRANSansWeb_Light.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ - url('./fonts/woff/IRANSansWeb_Light.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/IRANSansWeb_Light.ttf') format('truetype'); + font-family: IRANSans; + font-style: normal; + font-weight: 300; + src: url('./fonts/eot/IRANSansWeb_Light.eot'); + src: url('./fonts/eot/IRANSansWeb_Light.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff2/IRANSansWeb_Light.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ + url('./fonts/woff/IRANSansWeb_Light.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/IRANSansWeb_Light.ttf') format('truetype'); } + @font-face { - font-family: IRANSans; - font-style: normal; - font-weight: 200; - src: url('./fonts/eot/IRANSansWeb_UltraLight.eot'); - src: url('./fonts/eot/IRANSansWeb_UltraLight.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ - url('./fonts/woff2/IRANSansWeb_UltraLight.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ - url('./fonts/woff/IRANSansWeb_UltraLight.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/IRANSansWeb_UltraLight.ttf') format('truetype'); + font-family: IRANSans; + font-style: normal; + font-weight: 200; + src: url('./fonts/eot/IRANSansWeb_UltraLight.eot'); + src: url('./fonts/eot/IRANSansWeb_UltraLight.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff2/IRANSansWeb_UltraLight.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ + url('./fonts/woff/IRANSansWeb_UltraLight.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/IRANSansWeb_UltraLight.ttf') format('truetype'); } + @font-face { - font-family: IRANSans; - font-style: normal; - font-weight: normal; - src: url('./fonts/eot/IRANSansWeb.eot'); - src: url('./fonts/eot/IRANSansWeb.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ - url('./fonts/woff2/IRANSansWeb.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ - url('./fonts/woff/IRANSansWeb.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/IRANSansWeb.ttf') format('truetype'); + font-family: IRANSans; + font-style: normal; + font-weight: normal; + src: url('./fonts/eot/IRANSansWeb.eot'); + src: url('./fonts/eot/IRANSansWeb.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff2/IRANSansWeb.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ + url('./fonts/woff/IRANSansWeb.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/IRANSansWeb.ttf') format('truetype'); } + @font-face { - font-family: Parastoo; - font-style: normal; - font-weight: normal; - src: url('./fonts/eot/Parastoo.eot'); - src: url('./fonts/eot/Parastoo.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ - url('./fonts/woff/Parastoo.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/Parastoo.ttf') format('truetype'); + font-family: Parastoo; + font-style: normal; + font-weight: normal; + src: url('./fonts/eot/Parastoo.eot'); + src: url('./fonts/eot/Parastoo.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff/Parastoo.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/Parastoo.ttf') format('truetype'); } + @font-face { - font-family: Parastoo; - font-style: normal; - font-weight: bold; - src: url('./fonts/eot/Parastoo-Bold.eot'); - src: url('./fonts/eot/Parastoo-Bold.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ - url('./fonts/woff/Parastoo-Bold.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/Parastoo-Bold.ttf') format('truetype'); + font-family: Parastoo; + font-style: normal; + font-weight: bold; + src: url('./fonts/eot/Parastoo-Bold.eot'); + src: url('./fonts/eot/Parastoo-Bold.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff/Parastoo-Bold.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/Parastoo-Bold.ttf') format('truetype'); } diff --git a/public/images/change-password.svg b/public/images/change-password.svg index f3b65aa..d940442 100644 --- a/public/images/change-password.svg +++ b/public/images/change-password.svg @@ -1 +1,64 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/images/dashboard.svg b/public/images/dashboard.svg index ea3f11b..f7c0340 100644 --- a/public/images/dashboard.svg +++ b/public/images/dashboard.svg @@ -1 +1,104 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/images/loading.svg b/public/images/loading.svg index 03b8908..f2fc10e 100644 --- a/public/images/loading.svg +++ b/public/images/loading.svg @@ -1 +1,42 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/images/login.svg b/public/images/login.svg index e2854d2..cd7e24e 100644 --- a/public/images/login.svg +++ b/public/images/login.svg @@ -1 +1,60 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/images/not-found.svg b/public/images/not-found.svg index 8735cf8..b233cca 100644 --- a/public/images/not-found.svg +++ b/public/images/not-found.svg @@ -1 +1,90 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/images/register.svg b/public/images/register.svg index f5184c9..6424756 100644 --- a/public/images/register.svg +++ b/public/images/register.svg @@ -1 +1,86 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/images/upload-image.svg b/public/images/upload-image.svg index 3bbca65..c901145 100644 --- a/public/images/upload-image.svg +++ b/public/images/upload-image.svg @@ -1 +1,92 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/locales/fa/datatable.js b/public/locales/fa/datatable.js index e42208f..7713862 100644 --- a/public/locales/fa/datatable.js +++ b/public/locales/fa/datatable.js @@ -1,92 +1,92 @@ export const FA_DATATABLE_LOCALIZATION = { - actions: "Actions", - and: "and", - cancel: "Cancel", - changeFilterMode: "Change filter mode", - changeSearchMode: "Change search mode", - clearFilter: "Clear filter", - clearSearch: "Clear search", - clearSort: "Clear sort", - clickToCopy: "Click to copy", - collapse: "Collapse", - collapseAll: "Collapse all", - columnActions: "Column Actions", - copiedToClipboard: "Copied to clipboard", - dropToGroupBy: "Drop to group by {column}", - edit: "Edit", - expand: "Expand", - expandAll: "Expand all", - filterArrIncludes: "Includes", - filterArrIncludesAll: "Includes all", - filterArrIncludesSome: "Includes", - filterBetween: "Between", - filterBetweenInclusive: "Between Inclusive", - filterByColumn: "Filter by {column}", - filterContains: "Contains", - filterEmpty: "Empty", - filterEndsWith: "Ends With", - filterEquals: "Equals", - filterEqualsString: "Equals", - filterFuzzy: "Fuzzy", - filterGreaterThan: "Greater Than", - filterGreaterThanOrEqualTo: "Greater Than Or Equal To", - filterInNumberRange: "Between", - filterIncludesString: "Contains", - filterIncludesStringSensitive: "Contains", - filterLessThan: "Less Than", - filterLessThanOrEqualTo: "Less Than Or Equal To", - filterMode: "Filter Mode: {filterType}", - filterNotEmpty: "Not Empty", - filterNotEquals: "Not Equals", - filterStartsWith: "Starts With", - filterWeakEquals: "Equals", - filteringByColumn: "Filtering by {column} - {filterType} {filterValue}", - goToFirstPage: "Go to first page", - goToLastPage: "Go to last page", - goToNextPage: "Go to next page", - goToPreviousPage: "Go to previous page", - grab: "Grab", - groupByColumn: "Group by {column}", - groupedBy: "Grouped by ", - hideAll: "Hide all", - hideColumn: "Hide {column} column", - max: "Max", - min: "Min", - move: "Move", - noRecordsToDisplay: "No records to display", - noResultsFound: "No results found", - of: "of", - or: "or", - pinToLeft: "Pin to left", - pinToRight: "Pin to right", - resetColumnSize: "Reset column size", - resetOrder: "Reset order", - rowActions: "Row Actions", - rowNumber: "#", - rowNumbers: "Row Numbers", - rowsPerPage: "Rows per page", - save: "Save", - search: "Search", - selectedCountOfRowCountRowsSelected: - "{selectedCount} of {rowCount} row(s) selected", - select: "Select", - showAll: "Show all", - showAllColumns: "Show all columns", - showHideColumns: "Show/Hide columns", - showHideFilters: "Show/Hide filters", - showHideSearch: "Show/Hide search", - sortByColumnAsc: "Sort by {column} ascending", - sortByColumnDesc: "Sort by {column} descending", - sortedByColumnAsc: "Sorted by {column} ascending", - sortedByColumnDesc: "Sorted by {column} descending", - thenBy: ", then by ", - toggleDensity: "Toggle density", - toggleFullScreen: "Toggle full screen", - toggleSelectAll: "Toggle select all", - toggleSelectRow: "Toggle select row", - toggleVisibility: "Toggle visibility", - ungroupByColumn: "Ungroup by {column}", - unpin: "Unpin", - unpinAll: "Unpin all", - unsorted: "Unsorted", + actions: "Actions", + and: "and", + cancel: "Cancel", + changeFilterMode: "Change filter mode", + changeSearchMode: "Change search mode", + clearFilter: "Clear filter", + clearSearch: "Clear search", + clearSort: "Clear sort", + clickToCopy: "Click to copy", + collapse: "Collapse", + collapseAll: "Collapse all", + columnActions: "Column Actions", + copiedToClipboard: "Copied to clipboard", + dropToGroupBy: "Drop to group by {column}", + edit: "Edit", + expand: "Expand", + expandAll: "Expand all", + filterArrIncludes: "Includes", + filterArrIncludesAll: "Includes all", + filterArrIncludesSome: "Includes", + filterBetween: "Between", + filterBetweenInclusive: "Between Inclusive", + filterByColumn: "Filter by {column}", + filterContains: "Contains", + filterEmpty: "Empty", + filterEndsWith: "Ends With", + filterEquals: "Equals", + filterEqualsString: "Equals", + filterFuzzy: "Fuzzy", + filterGreaterThan: "Greater Than", + filterGreaterThanOrEqualTo: "Greater Than Or Equal To", + filterInNumberRange: "Between", + filterIncludesString: "Contains", + filterIncludesStringSensitive: "Contains", + filterLessThan: "Less Than", + filterLessThanOrEqualTo: "Less Than Or Equal To", + filterMode: "Filter Mode: {filterType}", + filterNotEmpty: "Not Empty", + filterNotEquals: "Not Equals", + filterStartsWith: "Starts With", + filterWeakEquals: "Equals", + filteringByColumn: "Filtering by {column} - {filterType} {filterValue}", + goToFirstPage: "Go to first page", + goToLastPage: "Go to last page", + goToNextPage: "Go to next page", + goToPreviousPage: "Go to previous page", + grab: "Grab", + groupByColumn: "Group by {column}", + groupedBy: "Grouped by ", + hideAll: "Hide all", + hideColumn: "Hide {column} column", + max: "Max", + min: "Min", + move: "Move", + noRecordsToDisplay: "No records to display", + noResultsFound: "No results found", + of: "of", + or: "or", + pinToLeft: "Pin to left", + pinToRight: "Pin to right", + resetColumnSize: "Reset column size", + resetOrder: "Reset order", + rowActions: "Row Actions", + rowNumber: "#", + rowNumbers: "Row Numbers", + rowsPerPage: "Rows per page", + save: "Save", + search: "Search", + selectedCountOfRowCountRowsSelected: + "{selectedCount} of {rowCount} row(s) selected", + select: "Select", + showAll: "Show all", + showAllColumns: "Show all columns", + showHideColumns: "Show/Hide columns", + showHideFilters: "Show/Hide filters", + showHideSearch: "Show/Hide search", + sortByColumnAsc: "Sort by {column} ascending", + sortByColumnDesc: "Sort by {column} descending", + sortedByColumnAsc: "Sorted by {column} ascending", + sortedByColumnDesc: "Sorted by {column} descending", + thenBy: ", then by ", + toggleDensity: "Toggle density", + toggleFullScreen: "Toggle full screen", + toggleSelectAll: "Toggle select all", + toggleSelectRow: "Toggle select row", + toggleVisibility: "Toggle visibility", + ungroupByColumn: "Ungroup by {column}", + unpin: "Unpin", + unpinAll: "Unpin all", + unsorted: "Unsorted", }; diff --git a/src/components/dashboard/first/index.jsx b/src/components/dashboard/first/index.jsx index c693380..ee4f80a 100644 --- a/src/components/dashboard/first/index.jsx +++ b/src/components/dashboard/first/index.jsx @@ -1,7 +1,7 @@ import DashboardLayouts from "@/layouts/dashboardLayouts"; const DashboardFirstComponent = () => { - return ; + return ; }; export default DashboardFirstComponent; diff --git a/src/components/dashboard/loan-follow-up/index.jsx b/src/components/dashboard/loan-follow-up/index.jsx index 1b211af..5284cb4 100644 --- a/src/components/dashboard/loan-follow-up/index.jsx +++ b/src/components/dashboard/loan-follow-up/index.jsx @@ -2,121 +2,122 @@ import DashboardLayouts from "@/layouts/dashboardLayouts"; import useUser from "@/lib/app/hooks/useUser"; import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; import { - Avatar, Card, - CardActions, - CardContent, - CardHeader, - Collapse, - Grid, - IconButton, - Stack, - Typography + Avatar, + Card, + CardActions, + CardContent, + CardHeader, + Collapse, + Grid, + IconButton, + Stack, + Typography } from "@mui/material"; -import { styled } from "@mui/material/styles"; -import { useTranslations } from "next-intl"; -import { useState } from "react"; +import {styled} from "@mui/material/styles"; +import {useTranslations} from "next-intl"; +import {useState} from "react"; const ExpandMore = styled((props) => { - const { expand, ...other } = props; - return ; -})(({ theme, expand }) => ({ - transform: !expand ? "rotate(0deg)" : "rotate(180deg)", - marginLeft: "auto", - transition: theme.transitions.create("transform", { - duration: theme.transitions.duration.shortest, - }), + const {expand, ...other} = props; + return ; +})(({theme, expand}) => ({ + transform: !expand ? "rotate(0deg)" : "rotate(180deg)", + marginLeft: "auto", + transition: theme.transitions.create("transform", { + duration: theme.transitions.duration.shortest, + }), })); const data = [ - { - name: "جان دو", - date: "۱۳۹۹/۰۴/۲۵", - description: - "لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ و با استفاده از طراحان گرافیک است.", - }, - { - name: "جین اسمیت", - date: "۱۳۹۹/۰۴/۲۶", - description: "نُلا ویته الیت لیبرو آ، آ فارِترا آوگوه.", - }, - { - name: "مایک جانسون", - date: "۱۳۹۹/۰۴/۲۷", - description: - "دوئیس مولیس، است نُن کُمُدو لُکتوس، نیسی ارات پورتیتور لیگولا.", - }, + { + name: "جان دو", + date: "۱۳۹۹/۰۴/۲۵", + description: + "لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ و با استفاده از طراحان گرافیک است.", + }, + { + name: "جین اسمیت", + date: "۱۳۹۹/۰۴/۲۶", + description: "نُلا ویته الیت لیبرو آ، آ فارِترا آوگوه.", + }, + { + name: "مایک جانسون", + date: "۱۳۹۹/۰۴/۲۷", + description: + "دوئیس مولیس، است نُن کُمُدو لُکتوس، نیسی ارات پورتیتور لیگولا.", + }, ]; const DashboardLoanFollowUpComponent = () => { - const t = useTranslations(); - const { token } = useUser(); + const t = useTranslations(); + const {token} = useUser(); - const [expanded, setExpanded] = useState([]); + const [expanded, setExpanded] = useState([]); - const handleExpandClick = (index) => { - setExpanded((prevExpanded) => { - const newExpanded = [...prevExpanded]; - newExpanded[index] = !newExpanded[index]; - return newExpanded; - }); - }; + const handleExpandClick = (index) => { + setExpanded((prevExpanded) => { + const newExpanded = [...prevExpanded]; + newExpanded[index] = !newExpanded[index]; + return newExpanded; + }); + }; - return ( - - - - {data.map((item, index) => ( - - - - } - title={item.name} - subheader={item.date} - /> - - - متن تست - - - - handleExpandClick(index)} - aria-expanded={expanded[index]} - aria-label="show more" - > - - - - - - اطلاعات تکمیلی: - {item.description} - - - - - ))} - - - - ); + return ( + + + + {data.map((item, index) => ( + + + + } + title={item.name} + subheader={item.date} + /> + + + متن تست + + + + handleExpandClick(index)} + aria-expanded={expanded[index]} + aria-label="show more" + > + + + + + + اطلاعات تکمیلی: + {item.description} + + + + + ))} + + + + ); }; export default DashboardLoanFollowUpComponent; diff --git a/src/components/dashboard/loan-request/NavyForm.jsx b/src/components/dashboard/loan-request/NavyForm.jsx index 9e7c40c..dfe9327 100644 --- a/src/components/dashboard/loan-request/NavyForm.jsx +++ b/src/components/dashboard/loan-request/NavyForm.jsx @@ -2,490 +2,487 @@ import Notifications from "@/core/components/notifications"; import SelectBox from "@/core/components/SelectBox"; import StyledForm from "@/core/components/StyledForm"; import UploadSystem from "@/core/components/UploadSystem"; -import { - GET_PROVINCE_LIST, - SEND_LOAN_REQUEST_NAVGAN, -} from "@/core/data/apiRoutes"; +import {GET_PROVINCE_LIST, SEND_LOAN_REQUEST_NAVGAN,} from "@/core/data/apiRoutes"; import useDirection from "@/lib/app/hooks/useDirection"; import useUser from "@/lib/app/hooks/useUser"; import DataSaverOnIcon from "@mui/icons-material/DataSaverOn"; -import { Box, Button, Stack, TextField } from "@mui/material"; +import {Box, Button, Stack, TextField} from "@mui/material"; import axios from "axios"; -import { Field, Formik } from "formik"; -import { useTranslations } from "next-intl"; -import { useEffect, useState } from "react"; +import {Field, Formik} from "formik"; +import {useTranslations} from "next-intl"; +import {useEffect, useState} from "react"; import * as Yup from "yup"; const NavyForm = () => { - const t = useTranslations(); - const { directionApp } = useDirection(); - const { token } = useUser(); + const t = useTranslations(); + const {directionApp} = useDirection(); + const {token} = useUser(); - // get province list - const [provinceList, setProvinceList] = useState([]); - useEffect(() => { - axios - .get(GET_PROVINCE_LIST, { - headers: { Authorization: `Bearer ${token}` }, - }) - .then(({ data }) => { - const formattedData = data.map((province, index) => ({ - id: index, - name: province.name, - value: province.id, - })); - setProvinceList(formattedData); - }) - .catch((error) => { - Notifications(directionApp, t, error.response); - }); - }, []); - // end get province list + // get province list + const [provinceList, setProvinceList] = useState([]); + useEffect(() => { + axios + .get(GET_PROVINCE_LIST, { + headers: {Authorization: `Bearer ${token}`}, + }) + .then(({data}) => { + const formattedData = data.map((province, index) => ({ + id: index, + name: province.name, + value: province.id, + })); + setProvinceList(formattedData); + }) + .catch((error) => { + Notifications(directionApp, t, error.response); + }); + }, []); + // end get province list - // upload files - const [selectedImageShenasname, setSelectedImageShenasname] = useState( - "/images/upload-image.svg" - ); - const [fileTypeShenasname, setFileTypeShenasname] = useState(null); - const [fileNameShenasname, setFileNameShenasname] = useState(null); - const [selectedImageNationalCard, setSelectedImageNationalCard] = useState( - "/images/upload-image.svg" - ); - const [fileTypeNationalCard, setFileTypeNationalCard] = useState(null); - const [fileNameNationalCard, setFileNameNationalCard] = useState(null); + // upload files + const [selectedImageShenasname, setSelectedImageShenasname] = useState( + "/images/upload-image.svg" + ); + const [fileTypeShenasname, setFileTypeShenasname] = useState(null); + const [fileNameShenasname, setFileNameShenasname] = useState(null); + const [selectedImageNationalCard, setSelectedImageNationalCard] = useState( + "/images/upload-image.svg" + ); + const [fileTypeNationalCard, setFileTypeNationalCard] = useState(null); + const [fileNameNationalCard, setFileNameNationalCard] = useState(null); - const handleUploadChangeShenasname = (event, setFieldValue) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const fileType = event.target?.files?.[0].type; - const fileName = event.target?.files?.[0].name; - setSelectedImageShenasname(URL.createObjectURL(uploadedFile)); - setFileTypeShenasname(fileType); - setFileNameShenasname(fileName); - setFieldValue("shenasname_img", uploadedFile); - } - }; - const handleUploadChangeNationalCard = (event, setFieldValue) => { - const uploadedFile = event.target?.files?.[0]; - const fileType = event.target.files[0].type; - const fileName = event.target.files[0].name; - if (uploadedFile) { - setSelectedImageNationalCard(URL.createObjectURL(uploadedFile)); - setFileTypeNationalCard(fileType); - setFileNameNationalCard(fileName); - setFieldValue("national_card_img", uploadedFile); - } - }; - // end upload files + const handleUploadChangeShenasname = (event, setFieldValue) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const fileType = event.target?.files?.[0].type; + const fileName = event.target?.files?.[0].name; + setSelectedImageShenasname(URL.createObjectURL(uploadedFile)); + setFileTypeShenasname(fileType); + setFileNameShenasname(fileName); + setFieldValue("shenasname_img", uploadedFile); + } + }; + const handleUploadChangeNationalCard = (event, setFieldValue) => { + const uploadedFile = event.target?.files?.[0]; + const fileType = event.target.files[0].type; + const fileName = event.target.files[0].name; + if (uploadedFile) { + setSelectedImageNationalCard(URL.createObjectURL(uploadedFile)); + setFileTypeNationalCard(fileType); + setFileNameNationalCard(fileName); + setFieldValue("national_card_img", uploadedFile); + } + }; + // end upload files - // initial values - const initialValues = { - name: "", - phone_number: "", - vehicle_type: "", - plate_number: "", - province: "", - navgan_id: "", - national_code: "", - shenasname_id: "", - national_card_img: null, - shenasname_img: null, - }; - // end initial values + // initial values + const initialValues = { + name: "", + phone_number: "", + vehicle_type: "", + plate_number: "", + province: "", + navgan_id: "", + national_code: "", + shenasname_id: "", + national_card_img: null, + shenasname_img: null, + }; + // end initial values - // validation - const validationSchema = Yup.object().shape({ - name: Yup.string().required(t("LoanRequest.error_message_required")), - phone_number: Yup.string().required( - t("LoanRequest.error_message_required") - ), - vehicle_type: Yup.string().required( - t("LoanRequest.error_message_required") - ), - plate_number: Yup.string().required( - t("LoanRequest.error_message_required") - ), - navgan_id: Yup.string().required(t("LoanRequest.error_message_required")), - province: Yup.string().required(t("LoanRequest.error_message_required")), - national_code: Yup.string().required( - t("LoanRequest.error_message_required") - ), - shenasname_id: Yup.string().required( - t("LoanRequest.error_message_required") - ), - }); - // end validation + // validation + const validationSchema = Yup.object().shape({ + name: Yup.string().required(t("LoanRequest.error_message_required")), + phone_number: Yup.string().required( + t("LoanRequest.error_message_required") + ), + vehicle_type: Yup.string().required( + t("LoanRequest.error_message_required") + ), + plate_number: Yup.string().required( + t("LoanRequest.error_message_required") + ), + navgan_id: Yup.string().required(t("LoanRequest.error_message_required")), + province: Yup.string().required(t("LoanRequest.error_message_required")), + national_code: Yup.string().required( + t("LoanRequest.error_message_required") + ), + shenasname_id: Yup.string().required( + t("LoanRequest.error_message_required") + ), + }); + // end validation - // submit - const handleSubmit = async (values, props) => { - Notifications(directionApp, t, undefined); - const formData = new FormData(); - formData.append("name", values.name); - formData.append("phone_number", values.phone_number); - formData.append("vehicle_type", values.vehicle_type); - formData.append("plate_number", values.plate_number); - formData.append("province_id", values.province); - formData.append("navgan_id", values.navgan_id); - formData.append("national_code", values.national_code); - formData.append("shenasname_id", values.shenasname_id); - if (values.shenasname_img != null) - formData.append("shenasname_image", values.shenasname_img); - if (values.national_card_img != null) - formData.append("national_card_image", values.national_card_img); + // submit + const handleSubmit = async (values, props) => { + Notifications(directionApp, t, undefined); + const formData = new FormData(); + formData.append("name", values.name); + formData.append("phone_number", values.phone_number); + formData.append("vehicle_type", values.vehicle_type); + formData.append("plate_number", values.plate_number); + formData.append("province_id", values.province); + formData.append("navgan_id", values.navgan_id); + formData.append("national_code", values.national_code); + formData.append("shenasname_id", values.shenasname_id); + if (values.shenasname_img != null) + formData.append("shenasname_image", values.shenasname_img); + if (values.national_card_img != null) + formData.append("national_card_image", values.national_card_img); - await axios - .post(SEND_LOAN_REQUEST_NAVGAN, formData, { - headers: { - Authorization: `Bearer ${token}`, - "Content-Type": "multipart/form-data", - }, - }) - .then(function (response) { - Notifications(directionApp, t, response); - }) - .catch(function (error) { - Notifications(directionApp, t, error.response); - props.setSubmitting(false); - }); - }; - // end submit + await axios + .post(SEND_LOAN_REQUEST_NAVGAN, formData, { + headers: { + Authorization: `Bearer ${token}`, + "Content-Type": "multipart/form-data", + }, + }) + .then(function (response) { + Notifications(directionApp, t, response); + }) + .catch(function (error) { + Notifications(directionApp, t, error.response); + props.setSubmitting(false); + }); + }; + // end submit - return ( - - {(props) => ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - handleUploadChangeShenasname(e, props.setFieldValue) - } - setselectedImage={setSelectedImageShenasname} - setFieldValue={props.setFieldValue} - fieldname="shenasname_img" - fileType={fileTypeShenasname} - fileName={fileNameShenasname} - imageAlt={t("app_name")} - imageSize={[300 /*width*/, 150 /*height*/]} - label={t("LoanRequest.file_field_shenasname_image")} - /> - - handleUploadChangeNationalCard(e, props.setFieldValue) - } - setselectedImage={setSelectedImageNationalCard} - setFieldValue={props.setFieldValue} - fieldname="national_card_img" - fileType={fileTypeNationalCard} - fileName={fileNameNationalCard} - imageAlt={t("app_name")} - imageSize={[300 /*width*/, 150 /*height*/]} - label={t("LoanRequest.file_field_national_card_image")} - /> - - - - - - - )} - - ); + {(props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + handleUploadChangeShenasname(e, props.setFieldValue) + } + setselectedImage={setSelectedImageShenasname} + setFieldValue={props.setFieldValue} + fieldname="shenasname_img" + fileType={fileTypeShenasname} + fileName={fileNameShenasname} + imageAlt={t("app_name")} + imageSize={[300 /*width*/, 150 /*height*/]} + label={t("LoanRequest.file_field_shenasname_image")} + /> + + handleUploadChangeNationalCard(e, props.setFieldValue) + } + setselectedImage={setSelectedImageNationalCard} + setFieldValue={props.setFieldValue} + fieldname="national_card_img" + fileType={fileTypeNationalCard} + fileName={fileNameNationalCard} + imageAlt={t("app_name")} + imageSize={[300 /*width*/, 150 /*height*/]} + label={t("LoanRequest.file_field_national_card_image")} + /> + + + + + + + )} + + ); }; export default NavyForm; diff --git a/src/components/dashboard/loan-request/WelfareServicesForm.jsx b/src/components/dashboard/loan-request/WelfareServicesForm.jsx index 73759bc..6a50ef7 100644 --- a/src/components/dashboard/loan-request/WelfareServicesForm.jsx +++ b/src/components/dashboard/loan-request/WelfareServicesForm.jsx @@ -1,435 +1,435 @@ import Notifications from "@/core/components/notifications"; import StyledForm from "@/core/components/StyledForm"; import UploadSystem from "@/core/components/UploadSystem"; -import { SEND_LOAN_REQUEST_WELFARE } from "@/core/data/apiRoutes"; +import {SEND_LOAN_REQUEST_WELFARE} from "@/core/data/apiRoutes"; import useDirection from "@/lib/app/hooks/useDirection"; import useUser from "@/lib/app/hooks/useUser"; import DataSaverOnIcon from "@mui/icons-material/DataSaverOn"; -import { Box, Button, Stack, TextField } from "@mui/material"; +import {Box, Button, Stack, TextField} from "@mui/material"; import axios from "axios"; -import { Field, Formik } from "formik"; -import { useTranslations } from "next-intl"; -import { useState } from "react"; +import {Field, Formik} from "formik"; +import {useTranslations} from "next-intl"; +import {useState} from "react"; import * as Yup from "yup"; const WelfareServicesForm = () => { - const t = useTranslations(); - const { directionApp } = useDirection(); - const { token } = useUser(); + const t = useTranslations(); + const {directionApp} = useDirection(); + const {token} = useUser(); - // upload files - const [selectedImageShenasname, setSelectedImageShenasname] = useState( - "/images/upload-image.svg" - ); - const [fileTypeShenasname, setFileTypeShenasname] = useState(null); - const [fileNameShenasname, setFileNameShenasname] = useState(null); - const [selectedImageNationalCard, setSelectedImageNationalCard] = useState( - "/images/upload-image.svg" - ); - const [fileTypeNationalCard, setFileTypeNationalCard] = useState(null); - const [fileNameNationalCard, setFileNameNationalCard] = useState(null); + // upload files + const [selectedImageShenasname, setSelectedImageShenasname] = useState( + "/images/upload-image.svg" + ); + const [fileTypeShenasname, setFileTypeShenasname] = useState(null); + const [fileNameShenasname, setFileNameShenasname] = useState(null); + const [selectedImageNationalCard, setSelectedImageNationalCard] = useState( + "/images/upload-image.svg" + ); + const [fileTypeNationalCard, setFileTypeNationalCard] = useState(null); + const [fileNameNationalCard, setFileNameNationalCard] = useState(null); - const handleUploadChangeShenasname = (event, setFieldValue) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const fileType = event.target?.files?.[0].type; - const fileName = event.target?.files?.[0].name; - setSelectedImageShenasname(URL.createObjectURL(uploadedFile)); - setFileTypeShenasname(fileType); - setFileNameShenasname(fileName); - setFieldValue("shenasname_img", uploadedFile); - } - }; - const handleUploadChangeNationalCard = (event, setFieldValue) => { - const uploadedFile = event.target?.files?.[0]; - const fileType = event.target.files[0].type; - const fileName = event.target.files[0].name; - if (uploadedFile) { - setSelectedImageNationalCard(URL.createObjectURL(uploadedFile)); - setFileTypeNationalCard(fileType); - setFileNameNationalCard(fileName); - setFieldValue("national_card_img", uploadedFile); - } - }; - // end upload files + const handleUploadChangeShenasname = (event, setFieldValue) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const fileType = event.target?.files?.[0].type; + const fileName = event.target?.files?.[0].name; + setSelectedImageShenasname(URL.createObjectURL(uploadedFile)); + setFileTypeShenasname(fileType); + setFileNameShenasname(fileName); + setFieldValue("shenasname_img", uploadedFile); + } + }; + const handleUploadChangeNationalCard = (event, setFieldValue) => { + const uploadedFile = event.target?.files?.[0]; + const fileType = event.target.files[0].type; + const fileName = event.target.files[0].name; + if (uploadedFile) { + setSelectedImageNationalCard(URL.createObjectURL(uploadedFile)); + setFileTypeNationalCard(fileType); + setFileNameNationalCard(fileName); + setFieldValue("national_card_img", uploadedFile); + } + }; + // end upload files - // initial values, validation and request action of form - const initialValues = { - name: "", - phone_number: "", - vehicle_type: "", - plate_number: "", - province: "", - national_code: "", - shenasname_id: "", - national_card_img: null, - shenasname_img: null, - }; + // initial values, validation and request action of form + const initialValues = { + name: "", + phone_number: "", + vehicle_type: "", + plate_number: "", + province: "", + national_code: "", + shenasname_id: "", + national_card_img: null, + shenasname_img: null, + }; - const validationSchema = Yup.object().shape({ - name: Yup.string().required(t("LoanRequest.error_message_required")), - phone_number: Yup.string().required( - t("LoanRequest.error_message_required") - ), - vehicle_type: Yup.string().required( - t("LoanRequest.error_message_required") - ), - plate_number: Yup.string().required( - t("LoanRequest.error_message_required") - ), - province: Yup.string().required(t("LoanRequest.error_message_required")), - national_code: Yup.string().required( - t("LoanRequest.error_message_required") - ), - shenasname_id: Yup.string().required( - t("LoanRequest.error_message_required") - ), - }); + const validationSchema = Yup.object().shape({ + name: Yup.string().required(t("LoanRequest.error_message_required")), + phone_number: Yup.string().required( + t("LoanRequest.error_message_required") + ), + vehicle_type: Yup.string().required( + t("LoanRequest.error_message_required") + ), + plate_number: Yup.string().required( + t("LoanRequest.error_message_required") + ), + province: Yup.string().required(t("LoanRequest.error_message_required")), + national_code: Yup.string().required( + t("LoanRequest.error_message_required") + ), + shenasname_id: Yup.string().required( + t("LoanRequest.error_message_required") + ), + }); - const handleSubmit = async (values, props) => { - Notifications(directionApp, t, undefined); - const formData = new FormData(); - formData.append("name", values.name); - formData.append("phone_number", values.phone_number); - formData.append("vehicle_type", values.vehicle_type); - formData.append("plate_number", values.plate_number); - formData.append("province_id", values.province); - formData.append("national_code", values.national_code); - formData.append("shenasname_id", values.shenasname_id); - if (values.shenasname_img != null) - formData.append("shenasname_image", values.shenasname_img); - if (values.national_card_img != null) - formData.append("national_card_image", values.national_card_img); + const handleSubmit = async (values, props) => { + Notifications(directionApp, t, undefined); + const formData = new FormData(); + formData.append("name", values.name); + formData.append("phone_number", values.phone_number); + formData.append("vehicle_type", values.vehicle_type); + formData.append("plate_number", values.plate_number); + formData.append("province_id", values.province); + formData.append("national_code", values.national_code); + formData.append("shenasname_id", values.shenasname_id); + if (values.shenasname_img != null) + formData.append("shenasname_image", values.shenasname_img); + if (values.national_card_img != null) + formData.append("national_card_image", values.national_card_img); - await axios - .post(SEND_LOAN_REQUEST_WELFARE, formData, { - headers: { - Authorization: `Bearer ${token}`, - "Content-Type": "multipart/form-data", - }, - }) - .then(function (response) { - Notifications(directionApp, t, response); - }) - .catch(function (error) { - Notifications(directionApp, t, error.response); - props.setSubmitting(false); - }); - }; - // end initial values, validation and request action of form + await axios + .post(SEND_LOAN_REQUEST_WELFARE, formData, { + headers: { + Authorization: `Bearer ${token}`, + "Content-Type": "multipart/form-data", + }, + }) + .then(function (response) { + Notifications(directionApp, t, response); + }) + .catch(function (error) { + Notifications(directionApp, t, error.response); + props.setSubmitting(false); + }); + }; + // end initial values, validation and request action of form - return ( - - {(props) => ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - handleUploadChangeShenasname(e, props.setFieldValue) - } - setselectedImage={setSelectedImageShenasname} - setFieldValue={props.setFieldValue} - fieldname="shenasname_img" - fileType={fileTypeShenasname} - fileName={fileNameShenasname} - imageAlt={t("app_name")} - imageSize={[300 /*width*/, 150 /*height*/]} - label={t("LoanRequest.file_field_shenasname_image")} - /> - - handleUploadChangeNationalCard(e, props.setFieldValue) - } - setselectedImage={setSelectedImageNationalCard} - setFieldValue={props.setFieldValue} - fieldname="national_card_img" - fileType={fileTypeNationalCard} - fileName={fileNameNationalCard} - imageAlt={t("app_name")} - imageSize={[300 /*width*/, 150 /*height*/]} - label={t("LoanRequest.file_field_national_card_image")} - /> - - - - - - - )} - - ); + {(props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + handleUploadChangeShenasname(e, props.setFieldValue) + } + setselectedImage={setSelectedImageShenasname} + setFieldValue={props.setFieldValue} + fieldname="shenasname_img" + fileType={fileTypeShenasname} + fileName={fileNameShenasname} + imageAlt={t("app_name")} + imageSize={[300 /*width*/, 150 /*height*/]} + label={t("LoanRequest.file_field_shenasname_image")} + /> + + handleUploadChangeNationalCard(e, props.setFieldValue) + } + setselectedImage={setSelectedImageNationalCard} + setFieldValue={props.setFieldValue} + fieldname="national_card_img" + fileType={fileTypeNationalCard} + fileName={fileNameNationalCard} + imageAlt={t("app_name")} + imageSize={[300 /*width*/, 150 /*height*/]} + label={t("LoanRequest.file_field_national_card_image")} + /> + + + + + + + )} + + ); }; export default WelfareServicesForm; diff --git a/src/components/dashboard/loan-request/index.jsx b/src/components/dashboard/loan-request/index.jsx index 3b5d31f..630642a 100644 --- a/src/components/dashboard/loan-request/index.jsx +++ b/src/components/dashboard/loan-request/index.jsx @@ -3,29 +3,29 @@ import DashboardLayouts from "@/layouts/dashboardLayouts"; import useUser from "@/lib/app/hooks/useUser"; import NavyForm from "./NavyForm"; import WelfareServicesForm from "./WelfareServicesForm"; -import { Divider, Chip, Box } from "@mui/material"; -import { useTranslations } from "next-intl"; +import {Box, Chip, Divider} from "@mui/material"; +import {useTranslations} from "next-intl"; const DashboardLoanRequestComponent = () => { - const t = useTranslations(); - const { user } = useUser(); + const t = useTranslations(); + const {user} = useUser(); - return ( - - - - - - - - {user.type_id == 1 ? : } - - - ); + return ( + + + + + + + + {user.type_id == 1 ? : } + + + ); }; export default DashboardLoanRequestComponent; diff --git a/src/components/first/index.jsx b/src/components/first/index.jsx index 1436752..67f6284 100644 --- a/src/components/first/index.jsx +++ b/src/components/first/index.jsx @@ -1,55 +1,55 @@ import dahsboardImage from "&/images/dashboard.svg"; -import { NextLinkComposed } from "@/core/components/LinkRouting"; +import {NextLinkComposed} from "@/core/components/LinkRouting"; import StyledImage from "@/core/components/StyledImage"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import useUser from "@/lib/app/hooks/useUser"; -import { Button, Typography } from "@mui/material"; -import { useTranslations } from "next-intl"; +import {Button, Typography} from "@mui/material"; +import {useTranslations} from "next-intl"; const FirstComponent = () => { - const t = useTranslations(); - const { isAuth } = useUser(); + const t = useTranslations(); + const {isAuth} = useUser(); - return ( - - - - - {t("app_name")} - - {isAuth ? ( - - ) : ( - - )} - - - ); + return ( + + + + + {t("app_name")} + + {isAuth ? ( + + ) : ( + + )} + + + ); }; export default FirstComponent; diff --git a/src/components/login/SendToken.jsx b/src/components/login/SendToken.jsx index 6567084..8699aa4 100644 --- a/src/components/login/SendToken.jsx +++ b/src/components/login/SendToken.jsx @@ -1,167 +1,158 @@ import Notifications from "@/core/components/notifications"; import ResendToken from "@/core/components/ResendToken"; import StyledForm from "@/core/components/StyledForm"; -import { LOGIN } from "@/core/data/apiRoutes"; +import {LOGIN} from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import useDirection from "@/lib/app/hooks/useDirection"; import useUser from "@/lib/app/hooks/useUser"; import ChangeCircleIcon from "@mui/icons-material/ChangeCircle"; import LoginIcon from "@mui/icons-material/Login"; -import { - Box, - Button, - Container, - Grid, - Paper, - Stack, - TextField, - Typography, -} from "@mui/material"; +import {Box, Button, Container, Grid, Paper, Stack, TextField, Typography,} from "@mui/material"; import axios from "axios"; -import { Field, Formik } from "formik"; -import { useTranslations } from "next-intl"; +import {Field, Formik} from "formik"; +import {useTranslations} from "next-intl"; import Image from "next/image"; import * as Yup from "yup"; const SendToken = ({ - PhoneNumber, - setOtpToken, - timer, - setTimer, - initialTimerValue, -}) => { - const t = useTranslations(); - const { directionApp } = useDirection(); - const { setToken } = useUser(); + PhoneNumber, + setOtpToken, + timer, + setTimer, + initialTimerValue, + }) => { + const t = useTranslations(); + const {directionApp} = useDirection(); + const {setToken} = useUser(); - const initialValues = { - phone_number: PhoneNumber, - verification_code: "", - }; - const validationSchema = Yup.object().shape({ - verification_code: Yup.string().required( - t("LoginPage.error_message_required") - ), - }); + const initialValues = { + phone_number: PhoneNumber, + verification_code: "", + }; + const validationSchema = Yup.object().shape({ + verification_code: Yup.string().required( + t("LoginPage.error_message_required") + ), + }); - const handleSubmit = async (values, props) => { - Notifications(directionApp, t, undefined); - await axios - .post(LOGIN, { - phone_number: values.phone_number, - verification_code: values.verification_code, - }) - .then(function (response) { - Notifications(directionApp, t, response); - setToken(response.data.token); - }) - .catch(function (error) { - Notifications(directionApp, t, error.response); - props.setSubmitting(false); - }); - }; + const handleSubmit = async (values, props) => { + Notifications(directionApp, t, undefined); + await axios + .post(LOGIN, { + phone_number: values.phone_number, + verification_code: values.verification_code, + }) + .then(function (response) { + Notifications(directionApp, t, response); + setToken(response.data.token); + }) + .catch(function (error) { + Notifications(directionApp, t, error.response); + props.setSubmitting(false); + }); + }; - return ( - - - - - - {(props) => ( - - - {t("app_name")} - - - {t("login")} - - - - - - {t("LoginPage.sent_token_to")}: {PhoneNumber} - - - - - - - - - - - - - - )} - - - - - - ); + {(props) => ( + + + {t("app_name")} + + + {t("login")} + + + + + + {t("LoginPage.sent_token_to")}: {PhoneNumber} + + + + + + + + + + + + + + )} + + + + + + ); }; export default SendToken; diff --git a/src/components/login/SendUserData.jsx b/src/components/login/SendUserData.jsx index bb14087..8b4b056 100644 --- a/src/components/login/SendUserData.jsx +++ b/src/components/login/SendUserData.jsx @@ -1,173 +1,164 @@ import LinkRouting from "@/core/components/LinkRouting"; import Notifications from "@/core/components/notifications"; import StyledForm from "@/core/components/StyledForm"; -import { SEND_OTP_TOKEN } from "@/core/data/apiRoutes"; +import {SEND_OTP_TOKEN} from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import useDirection from "@/lib/app/hooks/useDirection"; import FingerprintIcon from "@mui/icons-material/Fingerprint"; import PersonAddIcon from "@mui/icons-material/PersonAdd"; -import { - Box, - Button, - Container, - Grid, - Paper, - Stack, - TextField, - Typography, -} from "@mui/material"; +import {Box, Button, Container, Grid, Paper, Stack, TextField, Typography,} from "@mui/material"; import axios from "axios"; -import { Field, Formik } from "formik"; -import { useTranslations } from "next-intl"; +import {Field, Formik} from "formik"; +import {useTranslations} from "next-intl"; import Image from "next/image"; -import { useSearchParams } from "next/navigation"; +import {useSearchParams} from "next/navigation"; import * as Yup from "yup"; const SendUserData = ({ - setOtpToken, - setPhoneNumber, - PhoneNumber, - setTimer, - initialTimerValue, -}) => { - const t = useTranslations(); - const { directionApp } = useDirection(); + setOtpToken, + setPhoneNumber, + PhoneNumber, + setTimer, + initialTimerValue, + }) => { + const t = useTranslations(); + const {directionApp} = useDirection(); - const searchParams = useSearchParams(); - const backUrlDecodedPath = searchParams.get("back_url"); + const searchParams = useSearchParams(); + const backUrlDecodedPath = searchParams.get("back_url"); - const initialValues = { - phone_number: PhoneNumber, - }; - const validationSchema = Yup.object().shape({ - phone_number: Yup.string().required(t("LoginPage.error_message_required")), - }); + const initialValues = { + phone_number: PhoneNumber, + }; + const validationSchema = Yup.object().shape({ + phone_number: Yup.string().required(t("LoginPage.error_message_required")), + }); - const handleSubmit = async (values, props) => { - Notifications(directionApp, t, undefined); - await axios - .post(SEND_OTP_TOKEN, { - phone_number: values.phone_number, - }) - .then(function (response) { - Notifications(directionApp, t, response); - setPhoneNumber(values.phone_number); - setOtpToken(true); - setTimer(initialTimerValue); - }) - .catch(function (error) { - Notifications(directionApp, t, error.response); - props.setSubmitting(false); - }); - }; + const handleSubmit = async (values, props) => { + Notifications(directionApp, t, undefined); + await axios + .post(SEND_OTP_TOKEN, { + phone_number: values.phone_number, + }) + .then(function (response) { + Notifications(directionApp, t, response); + setPhoneNumber(values.phone_number); + setOtpToken(true); + setTimer(initialTimerValue); + }) + .catch(function (error) { + Notifications(directionApp, t, error.response); + props.setSubmitting(false); + }); + }; - return ( - - - - - - {(props) => ( - - - {t("app_name")} - - - {t("Titles.title_login_page")} - - - - - - - - - - - - - - - - - - )} - - - - - - - {t("LoginPage.link_routing_back_to")}{" "} - {backUrlDecodedPath - ? t("LoginPage.link_routing_previuos_page") - : t("LoginPage.link_routing_main_page")} - - - - ); + return ( + + + + + + {(props) => ( + + + {t("app_name")} + + + {t("Titles.title_login_page")} + + + + + + + + + + + + + + + + + + )} + + + + + + + {t("LoginPage.link_routing_back_to")}{" "} + {backUrlDecodedPath + ? t("LoginPage.link_routing_previuos_page") + : t("LoginPage.link_routing_main_page")} + + + + ); }; export default SendUserData; diff --git a/src/components/login/index.jsx b/src/components/login/index.jsx index fe20a4d..1d90474 100644 --- a/src/components/login/index.jsx +++ b/src/components/login/index.jsx @@ -1,37 +1,37 @@ -import { useState } from "react"; +import {useState} from "react"; import SendToken from "./SendToken"; import SendUserData from "./SendUserData"; const LoginComponent = () => { - const [otpToken, setOtpToken] = useState(false); - const [PhoneNumber, setPhoneNumber] = useState(""); + const [otpToken, setOtpToken] = useState(false); + const [PhoneNumber, setPhoneNumber] = useState(""); - // For Resend Token (read ResendToken Component Doc) - const initialTimerValue = 30; - const [timer, setTimer] = useState(initialTimerValue); - // End For Resend Token + // For Resend Token (read ResendToken Component Doc) + const initialTimerValue = 30; + const [timer, setTimer] = useState(initialTimerValue); + // End For Resend Token - if (!otpToken) { - return ( - - ); - } else { - return ( - - ); - } + if (!otpToken) { + return ( + + ); + } else { + return ( + + ); + } }; export default LoginComponent; diff --git a/src/components/not-found.jsx b/src/components/not-found.jsx index c699d84..96f2863 100644 --- a/src/components/not-found.jsx +++ b/src/components/not-found.jsx @@ -1,38 +1,38 @@ import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; -import { Box, Button, Typography } from "@mui/material"; -import { NextLinkComposed } from "@/core/components/LinkRouting"; -import { useTranslations } from "next-intl"; +import {Box, Button, Typography} from "@mui/material"; +import {NextLinkComposed} from "@/core/components/LinkRouting"; +import {useTranslations} from "next-intl"; import Image from "next/image"; const NotFoundComponent = () => { const t = useTranslations(); - return ( - - - - not found image - - - صفحه ای با این عنوان یافت نشد - - - - - ); + return ( + + + + not found image + + + صفحه ای با این عنوان یافت نشد + + + + + ); }; export default NotFoundComponent; diff --git a/src/components/register/RequestOtp.jsx b/src/components/register/RequestOtp.jsx index 3c209d9..88804f8 100644 --- a/src/components/register/RequestOtp.jsx +++ b/src/components/register/RequestOtp.jsx @@ -1,151 +1,143 @@ import LinkRouting from "@/core/components/LinkRouting"; import Notifications from "@/core/components/notifications"; import StyledForm from "@/core/components/StyledForm"; -import { SEND_OTP_TOKEN } from "@/core/data/apiRoutes"; +import {SEND_OTP_TOKEN} from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import useDirection from "@/lib/app/hooks/useDirection"; import FingerprintIcon from "@mui/icons-material/Fingerprint"; -import { - Box, - Button, - Container, - Paper, - Stack, - TextField, - Typography, -} from "@mui/material"; +import {Box, Button, Container, Paper, Stack, TextField, Typography,} from "@mui/material"; import axios from "axios"; -import { Field, Formik } from "formik"; -import { useTranslations } from "next-intl"; +import {Field, Formik} from "formik"; +import {useTranslations} from "next-intl"; import Image from "next/image"; -import { useSearchParams } from "next/navigation"; +import {useSearchParams} from "next/navigation"; import * as Yup from "yup"; const RequestOtp = ({ - setOtpToken, - setPhoneNumber, - PhoneNumber, - setTimer, - initialTimerValue, -}) => { - const t = useTranslations(); - const { directionApp } = useDirection(); + setOtpToken, + setPhoneNumber, + PhoneNumber, + setTimer, + initialTimerValue, + }) => { + const t = useTranslations(); + const {directionApp} = useDirection(); - const searchParams = useSearchParams(); - const backUrlDecodedPath = searchParams.get("back_url"); + const searchParams = useSearchParams(); + const backUrlDecodedPath = searchParams.get("back_url"); - const initialValues = { - phone_number: PhoneNumber, - }; - const validationSchema = Yup.object().shape({ - phone_number: Yup.string().required( - t("RegisterPage.error_message_required") - ), - }); + const initialValues = { + phone_number: PhoneNumber, + }; + const validationSchema = Yup.object().shape({ + phone_number: Yup.string().required( + t("RegisterPage.error_message_required") + ), + }); - const handleSubmit = async (values, props) => { - Notifications(directionApp, t, undefined); - await axios - .post(SEND_OTP_TOKEN, { - phone_number: values.phone_number, - }) - .then(function (response) { - Notifications(directionApp, t, response); - setPhoneNumber(values.phone_number); - setOtpToken(true); - setTimer(initialTimerValue); - }) - .catch(function (error) { - Notifications(directionApp, t, error.response); - props.setSubmitting(false); - }); - }; + const handleSubmit = async (values, props) => { + Notifications(directionApp, t, undefined); + await axios + .post(SEND_OTP_TOKEN, { + phone_number: values.phone_number, + }) + .then(function (response) { + Notifications(directionApp, t, response); + setPhoneNumber(values.phone_number); + setOtpToken(true); + setTimer(initialTimerValue); + }) + .catch(function (error) { + Notifications(directionApp, t, error.response); + props.setSubmitting(false); + }); + }; - return ( - - - - - - {(props) => ( - - - {t("app_name")} - - - {t("Titles.title_register_page")} - - - - - - - - - )} - - - - - - - {t("RegisterPage.link_routing_back_to")}{" "} - {backUrlDecodedPath - ? t("RegisterPage.link_routing_previuos_page") - : t("RegisterPage.link_routing_register")} - - - - ); + return ( + + + + + + {(props) => ( + + + {t("app_name")} + + + {t("Titles.title_register_page")} + + + + + + + + + )} + + + + + + + {t("RegisterPage.link_routing_back_to")}{" "} + {backUrlDecodedPath + ? t("RegisterPage.link_routing_previuos_page") + : t("RegisterPage.link_routing_register")} + + + + ); }; export default RequestOtp; diff --git a/src/components/register/index.jsx b/src/components/register/index.jsx index f71ba2a..6e05291 100644 --- a/src/components/register/index.jsx +++ b/src/components/register/index.jsx @@ -1,98 +1,97 @@ import dahsboardImage from "&/images/dashboard.svg"; -import LinkRouting from "@/core/components/LinkRouting"; -import { NextLinkComposed } from "@/core/components/LinkRouting"; +import LinkRouting, {NextLinkComposed} from "@/core/components/LinkRouting"; import StyledImage from "@/core/components/StyledImage"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import useUser from "@/lib/app/hooks/useUser"; -import { Box, Button, Grid, Stack } from "@mui/material"; -import { useTranslations } from "next-intl"; -import { useSearchParams } from "next/navigation"; +import {Box, Button, Grid, Stack} from "@mui/material"; +import {useTranslations} from "next-intl"; +import {useSearchParams} from "next/navigation"; const RegisterComponent = () => { - const t = useTranslations(); - const { isAuth } = useUser(); + const t = useTranslations(); + const {isAuth} = useUser(); - const searchParams = useSearchParams(); - const backUrlDecodedPath = searchParams.get("back_url"); + const searchParams = useSearchParams(); + const backUrlDecodedPath = searchParams.get("back_url"); - return ( - - - - {isAuth ? ( - - ) : ( - - - - + ) : ( + + + + + + + + + + + )} + + + - {t("register_navy")} - - - - - - - - )} - - - - {t("RegisterPage.link_routing_back_to")}{" "} - {backUrlDecodedPath - ? t("RegisterPage.link_routing_previuos_page") - : t("RegisterPage.link_routing_login")} - - - - ); + {t("RegisterPage.link_routing_back_to")}{" "} + {backUrlDecodedPath + ? t("RegisterPage.link_routing_previuos_page") + : t("RegisterPage.link_routing_login")} + + + + ); }; export default RegisterComponent; diff --git a/src/components/register/navy/UserRegister.jsx b/src/components/register/navy/UserRegister.jsx index e9d618a..b7a50f9 100644 --- a/src/components/register/navy/UserRegister.jsx +++ b/src/components/register/navy/UserRegister.jsx @@ -1,222 +1,212 @@ import Notifications from "@/core/components/notifications"; import StyledForm from "@/core/components/StyledForm"; -import { REGISTER } from "@/core/data/apiRoutes"; +import {REGISTER} from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import useDirection from "@/lib/app/hooks/useDirection"; import LoginIcon from "@mui/icons-material/Login"; import ChangeCircleIcon from "@mui/icons-material/ChangeCircle"; -import { - Box, - Button, - Chip, - Container, - Divider, - Paper, - Stack, - TextField, - Typography, -} from "@mui/material"; +import {Box, Button, Chip, Container, Divider, Paper, Stack, TextField, Typography,} from "@mui/material"; import axios from "axios"; -import { Field, Formik } from "formik"; -import { useTranslations } from "next-intl"; +import {Field, Formik} from "formik"; +import {useTranslations} from "next-intl"; import Image from "next/image"; import * as Yup from "yup"; import ResendToken from "@/core/components/ResendToken"; import useUser from "@/lib/app/hooks/useUser"; const UserRegister = ({ - PhoneNumber, - setOtpToken, - initialTimerValue, - timer, - setTimer, -}) => { - const t = useTranslations(); - const { directionApp } = useDirection(); - const { setToken } = useUser(); + PhoneNumber, + setOtpToken, + initialTimerValue, + timer, + setTimer, + }) => { + const t = useTranslations(); + const {directionApp} = useDirection(); + const {setToken} = useUser(); - const initialValues = { - type_id: "1", - verification_code: "", - phone_number: PhoneNumber, - national_id: "", - navgan_id: "", - }; + const initialValues = { + type_id: "1", + verification_code: "", + phone_number: PhoneNumber, + national_id: "", + navgan_id: "", + }; - const validationSchema = Yup.object().shape({ - verification_code: Yup.string().required( - t("RegisterPage.error_message_required") - ), - national_id: Yup.string().required( - t("RegisterPage.error_message_required") - ), - navgan_id: Yup.string().required(t("RegisterPage.error_message_required")), - }); + const validationSchema = Yup.object().shape({ + verification_code: Yup.string().required( + t("RegisterPage.error_message_required") + ), + national_id: Yup.string().required( + t("RegisterPage.error_message_required") + ), + navgan_id: Yup.string().required(t("RegisterPage.error_message_required")), + }); - const handleSubmit = async (values, props) => { - Notifications(directionApp, t, undefined); - console.log(initialValues); - await axios - .post(REGISTER, { - type_id: values.type_id, - national_id: values.national_id, - navgan_id: values.navgan_id, - phone_number: values.phone_number, - verification_code: values.verification_code, - }) - .then(function (response) { - Notifications(directionApp, t, response); - setOtpToken(true); - setToken(response.data.token); - }) - .catch(function (error) { - Notifications(directionApp, t, error.response); - props.setSubmitting(false); - }); - }; + const handleSubmit = async (values, props) => { + Notifications(directionApp, t, undefined); + console.log(initialValues); + await axios + .post(REGISTER, { + type_id: values.type_id, + national_id: values.national_id, + navgan_id: values.navgan_id, + phone_number: values.phone_number, + verification_code: values.verification_code, + }) + .then(function (response) { + Notifications(directionApp, t, response); + setOtpToken(true); + setToken(response.data.token); + }) + .catch(function (error) { + Notifications(directionApp, t, error.response); + props.setSubmitting(false); + }); + }; - return ( - - - - - - {(props) => ( - - - {t("app_name")} - - - {t("register_navy")} - - - - - - {t("LoginPage.sent_token_to")}: {PhoneNumber} - - - - - - - - - - - - - - - )} - - - - - - ); + {(props) => ( + + + {t("app_name")} + + + {t("register_navy")} + + + + + + {t("LoginPage.sent_token_to")}: {PhoneNumber} + + + + + + + + + + + + + + + )} + + + + + + ); }; export default UserRegister; diff --git a/src/components/register/navy/index.jsx b/src/components/register/navy/index.jsx index f3c5938..68a6069 100644 --- a/src/components/register/navy/index.jsx +++ b/src/components/register/navy/index.jsx @@ -1,37 +1,37 @@ -import { useState } from "react"; +import {useState} from "react"; import RequestOtp from "../RequestOtp"; import UserRegister from "./UserRegister"; const NavyComponent = () => { - const [otpToken, setOtpToken] = useState(false); - const [PhoneNumber, setPhoneNumber] = useState(""); + const [otpToken, setOtpToken] = useState(false); + const [PhoneNumber, setPhoneNumber] = useState(""); - // For Resend Token (read ResendToken Component Doc) - const initialTimerValue = 30; - const [timer, setTimer] = useState(initialTimerValue); - // End For Resend Token + // For Resend Token (read ResendToken Component Doc) + const initialTimerValue = 30; + const [timer, setTimer] = useState(initialTimerValue); + // End For Resend Token - if (!otpToken) { - return ( - - ); - } else { - return ( - - ); - } + if (!otpToken) { + return ( + + ); + } else { + return ( + + ); + } }; export default NavyComponent; diff --git a/src/components/register/welfare-services/UserRegister.jsx b/src/components/register/welfare-services/UserRegister.jsx index c15db81..324c5c2 100644 --- a/src/components/register/welfare-services/UserRegister.jsx +++ b/src/components/register/welfare-services/UserRegister.jsx @@ -1,198 +1,188 @@ import Notifications from "@/core/components/notifications"; import StyledForm from "@/core/components/StyledForm"; -import { REGISTER } from "@/core/data/apiRoutes"; +import {REGISTER} from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import useDirection from "@/lib/app/hooks/useDirection"; import LoginIcon from "@mui/icons-material/Login"; import ChangeCircleIcon from "@mui/icons-material/ChangeCircle"; -import { - Box, - Button, - Chip, - Container, - Divider, - Paper, - Stack, - TextField, - Typography, -} from "@mui/material"; +import {Box, Button, Chip, Container, Divider, Paper, Stack, TextField, Typography,} from "@mui/material"; import axios from "axios"; -import { Field, Formik } from "formik"; -import { useTranslations } from "next-intl"; +import {Field, Formik} from "formik"; +import {useTranslations} from "next-intl"; import Image from "next/image"; import * as Yup from "yup"; import ResendToken from "@/core/components/ResendToken"; import useUser from "@/lib/app/hooks/useUser"; const UserRegister = ({ - PhoneNumber, - setOtpToken, - initialTimerValue, - timer, - setTimer, -}) => { - const t = useTranslations(); - const { directionApp } = useDirection(); - const { setToken } = useUser(); + PhoneNumber, + setOtpToken, + initialTimerValue, + timer, + setTimer, + }) => { + const t = useTranslations(); + const {directionApp} = useDirection(); + const {setToken} = useUser(); - const initialValues = { - type_id: "2", - verification_code: "", - phone_number: PhoneNumber, - national_id: "", - }; + const initialValues = { + type_id: "2", + verification_code: "", + phone_number: PhoneNumber, + national_id: "", + }; - const validationSchema = Yup.object().shape({ - verification_code: Yup.string().required( - t("RegisterPage.error_message_required") - ), - national_id: Yup.string().required( - t("RegisterPage.error_message_required") - ), - }); + const validationSchema = Yup.object().shape({ + verification_code: Yup.string().required( + t("RegisterPage.error_message_required") + ), + national_id: Yup.string().required( + t("RegisterPage.error_message_required") + ), + }); - const handleSubmit = async (values, props) => { - Notifications(directionApp, t, undefined); - console.log(initialValues); - await axios - .post(REGISTER, { - type_id: values.type_id, - national_id: values.national_id, - phone_number: values.phone_number, - verification_code: values.verification_code, - }) - .then(function (response) { - Notifications(directionApp, t, response); - setOtpToken(true); - setToken(response.data.token); - }) - .catch(function (error) { - Notifications(directionApp, t, error.response); - props.setSubmitting(false); - }); - }; + const handleSubmit = async (values, props) => { + Notifications(directionApp, t, undefined); + console.log(initialValues); + await axios + .post(REGISTER, { + type_id: values.type_id, + national_id: values.national_id, + phone_number: values.phone_number, + verification_code: values.verification_code, + }) + .then(function (response) { + Notifications(directionApp, t, response); + setOtpToken(true); + setToken(response.data.token); + }) + .catch(function (error) { + Notifications(directionApp, t, error.response); + props.setSubmitting(false); + }); + }; - return ( - - - - - - {(props) => ( - - - {t("app_name")} - - - {t("register_welfare_services")} - - - - - - {t("LoginPage.sent_token_to")}: {PhoneNumber} - - - - - - - - - - - - - - )} - - - - - - ); + {(props) => ( + + + {t("app_name")} + + + {t("register_welfare_services")} + + + + + + {t("LoginPage.sent_token_to")}: {PhoneNumber} + + + + + + + + + + + + + + )} + + + + + + ); }; export default UserRegister; diff --git a/src/components/register/welfare-services/index.jsx b/src/components/register/welfare-services/index.jsx index f3c5938..68a6069 100644 --- a/src/components/register/welfare-services/index.jsx +++ b/src/components/register/welfare-services/index.jsx @@ -1,37 +1,37 @@ -import { useState } from "react"; +import {useState} from "react"; import RequestOtp from "../RequestOtp"; import UserRegister from "./UserRegister"; const NavyComponent = () => { - const [otpToken, setOtpToken] = useState(false); - const [PhoneNumber, setPhoneNumber] = useState(""); + const [otpToken, setOtpToken] = useState(false); + const [PhoneNumber, setPhoneNumber] = useState(""); - // For Resend Token (read ResendToken Component Doc) - const initialTimerValue = 30; - const [timer, setTimer] = useState(initialTimerValue); - // End For Resend Token + // For Resend Token (read ResendToken Component Doc) + const initialTimerValue = 30; + const [timer, setTimer] = useState(initialTimerValue); + // End For Resend Token - if (!otpToken) { - return ( - - ); - } else { - return ( - - ); - } + if (!otpToken) { + return ( + + ); + } else { + return ( + + ); + } }; export default NavyComponent; diff --git a/src/core/components/LinkRouting.jsx b/src/core/components/LinkRouting.jsx index ff33c86..f8fac0a 100644 --- a/src/core/components/LinkRouting.jsx +++ b/src/core/components/LinkRouting.jsx @@ -1,116 +1,116 @@ import MuiLink from "@mui/material/Link"; -import { styled } from "@mui/material/styles"; +import {styled} from "@mui/material/styles"; import clsx from "clsx"; import NextLink from "next/link"; -import { useRouter } from "next/router"; +import {useRouter} from "next/router"; import * as React from "react"; // Add support for the sx prop for consistency with the other branches. const Anchor = styled("a")({}); export const NextLinkComposed = React.forwardRef(function NextLinkComposed( - props, - ref + props, + ref ) { - const { - to, - linkAs, - replace, - scroll, - shallow, - prefetch, - legacyBehavior = true, - locale, - ...other - } = props; + const { + to, + linkAs, + replace, + scroll, + shallow, + prefetch, + legacyBehavior = true, + locale, + ...other + } = props; - return ( - - - - ); + return ( + + + + ); }); // A styled version of the Next.js Link component: // https://nextjs.org/docs/api-reference/next/link const LinkRouting = React.forwardRef(function Link(props, ref) { - const { - activeClassName = "active", - as, - className: classNameProps, - href, - legacyBehavior, - linkAs: linkAsProp, - locale, - noLinkStyle, - prefetch, - replace, - role, // Link don't have roles. - scroll, - shallow, - ...other - } = props; + const { + activeClassName = "active", + as, + className: classNameProps, + href, + legacyBehavior, + linkAs: linkAsProp, + locale, + noLinkStyle, + prefetch, + replace, + role, // Link don't have roles. + scroll, + shallow, + ...other + } = props; - const router = useRouter(); - const pathname = typeof href === "string" ? href : href.pathname; - const className = clsx(classNameProps, { - [activeClassName]: router.pathname === pathname && activeClassName, - }); + const router = useRouter(); + const pathname = typeof href === "string" ? href : href.pathname; + const className = clsx(classNameProps, { + [activeClassName]: router.pathname === pathname && activeClassName, + }); - const isExternal = - typeof href === "string" && - (href.indexOf("http") === 0 || href.indexOf("mailto:") === 0); + const isExternal = + typeof href === "string" && + (href.indexOf("http") === 0 || href.indexOf("mailto:") === 0); - if (isExternal) { - if (noLinkStyle) { - return ; + if (isExternal) { + if (noLinkStyle) { + return ; + } + + return ; } - return ; - } + const linkAs = linkAsProp || as; + const nextjsProps = { + to: href, + linkAs, + replace, + scroll, + shallow, + prefetch, + legacyBehavior, + locale, + }; - const linkAs = linkAsProp || as; - const nextjsProps = { - to: href, - linkAs, - replace, - scroll, - shallow, - prefetch, - legacyBehavior, - locale, - }; + if (noLinkStyle) { + return ( + + ); + } - if (noLinkStyle) { return ( - + ); - } - - return ( - - ); }); export default LinkRouting; diff --git a/src/core/components/LoadingHardPage.jsx b/src/core/components/LoadingHardPage.jsx index 01ce658..9406e8f 100644 --- a/src/core/components/LoadingHardPage.jsx +++ b/src/core/components/LoadingHardPage.jsx @@ -1,44 +1,44 @@ -import { Backdrop, Fade, styled } from "@mui/material"; +import {Backdrop, Fade, styled} from "@mui/material"; import StyledImage from "./StyledImage"; const LoadingImage = styled(StyledImage)({ - "@keyframes load": { - "0%": { - // opacity: 0, - transform: "scale(1)", + "@keyframes load": { + "0%": { + // opacity: 0, + transform: "scale(1)", + }, + "50%": { + // opacity: 1, + transform: "scale(2)", + }, + "100%": { + // opacity: 0, + transform: "scale(1)", + }, }, - "50%": { - // opacity: 1, - transform: "scale(2)", - }, - "100%": { - // opacity: 0, - transform: "scale(1)", - }, - }, - animation: "load 2s infinite", + animation: "load 2s infinite", }); -const LoadingHardPage = ({ children, loading }) => { - return ( - <> - theme.zIndex.drawer + 1 }} - open={loading} - > - - - - - {children} - - ); +const LoadingHardPage = ({children, loading}) => { + return ( + <> + theme.zIndex.drawer + 1}} + open={loading} + > + + + + + {children} + + ); }; export default LoadingHardPage; diff --git a/src/core/components/Messages.jsx b/src/core/components/Messages.jsx index 2bd45c8..d5fdef9 100644 --- a/src/core/components/Messages.jsx +++ b/src/core/components/Messages.jsx @@ -2,22 +2,22 @@ import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import StyledImage from "./StyledImage"; -const Message = ({ text, actions }) => { - return ( - - - - {text} - {actions} - - - ); +const Message = ({text, actions}) => { + return ( + + + + {text} + {actions} + + + ); }; export default Message; diff --git a/src/core/components/PasswordField.jsx b/src/core/components/PasswordField.jsx index 5747bdb..d109b73 100644 --- a/src/core/components/PasswordField.jsx +++ b/src/core/components/PasswordField.jsx @@ -1,33 +1,33 @@ -import { useState } from "react"; -import { IconButton, InputAdornment, TextField } from "@mui/material"; -import { Visibility, VisibilityOff } from "@mui/icons-material"; -import { Field } from "formik"; +import {useState} from "react"; +import {IconButton, InputAdornment, TextField} from "@mui/material"; +import {Visibility, VisibilityOff} from "@mui/icons-material"; +import {Field} from "formik"; const PasswordField = (props) => { - const [showPassword, setShowPassword] = useState(false); + const [showPassword, setShowPassword] = useState(false); - const handleClickShowPassword = () => { - setShowPassword(!showPassword); - }; + const handleClickShowPassword = () => { + setShowPassword(!showPassword); + }; - return ( - - - {showPassword ? : } - - - ), - }} - /> - ); + return ( + + + {showPassword ? : } + + + ), + }} + /> + ); }; export default PasswordField; diff --git a/src/core/components/ResendToken.jsx b/src/core/components/ResendToken.jsx index b6430d3..1bb900e 100644 --- a/src/core/components/ResendToken.jsx +++ b/src/core/components/ResendToken.jsx @@ -1,72 +1,72 @@ import Notifications from "@/core/components/notifications"; import useDirection from "@/lib/app/hooks/useDirection"; -import { Button, Typography } from "@mui/material"; +import {Button} from "@mui/material"; import axios from "axios"; -import { useTranslations } from "next-intl"; -import { useEffect } from "react"; -import { SEND_OTP_TOKEN } from "../data/apiRoutes"; +import {useTranslations} from "next-intl"; +import {useEffect} from "react"; +import {SEND_OTP_TOKEN} from "../data/apiRoutes"; -const ResendToken = ({ initialTimerValue, timer, setTimer, PhoneNumber }) => { - const t = useTranslations(); - const { directionApp } = useDirection(); +const ResendToken = ({initialTimerValue, timer, setTimer, PhoneNumber}) => { + const t = useTranslations(); + const {directionApp} = useDirection(); - // Countdown Timer - useEffect(() => { - let interval; - if (timer > 0) { - interval = setInterval(() => { - setTimer((prevTimer) => prevTimer - 1); - }, 1000); - } else { - clearInterval(interval); - } + // Countdown Timer + useEffect(() => { + let interval; + if (timer > 0) { + interval = setInterval(() => { + setTimer((prevTimer) => prevTimer - 1); + }, 1000); + } else { + clearInterval(interval); + } - return () => clearInterval(interval); - }, [timer]); - // End Countdown Timer + return () => clearInterval(interval); + }, [timer]); + // End Countdown Timer - // Handle Resend Token - const handleResendClick = async () => { - // work on it - if (timer != 0) return; - Notifications(directionApp, t, undefined); - await axios - .post(SEND_OTP_TOKEN, { - phone_number: PhoneNumber, - }) - .then(function (response) { - Notifications(directionApp, t, response); - setTimer(initialTimerValue); - }) - .catch(function (error) { - Notifications(directionApp, t, error.response); - }); - }; - // End Handle Resend Token + // Handle Resend Token + const handleResendClick = async () => { + // work on it + if (timer != 0) return; + Notifications(directionApp, t, undefined); + await axios + .post(SEND_OTP_TOKEN, { + phone_number: PhoneNumber, + }) + .then(function (response) { + Notifications(directionApp, t, response); + setTimer(initialTimerValue); + }) + .catch(function (error) { + Notifications(directionApp, t, error.response); + }); + }; + // End Handle Resend Token - return ( - <> - {timer > 0 ? ( - - ) : ( - - )} - - ); + return ( + <> + {timer > 0 ? ( + + ) : ( + + )} + + ); }; export default ResendToken; diff --git a/src/core/components/SelectBox.jsx b/src/core/components/SelectBox.jsx index ea39d54..d2d38af 100644 --- a/src/core/components/SelectBox.jsx +++ b/src/core/components/SelectBox.jsx @@ -1,55 +1,49 @@ -import { - FormControl, - FormHelperText, - InputLabel, - MenuItem, - Select, -} from "@mui/material"; +import {FormControl, FormHelperText, InputLabel, MenuItem, Select,} from "@mui/material"; function SelectBox({ - select, - selectType, - selectors, - label, - setFieldValue, - setFieldTouched, - error, - helperText, -}) { - const handleChange = (event) => { - setFieldValue(selectType, event.target.value); - }; - const handleBlur = () => { - setFieldTouched(select, true); - }; - return ( - - {label} - - {helperText} - - ); + select, + selectType, + selectors, + label, + setFieldValue, + setFieldTouched, + error, + helperText, + }) { + const handleChange = (event) => { + setFieldValue(selectType, event.target.value); + }; + const handleBlur = () => { + setFieldTouched(select, true); + }; + return ( + + {label} + + {helperText} + + ); } export default SelectBox; diff --git a/src/core/components/StyledForm.jsx b/src/core/components/StyledForm.jsx index 1f299bb..41eeabc 100644 --- a/src/core/components/StyledForm.jsx +++ b/src/core/components/StyledForm.jsx @@ -1,5 +1,5 @@ -import { styled } from "@mui/material"; -import { Form } from "formik"; +import {styled} from "@mui/material"; +import {Form} from "formik"; const StyledForm = styled(Form)``; diff --git a/src/core/components/StyledImage.jsx b/src/core/components/StyledImage.jsx index 64391ad..58dd65f 100644 --- a/src/core/components/StyledImage.jsx +++ b/src/core/components/StyledImage.jsx @@ -1,4 +1,4 @@ -import { styled } from "@mui/material"; +import {styled} from "@mui/material"; import Image from "next/image"; const StyledImage = styled(Image)``; diff --git a/src/core/components/TitlePage.jsx b/src/core/components/TitlePage.jsx index 7bdcfc2..77c72ee 100644 --- a/src/core/components/TitlePage.jsx +++ b/src/core/components/TitlePage.jsx @@ -1,15 +1,15 @@ -import { useTranslations } from "next-intl"; +import {useTranslations} from "next-intl"; import Head from "next/head"; -const TitlePage = ({ text }) => { - const t = useTranslations(); - return ( - - - {text ? `${t("app_short_name")} | ${t(text)}` : t("app_short_name")} - - - ); +const TitlePage = ({text}) => { + const t = useTranslations(); + return ( + + + {text ? `${t("app_short_name")} | ${t(text)}` : t("app_short_name")} + + + ); }; export default TitlePage; diff --git a/src/core/components/UploadSystem.jsx b/src/core/components/UploadSystem.jsx index 3523c3e..85f38f8 100644 --- a/src/core/components/UploadSystem.jsx +++ b/src/core/components/UploadSystem.jsx @@ -1,148 +1,147 @@ -import { Box, Button, TextField, Typography } from "@mui/material"; -import { useTranslations } from "next-intl"; +import {Box, Button, TextField, Typography} from "@mui/material"; +import {useTranslations} from "next-intl"; import Image from "next/image"; import DeleteForeverIcon from "@mui/icons-material/DeleteForever"; -import { useRef } from "react"; +import {useRef} from "react"; const UploadSystem = ({ - selectedImage, - setselectedImage, - handleUploadChange, - fieldname, - setFieldValue, - imageAlt, - imageSize, - fileType, - fileName, - label, -}) => { - const t = useTranslations(); - const fileInputRef = useRef(null); + selectedImage, + setselectedImage, + handleUploadChange, + fieldname, + setFieldValue, + imageAlt, + imageSize, + fileType, + fileName, + label, + }) => { + const t = useTranslations(); + const fileInputRef = useRef(null); - const handleClick = () => { - fileInputRef.current.click(); - }; - const handleDeleteImage = () => { - setselectedImage("/images/upload-image.svg"); - setFieldValue(fieldname, null); - }; + const handleClick = () => { + fileInputRef.current.click(); + }; + const handleDeleteImage = () => { + setselectedImage("/images/upload-image.svg"); + setFieldValue(fieldname, null); + }; - const isDocumentFormat = (fileType) => { - const documentFormats = [ - "application/pdf", - "application/msword", - "application/vnd.openxmlformats-officedocument.wordprocessingml.document", - "application/vnd.ms-excel", - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", - ]; - return documentFormats.includes(fileType); - }; + const isDocumentFormat = (fileType) => { + const documentFormats = [ + "application/pdf", + "application/msword", + "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + "application/vnd.ms-excel", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + ]; + return documentFormats.includes(fileType); + }; - return ( - - - {label} - - {selectedImage === "/images/upload-image.svg" ? ( - {imageAlt} - ) : fileType && fileType.startsWith("image/") ? ( - {imageAlt} - ) : ( - fileType && - isDocumentFormat(fileType) && ( - + return ( + - {fileName} + {label} - - ) - )} + {selectedImage === "/images/upload-image.svg" ? ( + {imageAlt} + ) : fileType && fileType.startsWith("image/") ? ( + {imageAlt} + ) : ( + fileType && + isDocumentFormat(fileType) && ( + + + {fileName} + + + ) + )} - - - - ); + + + + ); }; export default UploadSystem; - //////****** usage document ******///////// // 1.) use component inside your page // 2.) list of props that you need to send is down below diff --git a/src/core/components/isBotHandler.jsx b/src/core/components/isBotHandler.jsx index 0fde3e3..5a4c4e1 100644 --- a/src/core/components/isBotHandler.jsx +++ b/src/core/components/isBotHandler.jsx @@ -1,8 +1,8 @@ -import { NoSsr } from "@mui/material"; +import {NoSsr} from "@mui/material"; -const NoSsrHandler = ({ isBot, children }) => { - if (isBot) return children; - return {children}; +const NoSsrHandler = ({isBot, children}) => { + if (isBot) return children; + return {children}; }; export default NoSsrHandler; diff --git a/src/core/components/notifications/ErrorNotification.jsx b/src/core/components/notifications/ErrorNotification.jsx index 8e1b99a..de83927 100644 --- a/src/core/components/notifications/ErrorNotification.jsx +++ b/src/core/components/notifications/ErrorNotification.jsx @@ -1,40 +1,40 @@ import DangerousIcon from "@mui/icons-material/Dangerous"; -import { Box, Typography } from "@mui/material"; -import { toast } from "react-toastify"; +import {Box, Typography} from "@mui/material"; +import {toast} from "react-toastify"; const ErrorNotification = (directionApp, t, status, message) => { - toast( - ({ closeToast }) => ( - <> - - - - - - {t("notifications.error")} ({t("notifications.code")}: {status}) - - - {message || t("notifications.error_static_text")} - - - - - - ), - { - position: directionApp === "ltr" ? "top-left" : "top-right", - autoClose: false, - closeOnClick: false, - draggable: false, - } - ); + toast( + ({closeToast}) => ( + <> + + + + + + {t("notifications.error")} ({t("notifications.code")}: {status}) + + + {message || t("notifications.error_static_text")} + + + + + + ), + { + position: directionApp === "ltr" ? "top-left" : "top-right", + autoClose: false, + closeOnClick: false, + draggable: false, + } + ); }; export default ErrorNotification; diff --git a/src/core/components/notifications/SuccessNotification.jsx b/src/core/components/notifications/SuccessNotification.jsx index 420e99a..d45e0ae 100644 --- a/src/core/components/notifications/SuccessNotification.jsx +++ b/src/core/components/notifications/SuccessNotification.jsx @@ -1,43 +1,43 @@ import BeenhereIcon from "@mui/icons-material/Beenhere"; -import { Box, Typography } from "@mui/material"; -import { toast } from "react-toastify"; +import {Box, Typography} from "@mui/material"; +import {toast} from "react-toastify"; const SuccessNotification = (directionApp, t, status) => { - toast( - () => ( - <> - - - - - - {t("notifications.success")} ({t("notifications.code")}:{" "} - {status}) - - - {t("notifications.success_static_text")} - - - - - - ), - { - position: directionApp === "ltr" ? "top-left" : "top-right", - autoClose: 3000, - hideProgressBar: true, - pauseOnHover: true, - closeOnClick: false, - draggable: true, - } - ); + toast( + () => ( + <> + + + + + + {t("notifications.success")} ({t("notifications.code")}:{" "} + {status}) + + + {t("notifications.success_static_text")} + + + + + + ), + { + position: directionApp === "ltr" ? "top-left" : "top-right", + autoClose: 3000, + hideProgressBar: true, + pauseOnHover: true, + closeOnClick: false, + draggable: true, + } + ); }; export default SuccessNotification; diff --git a/src/core/components/notifications/WarningNotification.jsx b/src/core/components/notifications/WarningNotification.jsx index 1451031..59ea1ba 100644 --- a/src/core/components/notifications/WarningNotification.jsx +++ b/src/core/components/notifications/WarningNotification.jsx @@ -1,41 +1,41 @@ import ReportIcon from "@mui/icons-material/Report"; -import { Box, Divider, Typography } from "@mui/material"; -import { toast } from "react-toastify"; +import {Box, Divider, Typography} from "@mui/material"; +import {toast} from "react-toastify"; const WarningNotification = (directionApp, t, status) => { - toast( - ({ closeToast }) => ( - <> - - - - - - {t("warning")} ({t("code")}: {status}) - - - {t("warning_static_text")} - - - - - - - ), - { - position: directionApp === "ltr" ? "top-left" : "top-right", - autoClose: false, - closeOnClick: false, - draggable: false, - } - ); + toast( + ({closeToast}) => ( + <> + + + + + + {t("warning")} ({t("code")}: {status}) + + + {t("warning_static_text")} + + + + + + + ), + { + position: directionApp === "ltr" ? "top-left" : "top-right", + autoClose: false, + closeOnClick: false, + draggable: false, + } + ); }; export default WarningNotification; diff --git a/src/core/components/notifications/index.jsx b/src/core/components/notifications/index.jsx index f27d437..1bf664e 100644 --- a/src/core/components/notifications/index.jsx +++ b/src/core/components/notifications/index.jsx @@ -1,45 +1,45 @@ -import { toast } from "react-toastify"; +import {toast} from "react-toastify"; import ErrorNotification from "./ErrorNotification"; import SuccessNotification from "./SuccessNotification"; import WarningNotification from "./WarningNotification"; const Notifications = async (directionApp, t, response) => { - const { status, data } = response != undefined ? response : "" - toast.dismiss(); - switch (status) { - case 200: - SuccessNotification(directionApp, t, status); - break; - case 400: - ErrorNotification(directionApp, t,status); - break; - case 401: - ErrorNotification(directionApp, t, status); - break; - case 403: - ErrorNotification(directionApp, t, status); - break; - case 422: - ErrorNotification(directionApp, t, status, data.message); - break; - case 500: - WarningNotification(directionApp, t, status); - break; - case 503: - WarningNotification(directionApp, t, status); - break; - case 504: - WarningNotification(directionApp, t, status); - break; - default: - toast(t("pending"), { - position: directionApp === "ltr" ? "top-left" : "top-right", - autoClose: false, - closeOnClick: false, - draggable: false, - }); - break; - } + const {status, data} = response != undefined ? response : "" + toast.dismiss(); + switch (status) { + case 200: + SuccessNotification(directionApp, t, status); + break; + case 400: + ErrorNotification(directionApp, t, status); + break; + case 401: + ErrorNotification(directionApp, t, status); + break; + case 403: + ErrorNotification(directionApp, t, status); + break; + case 422: + ErrorNotification(directionApp, t, status, data.message); + break; + case 500: + WarningNotification(directionApp, t, status); + break; + case 503: + WarningNotification(directionApp, t, status); + break; + case 504: + WarningNotification(directionApp, t, status); + break; + default: + toast(t("pending"), { + position: directionApp === "ltr" ? "top-left" : "top-right", + autoClose: false, + closeOnClick: false, + draggable: false, + }); + break; + } }; export default Notifications; diff --git a/src/core/data/headerProfileItems.jsx b/src/core/data/headerProfileItems.jsx index 90831ba..8164f38 100644 --- a/src/core/data/headerProfileItems.jsx +++ b/src/core/data/headerProfileItems.jsx @@ -1,7 +1,3 @@ -import BorderColorIcon from "@mui/icons-material/BorderColor"; -import PasswordIcon from "@mui/icons-material/Password"; - -const headerProfileItems = [ -]; +const headerProfileItems = []; export default headerProfileItems; diff --git a/src/core/data/sidebarMenu.jsx b/src/core/data/sidebarMenu.jsx index cc01fa6..8027ccf 100644 --- a/src/core/data/sidebarMenu.jsx +++ b/src/core/data/sidebarMenu.jsx @@ -3,29 +3,29 @@ import BookmarkAddedIcon from "@mui/icons-material/BookmarkAdded"; import DataSaverOnIcon from "@mui/icons-material/DataSaverOn"; const sidebarMenu = [ - [ - { - key: "sidebar.dashboard", - type: "page", - route: "/dashboard", - icon: , - selected: false, - }, - { - key: "sidebar.loan-request", - type: "page", - route: "/dashboard/loan-request", - icon: , - selected: false, - }, - { - key: "sidebar.loan-follow-up", - type: "page", - route: "/dashboard/loan-follow-up", - icon: , - selected: false, - }, - ], + [ + { + key: "sidebar.dashboard", + type: "page", + route: "/dashboard", + icon: , + selected: false, + }, + { + key: "sidebar.loan-request", + type: "page", + route: "/dashboard/loan-request", + icon: , + selected: false, + }, + { + key: "sidebar.loan-follow-up", + type: "page", + route: "/dashboard/loan-follow-up", + icon: , + selected: false, + }, + ], ]; export default sidebarMenu; diff --git a/src/core/utils/createEmotionCache.jsx b/src/core/utils/createEmotionCache.jsx index 06add02..413fafe 100644 --- a/src/core/utils/createEmotionCache.jsx +++ b/src/core/utils/createEmotionCache.jsx @@ -1,38 +1,38 @@ import createCache from "@emotion/cache"; -import { prefixer } from "stylis"; +import {prefixer} from "stylis"; import stylisRTLPlugin from "stylis-plugin-rtl"; const isBrowser = typeof document !== "undefined"; export const createEmotionCacheLtr = () => { - let insertionPoint; + let insertionPoint; - if (isBrowser) { - const emotionInsertionPoint = document.querySelector( - 'meta[name="emotion-insertion-point"]' - ); - insertionPoint = emotionInsertionPoint ?? undefined; - } + if (isBrowser) { + const emotionInsertionPoint = document.querySelector( + 'meta[name="emotion-insertion-point"]' + ); + insertionPoint = emotionInsertionPoint ?? undefined; + } - return createCache({ - key: "mui-style", - insertionPoint, - }); + return createCache({ + key: "mui-style", + insertionPoint, + }); }; export const createEmotionCacheRtl = () => { - let insertionPoint; + let insertionPoint; - if (isBrowser) { - const emotionInsertionPoint = document.querySelector( - 'meta[name="emotion-insertion-point"]' - ); - insertionPoint = emotionInsertionPoint ?? undefined; - } + if (isBrowser) { + const emotionInsertionPoint = document.querySelector( + 'meta[name="emotion-insertion-point"]' + ); + insertionPoint = emotionInsertionPoint ?? undefined; + } - return createCache({ - key: "muirtl", - stylisPlugins: [prefixer, stylisRTLPlugin], - insertionPoint, - }); + return createCache({ + key: "muirtl", + stylisPlugins: [prefixer, stylisRTLPlugin], + insertionPoint, + }); }; diff --git a/src/core/utils/theme-rtl.jsx b/src/core/utils/theme-rtl.jsx index c36abeb..bab1c3a 100644 --- a/src/core/utils/theme-rtl.jsx +++ b/src/core/utils/theme-rtl.jsx @@ -1,12 +1,12 @@ -import { createTheme } from "@mui/material/styles"; +import {createTheme} from "@mui/material/styles"; import theme from "./theme"; const themeRtl = createTheme({ - direction: "rtl", - typography: { - fontFamily: `IRANSans, sans-serif`, - }, - ...theme, + direction: "rtl", + typography: { + fontFamily: `IRANSans, sans-serif`, + }, + ...theme, }); export default themeRtl; diff --git a/src/core/utils/theme.jsx b/src/core/utils/theme.jsx index 0a36eee..54ba0b2 100644 --- a/src/core/utils/theme.jsx +++ b/src/core/utils/theme.jsx @@ -1,18 +1,18 @@ const theme = { - palette: { - primary: { - main: "#084070", - contrastText: "#fff", - light: "#2c6291", - dark: "#11293e", + palette: { + primary: { + main: "#084070", + contrastText: "#fff", + light: "#2c6291", + dark: "#11293e", + }, + secondary: { + main: "#FF4E00", + contrastText: "#fff", + light: "#ed743e", + dark: "#ad3a07", + }, }, - secondary: { - main: "#FF4E00", - contrastText: "#fff", - light: "#ed743e", - dark: "#ad3a07", - }, - }, }; export default theme; diff --git a/src/layouts/AppLayout.jsx b/src/layouts/AppLayout.jsx index fc4445f..d2c5da5 100644 --- a/src/layouts/AppLayout.jsx +++ b/src/layouts/AppLayout.jsx @@ -4,96 +4,96 @@ import useLoading from "@/lib/app/hooks/useLoading"; import useUser from "@/lib/app/hooks/useUser"; import Head from "next/head"; import NextNProgress from "nextjs-progressbar"; -import { useEffect } from "react"; +import {useEffect} from "react"; -function AppLayout({ children, isBot }) { - const { languageIsReady } = useLanguage(); - const { setLoadingPage } = useLoading(); - const { userChangedLanguage, token, isAuth } = useUser(); - useEffect(() => { - if (languageIsReady) { - if (token) { - if (isAuth) { - if (userChangedLanguage) { - setLoadingPage(true); +function AppLayout({children, isBot}) { + const {languageIsReady} = useLanguage(); + const {setLoadingPage} = useLoading(); + const {userChangedLanguage, token, isAuth} = useUser(); + useEffect(() => { + if (languageIsReady) { + if (token) { + if (isAuth) { + if (userChangedLanguage) { + setLoadingPage(true); + return; + } + setLoadingPage(false); + return; + } + setLoadingPage(true); + return; + } + setLoadingPage(false); return; - } - setLoadingPage(false); - return; } setLoadingPage(true); - return; - } - setLoadingPage(false); - return; + }, [languageIsReady, token, isAuth, userChangedLanguage]); + + if (!isBot) { + if (userChangedLanguage) return; + if (!languageIsReady) return; } - setLoadingPage(true); - }, [languageIsReady, token, isAuth, userChangedLanguage]); - if (!isBot) { - if (userChangedLanguage) return; - if (!languageIsReady) return; - } - - return ( - <> - - - - - - - - - - - - - - - - - - - - - - {children} - - ); + return ( + <> + + + + + + + + + + + + + + + + + + + + + + {children} + + ); } export default AppLayout; diff --git a/src/layouts/CenterLayout.jsx b/src/layouts/CenterLayout.jsx index 4c8767f..1e1b8bf 100644 --- a/src/layouts/CenterLayout.jsx +++ b/src/layouts/CenterLayout.jsx @@ -1,18 +1,18 @@ -import { Fade, Stack } from "@mui/material"; +import {Fade, Stack} from "@mui/material"; const CenterLayout = (props) => { - return ( - - - {props.children} - - - ); + return ( + + + {props.children} + + + ); }; export default CenterLayout; diff --git a/src/layouts/FullPageLayout.jsx b/src/layouts/FullPageLayout.jsx index cbf2102..d6ed61e 100644 --- a/src/layouts/FullPageLayout.jsx +++ b/src/layouts/FullPageLayout.jsx @@ -1,21 +1,21 @@ -import { Stack } from "@mui/material"; +import {Stack} from "@mui/material"; const FullPageLayout = (props) => { - return ( - - {props.children} - - ); + return ( + + {props.children} + + ); }; export default FullPageLayout; diff --git a/src/layouts/MuiLayout.jsx b/src/layouts/MuiLayout.jsx index ba891d0..2614ac2 100644 --- a/src/layouts/MuiLayout.jsx +++ b/src/layouts/MuiLayout.jsx @@ -1,76 +1,74 @@ import NoSsrHandler from "@/core/components/isBotHandler"; -import { - createEmotionCacheRtl -} from "@/core/utils/createEmotionCache"; +import {createEmotionCacheRtl} from "@/core/utils/createEmotionCache"; import themeRtl from "@/core/utils/theme-rtl"; -import { CacheProvider } from "@emotion/react"; -import { GlobalStyles } from "@mui/material"; +import {CacheProvider} from "@emotion/react"; +import {GlobalStyles} from "@mui/material"; import CssBaseline from "@mui/material/CssBaseline"; -import { ThemeProvider } from "@mui/material/styles"; +import {ThemeProvider} from "@mui/material/styles"; import Head from "next/head"; const clientSideEmotionCacheRtl = createEmotionCacheRtl(); -const MuiLayout = ({ children, isBot }) => { +const MuiLayout = ({children, isBot}) => { - const emotionCache = clientSideEmotionCacheRtl; + const emotionCache = clientSideEmotionCacheRtl; - const theme = themeRtl; - return ( - - - - - - - + + + + + + + body: { + width: "100vw", + height: "100vh", + }, + "#__next": { + width: "100%", + height: "100%", + }, + }} + /> - - {children} - - - - ); + + {children} + + + + ); }; export default MuiLayout; diff --git a/src/layouts/ScrollableLayout.jsx b/src/layouts/ScrollableLayout.jsx index 5ab58ca..583edd7 100644 --- a/src/layouts/ScrollableLayout.jsx +++ b/src/layouts/ScrollableLayout.jsx @@ -1,25 +1,25 @@ -import { Box, Fade } from "@mui/material"; +import {Box, Fade} from "@mui/material"; const ScrollableLayout = (props) => { - const overflowY = props?.y || "hidden"; - const overflowX = props?.x || "hidden"; + const overflowY = props?.y || "hidden"; + const overflowX = props?.x || "hidden"; - return ( - - - {props.children} - - - ); + return ( + + + {props.children} + + + ); }; export default ScrollableLayout; diff --git a/src/layouts/dashboardLayouts/breadcrumbs/BreadcrumbItem.jsx b/src/layouts/dashboardLayouts/breadcrumbs/BreadcrumbItem.jsx index ccff4c9..c233be3 100644 --- a/src/layouts/dashboardLayouts/breadcrumbs/BreadcrumbItem.jsx +++ b/src/layouts/dashboardLayouts/breadcrumbs/BreadcrumbItem.jsx @@ -1,19 +1,19 @@ import LinkRouting from "@/core/components/LinkRouting"; -import { Typography } from "@mui/material"; -import { useTranslations } from "next-intl"; +import {Typography} from "@mui/material"; +import {useTranslations} from "next-intl"; export default function BreadcrumbItem(props) { - const t = useTranslations(); - const isLast = props.index === props.RouterArray.length - 1; - const url = `/${props.RouterArray.slice(0, props.index + 1).join("/")}`; + const t = useTranslations(); + const isLast = props.index === props.RouterArray.length - 1; + const url = `/${props.RouterArray.slice(0, props.index + 1).join("/")}`; - return isLast ? ( - - {t("sidebar." + props.label)} - - ) : ( - - {t("sidebar." + props.label)} - - ); + return isLast ? ( + + {t("sidebar." + props.label)} + + ) : ( + + {t("sidebar." + props.label)} + + ); } diff --git a/src/layouts/dashboardLayouts/breadcrumbs/index.jsx b/src/layouts/dashboardLayouts/breadcrumbs/index.jsx index 3123a12..9ab234e 100644 --- a/src/layouts/dashboardLayouts/breadcrumbs/index.jsx +++ b/src/layouts/dashboardLayouts/breadcrumbs/index.jsx @@ -1,49 +1,49 @@ -import { useRouter } from "next/router"; -import { Box, Breadcrumbs } from "@mui/material"; -import { useTheme } from "@mui/material/styles"; -import { NavigateBefore, NavigateNext } from "@mui/icons-material"; +import {useRouter} from "next/router"; +import {Box, Breadcrumbs} from "@mui/material"; +import {useTheme} from "@mui/material/styles"; +import {NavigateBefore, NavigateNext} from "@mui/icons-material"; import BreadcrumbItem from "./BreadcrumbItem"; const BreadCrumbs = (props) => { - const { isVisible } = props; - const theme = useTheme(); - const router = useRouter(); + const {isVisible} = props; + const theme = useTheme(); + const router = useRouter(); - if (!isVisible) { - return null; - } + if (!isVisible) { + return null; + } - const { pathname } = router; - const RouterArray = pathname.split("/").filter((segment) => segment !== ""); + const {pathname} = router; + const RouterArray = pathname.split("/").filter((segment) => segment !== ""); - if (RouterArray.length === 1) { - return null; - } + if (RouterArray.length === 1) { + return null; + } - return ( - - - ) : ( - - ) - } - aria-label="breadcrumb" - > - {RouterArray.map((segment, index) => ( - - ))} - - - ); + return ( + + + ) : ( + + ) + } + aria-label="breadcrumb" + > + {RouterArray.map((segment, index) => ( + + ))} + + + ); }; export default BreadCrumbs; diff --git a/src/layouts/dashboardLayouts/header/ProfileData.jsx b/src/layouts/dashboardLayouts/header/ProfileData.jsx index eb25403..13ceda1 100644 --- a/src/layouts/dashboardLayouts/header/ProfileData.jsx +++ b/src/layouts/dashboardLayouts/header/ProfileData.jsx @@ -1,15 +1,15 @@ -import { Avatar, Stack, Typography } from "@mui/material"; +import {Avatar, Stack} from "@mui/material"; import useUser from "@/lib/app/hooks/useUser"; export default function ProfileData() { - const { user } = useUser(); - return ( - - - - ); + const {user} = useUser(); + return ( + + + + ); } diff --git a/src/layouts/dashboardLayouts/header/ProfileMenu.jsx b/src/layouts/dashboardLayouts/header/ProfileMenu.jsx index 50f34db..e628e52 100644 --- a/src/layouts/dashboardLayouts/header/ProfileMenu.jsx +++ b/src/layouts/dashboardLayouts/header/ProfileMenu.jsx @@ -1,61 +1,62 @@ -import { Avatar, Menu, IconButton, Tooltip } from "@mui/material"; -import { useState } from "react"; +import {Avatar, IconButton, Menu, Tooltip} from "@mui/material"; +import {useState} from "react"; import ProfileData from "./ProfileData"; import ProfileOptions from "./ProfileOptions"; -import { useTranslations } from "next-intl"; +import {useTranslations} from "next-intl"; import useUser from "@/lib/app/hooks/useUser"; function ProfileMenu() { - const t = useTranslations(); - const [anchorElUser, setAnchorElUser] = useState(null); - const { user } = useUser(); + const t = useTranslations(); + const [anchorElUser, setAnchorElUser] = useState(null); + const {user} = useUser(); - const handleOpenUserMenu = (event) => { - setAnchorElUser(event.currentTarget); - }; - const handleCloseUserMenu = () => { - setAnchorElUser(null); - }; + const handleOpenUserMenu = (event) => { + setAnchorElUser(event.currentTarget); + }; + const handleCloseUserMenu = () => { + setAnchorElUser(null); + }; - return ( - <> - - - - - - - - - - - ); + return ( + <> + + + + + + + + + + + ); } + export default ProfileMenu; diff --git a/src/layouts/dashboardLayouts/header/ProfileOptionLogOut.jsx b/src/layouts/dashboardLayouts/header/ProfileOptionLogOut.jsx index f56db6c..2a6cf85 100644 --- a/src/layouts/dashboardLayouts/header/ProfileOptionLogOut.jsx +++ b/src/layouts/dashboardLayouts/header/ProfileOptionLogOut.jsx @@ -1,49 +1,49 @@ -import { Box, Button, MenuItem, Typography } from "@mui/material"; +import {Box, Button, MenuItem, Typography} from "@mui/material"; import MeetingRoomIcon from "@mui/icons-material/MeetingRoom"; import useUser from "@/lib/app/hooks/useUser"; -import { useTranslations } from "next-intl"; +import {useTranslations} from "next-intl"; -export default function ProfileOptionLogOut({ handleCloseUserMenu }) { - const t = useTranslations(); - const { clearToken } = useUser(); - const handleClickLogOut = () => { - handleCloseUserMenu(); - clearToken(); - }; - return ( - <> - - - - - - - {t("header.logout")} - - - - - ); +export default function ProfileOptionLogOut({handleCloseUserMenu}) { + const t = useTranslations(); + const {clearToken} = useUser(); + const handleClickLogOut = () => { + handleCloseUserMenu(); + clearToken(); + }; + return ( + <> + + + + + + + {t("header.logout")} + + + + + ); } diff --git a/src/layouts/dashboardLayouts/header/ProfileOptions.jsx b/src/layouts/dashboardLayouts/header/ProfileOptions.jsx index bf63212..6e7bdba 100644 --- a/src/layouts/dashboardLayouts/header/ProfileOptions.jsx +++ b/src/layouts/dashboardLayouts/header/ProfileOptions.jsx @@ -1,49 +1,49 @@ -import { Box, MenuItem, Typography } from "@mui/material"; -import { NextLinkComposed } from "@/core/components/LinkRouting"; -import { useTranslations } from "next-intl"; +import {Box, MenuItem, Typography} from "@mui/material"; +import {NextLinkComposed} from "@/core/components/LinkRouting"; +import {useTranslations} from "next-intl"; import headerProfileItems from "@/core/data/headerProfileItems"; import ProfileOptionLogOut from "./ProfileOptionLogOut"; -export default function ProfileOptions({ handleCloseUserMenu }) { - const t = useTranslations(); +export default function ProfileOptions({handleCloseUserMenu}) { + const t = useTranslations(); - return ( - <> - {headerProfileItems.map((profile_item) => ( - - - - {profile_item.icon} - - - {t(profile_item.name)} - - - - ))} - - - ); + return ( + <> + {headerProfileItems.map((profile_item) => ( + + + + {profile_item.icon} + + + {t(profile_item.name)} + + + + ))} + + + ); } diff --git a/src/layouts/dashboardLayouts/header/index.jsx b/src/layouts/dashboardLayouts/header/index.jsx index cd1e4a0..8760960 100644 --- a/src/layouts/dashboardLayouts/header/index.jsx +++ b/src/layouts/dashboardLayouts/header/index.jsx @@ -1,80 +1,72 @@ import MenuIcon from "@mui/icons-material/Menu"; -import { - AppBar, - Box, - Container, - CssBaseline, - IconButton, - Stack, - Toolbar, - useTheme -} from "@mui/material"; +import {AppBar, Box, Container, CssBaseline, IconButton, Stack, Toolbar, useTheme} from "@mui/material"; import ProfileMenu from "./ProfileMenu"; -function Header({ drawerWidth, handleDrawerToggle }) { - const theme = useTheme(); +function Header({drawerWidth, handleDrawerToggle}) { + const theme = useTheme(); - return ( - <> - - - - - - - - - - - + + - - - - - - - - - - ); + > + + + + + + + + + + + + + + + + + + + ); } + export default Header; diff --git a/src/layouts/dashboardLayouts/index.jsx b/src/layouts/dashboardLayouts/index.jsx index f1478bf..ed0ee31 100644 --- a/src/layouts/dashboardLayouts/index.jsx +++ b/src/layouts/dashboardLayouts/index.jsx @@ -1,50 +1,50 @@ -import { useState } from "react"; +import {useState} from "react"; import FullPageLayout from "../FullPageLayout"; import Header from "./header"; import Sidebar from "./sidebar"; -import { Toolbar } from "@mui/material"; +import {Toolbar} from "@mui/material"; import BreadCrumbs from "./breadcrumbs"; -import { ToastContainer } from "react-toastify"; +import {ToastContainer} from "react-toastify"; import "react-toastify/dist/ReactToastify.css"; import useDirection from "@/lib/app/hooks/useDirection"; const drawerWidth = 240; const DashboardLayouts = (props) => { - const { directionApp } = useDirection(); - const { window } = props; - const [mobileOpen, setMobileOpen] = useState(false); - const container = - window !== undefined ? () => window().document.body : undefined; + const {directionApp} = useDirection(); + const {window} = props; + const [mobileOpen, setMobileOpen] = useState(false); + const container = + window !== undefined ? () => window().document.body : undefined; - const handleDrawerToggle = () => { - setMobileOpen(!mobileOpen); - }; - return ( - -
- - - - - - {props.children} + const handleDrawerToggle = () => { + setMobileOpen(!mobileOpen); + }; + return ( + +
+ + + + + + {props.children} + + + {directionApp === "rtl" ? : } - - {directionApp === "rtl" ? : } - - ); + ); }; export default DashboardLayouts; diff --git a/src/layouts/dashboardLayouts/sidebar/SidebarDrawer.jsx b/src/layouts/dashboardLayouts/sidebar/SidebarDrawer.jsx index 466c743..5eff37a 100644 --- a/src/layouts/dashboardLayouts/sidebar/SidebarDrawer.jsx +++ b/src/layouts/dashboardLayouts/sidebar/SidebarDrawer.jsx @@ -1,26 +1,26 @@ import useUser from "@/lib/app/hooks/useUser"; -import { Divider, Stack, Toolbar, Typography } from "@mui/material"; -import { useTranslations } from "next-intl"; +import {Divider, Stack, Toolbar, Typography} from "@mui/material"; +import {useTranslations} from "next-intl"; import SidebarList from "./SidebarList"; -const SidebarDrawer = ({ handleDrawerToggle }) => { - const { user } = useUser(); - const t = useTranslations(); +const SidebarDrawer = ({handleDrawerToggle}) => { + const {user} = useUser(); + const t = useTranslations(); - return ( - <> - - - - {t("app_short_name")} - - {user.type_name} - - - - - - ); + return ( + <> + + + + {t("app_short_name")} + + {user.type_name} + + + + + + ); }; export default SidebarDrawer; diff --git a/src/layouts/dashboardLayouts/sidebar/SidebarList.jsx b/src/layouts/dashboardLayouts/sidebar/SidebarList.jsx index 79dd93e..2d4019c 100644 --- a/src/layouts/dashboardLayouts/sidebar/SidebarList.jsx +++ b/src/layouts/dashboardLayouts/sidebar/SidebarList.jsx @@ -1,56 +1,56 @@ -import { Divider, List } from "@mui/material"; -import { Fragment, useEffect, useReducer } from "react"; +import {Divider, List} from "@mui/material"; +import {Fragment, useEffect, useReducer} from "react"; import SidebarListItem from "./SidebarListItem"; import sidebarMenu from "@/core/data/sidebarMenu"; -import { useRouter } from "next/router"; +import {useRouter} from "next/router"; function reducer(state, action) { - switch (action.type) { - case "COLLAPSE_MENU": - return state.map((itemsArr) => - itemsArr.map((item) => - action.key == item.key - ? { ...item, showSubItem: !item.showSubItem } - : item - ) - ); - case "SELECTED": - return state.map((itemsArr) => - itemsArr.map((item) => - action.route == item.route - ? { ...item, selected: true } - : { ...item, selected: false } - ) - ); - default: - throw new Error(); - } + switch (action.type) { + case "COLLAPSE_MENU": + return state.map((itemsArr) => + itemsArr.map((item) => + action.key == item.key + ? {...item, showSubItem: !item.showSubItem} + : item + ) + ); + case "SELECTED": + return state.map((itemsArr) => + itemsArr.map((item) => + action.route == item.route + ? {...item, selected: true} + : {...item, selected: false} + ) + ); + default: + throw new Error(); + } } -export default function SidebarList({ handleDrawerToggle }) { - const [itemMenu, dispatch] = useReducer(reducer, sidebarMenu); +export default function SidebarList({handleDrawerToggle}) { + const [itemMenu, dispatch] = useReducer(reducer, sidebarMenu); - // activate current page in menu - const router = useRouter(); - useEffect(() => { - dispatch({ type: "SELECTED", route: router.pathname }); - }, [router.pathname]); + // activate current page in menu + const router = useRouter(); + useEffect(() => { + dispatch({type: "SELECTED", route: router.pathname}); + }, [router.pathname]); - return ( - - {itemMenu.map((itemArr, index) => ( - - {itemArr.map((item) => ( - - ))} - - - ))} - - ); + return ( + + {itemMenu.map((itemArr, index) => ( + + {itemArr.map((item) => ( + + ))} + + + ))} + + ); } diff --git a/src/layouts/dashboardLayouts/sidebar/SidebarListItem.jsx b/src/layouts/dashboardLayouts/sidebar/SidebarListItem.jsx index ba270a5..f663413 100644 --- a/src/layouts/dashboardLayouts/sidebar/SidebarListItem.jsx +++ b/src/layouts/dashboardLayouts/sidebar/SidebarListItem.jsx @@ -1,64 +1,59 @@ -import { NextLinkComposed } from "@/core/components/LinkRouting"; +import {NextLinkComposed} from "@/core/components/LinkRouting"; import ExpandLess from "@mui/icons-material/ExpandLess"; import ExpandMore from "@mui/icons-material/ExpandMore"; -import { - ListItem, - ListItemButton, - ListItemIcon, - ListItemText, -} from "@mui/material"; -import { useTranslations } from "next-intl"; -import { Fragment } from "react"; +import {ListItem, ListItemButton, ListItemIcon, ListItemText,} from "@mui/material"; +import {useTranslations} from "next-intl"; +import {Fragment} from "react"; import SidebarListSubItem from "./SidebarListSubItem"; -const SidebarListItem = ({ item, dispatch, handleDrawerToggle }) => { - const t = useTranslations(); +const SidebarListItem = ({item, dispatch, handleDrawerToggle}) => { + const t = useTranslations(); - return ( - - - { - if (item.type == "menu") { - dispatch({ type: "COLLAPSE_MENU", key: item.key }); - } - handleDrawerToggle(); - }} - sx={{ - minHeight: 48, - }} - > - - {item.icon} - - + return ( + + + { + if (item.type == "menu") { + dispatch({type: "COLLAPSE_MENU", key: item.key}); + } + handleDrawerToggle(); + }} + sx={{ + minHeight: 48, + }} + > + + {item.icon} + + - {item.type == "menu" && - (item.showSubItem ? : )} - - - {item.subItem && ( - - )} - - ); + {item.type == "menu" && + (item.showSubItem ? : )} + + + {item.subItem && ( + + )} + + ); }; export default SidebarListItem; diff --git a/src/layouts/dashboardLayouts/sidebar/SidebarListSubItem.jsx b/src/layouts/dashboardLayouts/sidebar/SidebarListSubItem.jsx index f960efb..3407081 100644 --- a/src/layouts/dashboardLayouts/sidebar/SidebarListSubItem.jsx +++ b/src/layouts/dashboardLayouts/sidebar/SidebarListSubItem.jsx @@ -1,54 +1,48 @@ -import { NextLinkComposed } from "@/core/components/LinkRouting"; +import {NextLinkComposed} from "@/core/components/LinkRouting"; import InboxIcon from "@mui/icons-material/MoveToInbox"; -import { - Collapse, - List, - ListItemButton, - ListItemIcon, - ListItemText, -} from "@mui/material"; -import { useTranslations } from "next-intl"; -import { Fragment } from "react"; +import {Collapse, List, ListItemButton, ListItemIcon, ListItemText,} from "@mui/material"; +import {useTranslations} from "next-intl"; +import {Fragment} from "react"; -const SidebarListSubItem = ({ item, handleDrawerToggle }) => { - const t = useTranslations(); +const SidebarListSubItem = ({item, handleDrawerToggle}) => { + const t = useTranslations(); - return ( - - - {item.subItem.map((subitem, index) => ( - - { - if (item.type == "menu") { - dispatch({ type: "COLLAPSE_MENU", key: item.key }); - } - handleDrawerToggle(); - }} - > - - - - - - - ))} - - - ); + return ( + + + {item.subItem.map((subitem, index) => ( + + { + if (item.type == "menu") { + dispatch({type: "COLLAPSE_MENU", key: item.key}); + } + handleDrawerToggle(); + }} + > + + + + + + + ))} + + + ); }; export default SidebarListSubItem; diff --git a/src/layouts/dashboardLayouts/sidebar/index.jsx b/src/layouts/dashboardLayouts/sidebar/index.jsx index dcf7fe2..2498dfd 100644 --- a/src/layouts/dashboardLayouts/sidebar/index.jsx +++ b/src/layouts/dashboardLayouts/sidebar/index.jsx @@ -1,46 +1,46 @@ -import { Box, Drawer } from "@mui/material"; +import {Box, Drawer} from "@mui/material"; import SidebarDrawer from "./SidebarDrawer"; const Sidebar = (props) => { - return ( - - - - - - - - - ); + return ( + + + + + + + + + ); }; export default Sidebar; diff --git a/src/lib/app/contexts/language.jsx b/src/lib/app/contexts/language.jsx index c8ac313..e3f41f4 100644 --- a/src/lib/app/contexts/language.jsx +++ b/src/lib/app/contexts/language.jsx @@ -1,99 +1,99 @@ -import { FA_DATATABLE_LOCALIZATION } from "&/locales/fa/datatable"; -import { useRouter } from "next/router"; -import { createContext, useEffect, useState } from "react"; +import {FA_DATATABLE_LOCALIZATION} from "&/locales/fa/datatable"; +import {useRouter} from "next/router"; +import {createContext, useEffect, useState} from "react"; import useUser from "../hooks/useUser"; export const LanguageContext = createContext(); -export const LanguageProvider = ({ children }) => { - const router = useRouter(); - const languageList = [ - { - key: "fa", - dir: "rtl", - name: "فارسی", - fontFamily: `IRANSans, sans-serif`, - tableLocalization: FA_DATATABLE_LOCALIZATION, - } - ]; - const { user, userChangedLanguage, changeLanguageState } = useUser(); - const [languageIsReady, setLanguageIsReady] = useState(false); - const [languageApp, setLanguageApp] = useState(); - const [directionApp, setDirectionApp] = useState( - process.env.NEXT_PUBLIC_DEFAULT_DIRECTION - ); - - useEffect(() => { - const lang = localStorage.getItem("_language"); - - if (!lang && !languageApp) { - setLanguageApp(process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE); - } else if (lang) { - setLanguageApp(lang); - } - }, []); - - useEffect(() => { - if (!languageApp) return; - - const lang = localStorage.getItem("_language"); - - if (!lang) { - localStorage.setItem("_language", languageApp); - } else { - if (languageApp != lang) { - localStorage.setItem("_language", languageApp); - } - } - }, [languageApp]); - - useEffect(() => { - if (!router.isReady) return; - if (user.user_language) { - if (user.user_language != languageApp) { - setLanguageApp(user.user_language); - return; - } - } - - if (languageApp != router.locale) { - router.replace( - { pathname: router.pathname, query: router.query }, - router.asPath, +export const LanguageProvider = ({children}) => { + const router = useRouter(); + const languageList = [ { - locale: languageApp, + key: "fa", + dir: "rtl", + name: "فارسی", + fontFamily: `IRANSans, sans-serif`, + tableLocalization: FA_DATATABLE_LOCALIZATION, } - ); - return; - } - for (const lang of languageList) { - if (languageApp != lang.key) continue; - setDirectionApp(lang.dir); - document.dir = lang.dir; - } + ]; + const {user, userChangedLanguage, changeLanguageState} = useUser(); + const [languageIsReady, setLanguageIsReady] = useState(false); + const [languageApp, setLanguageApp] = useState(); + const [directionApp, setDirectionApp] = useState( + process.env.NEXT_PUBLIC_DEFAULT_DIRECTION + ); - const timer = setTimeout(() => { - changeLanguageState(false); - setLanguageIsReady(true); - }, 1000); + useEffect(() => { + const lang = localStorage.getItem("_language"); - return () => { - clearTimeout(timer); - }; - }, [router.locale, router.isReady, userChangedLanguage, languageApp]); + if (!lang && !languageApp) { + setLanguageApp(process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE); + } else if (lang) { + setLanguageApp(lang); + } + }, []); - return ( - - {children} - - ); + useEffect(() => { + if (!languageApp) return; + + const lang = localStorage.getItem("_language"); + + if (!lang) { + localStorage.setItem("_language", languageApp); + } else { + if (languageApp != lang) { + localStorage.setItem("_language", languageApp); + } + } + }, [languageApp]); + + useEffect(() => { + if (!router.isReady) return; + if (user.user_language) { + if (user.user_language != languageApp) { + setLanguageApp(user.user_language); + return; + } + } + + if (languageApp != router.locale) { + router.replace( + {pathname: router.pathname, query: router.query}, + router.asPath, + { + locale: languageApp, + } + ); + return; + } + for (const lang of languageList) { + if (languageApp != lang.key) continue; + setDirectionApp(lang.dir); + document.dir = lang.dir; + } + + const timer = setTimeout(() => { + changeLanguageState(false); + setLanguageIsReady(true); + }, 1000); + + return () => { + clearTimeout(timer); + }; + }, [router.locale, router.isReady, userChangedLanguage, languageApp]); + + return ( + + {children} + + ); }; diff --git a/src/lib/app/contexts/loading.jsx b/src/lib/app/contexts/loading.jsx index 6e95a8c..f5b8a47 100644 --- a/src/lib/app/contexts/loading.jsx +++ b/src/lib/app/contexts/loading.jsx @@ -1,14 +1,14 @@ import LoadingHardPage from "@/core/components/LoadingHardPage"; -import { createContext, useState } from "react"; +import {createContext, useState} from "react"; export const LoadingContext = createContext(); -export const LoadingProvider = ({ children }) => { - const [loadingPage, setLoadingPage] = useState(false); - return ( - - - {children} - - ); +export const LoadingProvider = ({children}) => { + const [loadingPage, setLoadingPage] = useState(false); + return ( + + + {children} + + ); }; diff --git a/src/lib/app/contexts/user.jsx b/src/lib/app/contexts/user.jsx index e859c58..ccfdb22 100644 --- a/src/lib/app/contexts/user.jsx +++ b/src/lib/app/contexts/user.jsx @@ -1,121 +1,122 @@ -import { USER_INFO } from "@/core/data/apiRoutes"; +import {USER_INFO} from "@/core/data/apiRoutes"; import axios from "axios"; -import { createContext, useCallback, useEffect, useReducer } from "react"; +import {createContext, useCallback, useEffect, useReducer} from "react"; const initialUser = { - isAuth: false, - userChangedLanguage: false, - token: null, - user: {}, + isAuth: false, + userChangedLanguage: false, + token: null, + user: {}, }; const reducer = (state, action) => { - switch (action.type) { - case "CLEAR_USER": - return { ...state, user: {} }; - case "CHANGE_USER": - return { ...state, user: action.user }; - case "CHANGE_USER_LANGUAGE": - return { - ...state, - user: { ...state.user, user_language: action.language }, - }; - case "CHANGE_AUTH_STATE": - return { ...state, isAuth: action.isAuth }; - case "CHANGE_LANGUAGE_STATE": - return { ...state, userChangedLanguage: action.userChangedLanguage }; - case "CLEAR_TOKEN": - localStorage.removeItem("_token"); - return { ...state, token: null }; - case "SET_TOKEN": - localStorage.setItem("_token", action.token); - return { ...state, token: action.token }; - default: - return state; - } + switch (action.type) { + case "CLEAR_USER": + return {...state, user: {}}; + case "CHANGE_USER": + return {...state, user: action.user}; + case "CHANGE_USER_LANGUAGE": + return { + ...state, + user: {...state.user, user_language: action.language}, + }; + case "CHANGE_AUTH_STATE": + return {...state, isAuth: action.isAuth}; + case "CHANGE_LANGUAGE_STATE": + return {...state, userChangedLanguage: action.userChangedLanguage}; + case "CLEAR_TOKEN": + localStorage.removeItem("_token"); + return {...state, token: null}; + case "SET_TOKEN": + localStorage.setItem("_token", action.token); + return {...state, token: action.token}; + default: + return state; + } }; export const UserContext = createContext(); -export const UserProvider = ({ children }) => { - const [state, dispatch] = useReducer(reducer, initialUser); +export const UserProvider = ({children}) => { + const [state, dispatch] = useReducer(reducer, initialUser); - const clearUser = useCallback(() => { - dispatch({ type: "CLEAR_USER" }); - }, []); + const clearUser = useCallback(() => { + dispatch({type: "CLEAR_USER"}); + }, []); - const changeUser = useCallback((user) => { - dispatch({ type: "CHANGE_USER", user }); - }, []); + const changeUser = useCallback((user) => { + dispatch({type: "CHANGE_USER", user}); + }, []); - const changeUserLanguage = useCallback(/* for multi language app */); + const changeUserLanguage = useCallback(/* for multi language app */); - const changeAuthState = useCallback((isAuth) => { - dispatch({ type: "CHANGE_AUTH_STATE", isAuth }); - }, []); + const changeAuthState = useCallback((isAuth) => { + dispatch({type: "CHANGE_AUTH_STATE", isAuth}); + }, []); - const changeLanguageState = useCallback((userChangedLanguage) => { - dispatch({ type: "CHANGE_LANGUAGE_STATE", userChangedLanguage }); - }, []); + const changeLanguageState = useCallback((userChangedLanguage) => { + dispatch({type: "CHANGE_LANGUAGE_STATE", userChangedLanguage}); + }, []); - const clearToken = useCallback(() => { - dispatch({ type: "CLEAR_TOKEN" }); - }, []); + const clearToken = useCallback(() => { + dispatch({type: "CLEAR_TOKEN"}); + }, []); - const setToken = useCallback((token) => { - dispatch({ type: "SET_TOKEN", token }); - }, []); + const setToken = useCallback((token) => { + dispatch({type: "SET_TOKEN", token}); + }, []); - const getUser = useCallback( - (callback = () => {}) => { - axios - .get(USER_INFO, { - headers: { authorization: `Bearer ${state.token}` }, - }) - .then(({ data }) => { - if (typeof callback === "function") callback(data); + const getUser = useCallback( + (callback = () => { + }) => { + axios + .get(USER_INFO, { + headers: {authorization: `Bearer ${state.token}`}, + }) + .then(({data}) => { + if (typeof callback === "function") callback(data); + }); + }, + [state.token] + ); + + useEffect(() => { + const localToken = localStorage.getItem("_token"); + if (localToken) dispatch({type: "SET_TOKEN", token: localToken}); + }, []); + + useEffect(() => { + if (!state.token) { + clearUser(); + changeAuthState(false); + changeLanguageState(false); + return; + } + getUser((data) => { + changeUser(data); + changeAuthState(true); + changeLanguageState(true); }); - }, - [state.token] - ); + }, [state.token]); - useEffect(() => { - const localToken = localStorage.getItem("_token"); - if (localToken) dispatch({ type: "SET_TOKEN", token: localToken }); - }, []); - - useEffect(() => { - if (!state.token) { - clearUser(); - changeAuthState(false); - changeLanguageState(false); - return; - } - getUser((data) => { - changeUser(data); - changeAuthState(true); - changeLanguageState(true); - }); - }, [state.token]); - - return ( - - {children} - - ); + return ( + + {children} + + ); }; diff --git a/src/lib/app/hooks/useDirection.jsx b/src/lib/app/hooks/useDirection.jsx index e45cb24..b2e01fe 100644 --- a/src/lib/app/hooks/useDirection.jsx +++ b/src/lib/app/hooks/useDirection.jsx @@ -1,10 +1,10 @@ -import { useContext } from "react"; -import { LanguageContext } from "../contexts/language"; +import {useContext} from "react"; +import {LanguageContext} from "../contexts/language"; const useDirection = () => { - const { directionApp } = useContext(LanguageContext); + const {directionApp} = useContext(LanguageContext); - return { directionApp }; + return {directionApp}; }; export default useDirection; diff --git a/src/lib/app/hooks/useLanguage.jsx b/src/lib/app/hooks/useLanguage.jsx index 66e2ee0..d663835 100644 --- a/src/lib/app/hooks/useLanguage.jsx +++ b/src/lib/app/hooks/useLanguage.jsx @@ -1,28 +1,28 @@ -import { useContext } from "react"; -import { LanguageContext } from "../contexts/language"; +import {useContext} from "react"; +import {LanguageContext} from "../contexts/language"; import useUser from "./useUser"; const useLanguage = () => { - const { isAuth, changeUserLanguage } = useUser(); - const { - languageApp, - setLanguageApp, - languageIsReady, - setLanguageIsReady, - languageList, - } = useContext(LanguageContext); + const {isAuth, changeUserLanguage} = useUser(); + const { + languageApp, + setLanguageApp, + languageIsReady, + setLanguageIsReady, + languageList, + } = useContext(LanguageContext); - const changeLanguage = (lang) => { - if (lang == languageApp) return; + const changeLanguage = (lang) => { + if (lang == languageApp) return; - setLanguageIsReady(false); - setLanguageApp(lang); - if (isAuth) { - changeUserLanguage(lang); - } - }; + setLanguageIsReady(false); + setLanguageApp(lang); + if (isAuth) { + changeUserLanguage(lang); + } + }; - return { languageApp, changeLanguage, languageIsReady, languageList }; + return {languageApp, changeLanguage, languageIsReady, languageList}; }; export default useLanguage; diff --git a/src/lib/app/hooks/useLoading.jsx b/src/lib/app/hooks/useLoading.jsx index d74a87e..a691bd7 100644 --- a/src/lib/app/hooks/useLoading.jsx +++ b/src/lib/app/hooks/useLoading.jsx @@ -1,10 +1,10 @@ -import { useContext } from "react"; -import { LoadingContext } from "../contexts/loading"; +import {useContext} from "react"; +import {LoadingContext} from "../contexts/loading"; const useLoading = () => { - const { setLoadingPage } = useContext(LoadingContext); + const {setLoadingPage} = useContext(LoadingContext); - return { setLoadingPage }; + return {setLoadingPage}; }; export default useLoading; diff --git a/src/lib/app/hooks/useUser.jsx b/src/lib/app/hooks/useUser.jsx index baa0aaa..21ccbdb 100644 --- a/src/lib/app/hooks/useUser.jsx +++ b/src/lib/app/hooks/useUser.jsx @@ -1,36 +1,36 @@ -import { useContext } from "react"; -import { UserContext } from "../contexts/user"; +import {useContext} from "react"; +import {UserContext} from "../contexts/user"; const useUser = () => { - const { - isAuth, - userChangedLanguage, - token, - user, - getUser, - clearUser, - changeUser, - changeUserLanguage, - changeAuthState, - changeLanguageState, - clearToken, - setToken, - } = useContext(UserContext); + const { + isAuth, + userChangedLanguage, + token, + user, + getUser, + clearUser, + changeUser, + changeUserLanguage, + changeAuthState, + changeLanguageState, + clearToken, + setToken, + } = useContext(UserContext); - return { - isAuth, - userChangedLanguage, - token, - user, - getUser, - clearUser, - changeUser, - changeUserLanguage, - changeAuthState, - changeLanguageState, - clearToken, - setToken, - }; + return { + isAuth, + userChangedLanguage, + token, + user, + getUser, + clearUser, + changeUser, + changeUserLanguage, + changeAuthState, + changeLanguageState, + clearToken, + setToken, + }; }; export default useUser; diff --git a/src/middlewares/WithAuth.jsx b/src/middlewares/WithAuth.jsx index 5ce8831..d8a6bba 100644 --- a/src/middlewares/WithAuth.jsx +++ b/src/middlewares/WithAuth.jsx @@ -1,41 +1,41 @@ -import { NextLinkComposed } from "@/core/components/LinkRouting"; +import {NextLinkComposed} from "@/core/components/LinkRouting"; import Message from "@/core/components/Messages"; import useUser from "@/lib/app/hooks/useUser"; -import { Button, Typography } from "@mui/material"; -import { useTranslations } from "next-intl"; -import { useRouter } from "next/router"; +import {Button, Typography} from "@mui/material"; +import {useTranslations} from "next-intl"; +import {useRouter} from "next/router"; -const WithAuthMiddleware = ({ children }) => { - const { isAuth } = useUser(); - const t = useTranslations(); - const router = useRouter(); +const WithAuthMiddleware = ({children}) => { + const {isAuth} = useUser(); + const t = useTranslations(); + const router = useRouter(); - if (!isAuth) - return ( - - {t( - "Authorization.typography_your_access_to_this_page_has_expired_Please_login_again" - )} - - } - actions={ - <> - - - } - /> - ); - return <>{children}; + if (!isAuth) + return ( + + {t( + "Authorization.typography_your_access_to_this_page_has_expired_Please_login_again" + )} + + } + actions={ + <> + + + } + /> + ); + return <>{children}; }; export default WithAuthMiddleware; diff --git a/src/middlewares/WithoutAuth.jsx b/src/middlewares/WithoutAuth.jsx index cb8e571..594ffc5 100644 --- a/src/middlewares/WithoutAuth.jsx +++ b/src/middlewares/WithoutAuth.jsx @@ -1,56 +1,56 @@ import Message from "@/core/components/Messages"; import useUser from "@/lib/app/hooks/useUser"; -import { Stack, Typography } from "@mui/material"; -import { useTranslations } from "next-intl"; -import { useSearchParams } from "next/navigation"; -import { useRouter } from "next/router"; -import { useEffect } from "react"; +import {Stack, Typography} from "@mui/material"; +import {useTranslations} from "next-intl"; +import {useSearchParams} from "next/navigation"; +import {useRouter} from "next/router"; +import {useEffect} from "react"; -const WithoutAuthMiddleware = ({ children }) => { - const { isAuth } = useUser(); - const t = useTranslations(); - const router = useRouter(); +const WithoutAuthMiddleware = ({children}) => { + const {isAuth} = useUser(); + const t = useTranslations(); + const router = useRouter(); - // gettin url query - const searchParams = useSearchParams(); - const backUrlDecodedPath = searchParams.get("back_url"); + // gettin url query + const searchParams = useSearchParams(); + const backUrlDecodedPath = searchParams.get("back_url"); - useEffect(() => { - if (!isAuth) return; - const timer = setTimeout(() => { - router.replace( - backUrlDecodedPath - ? decodeURIComponent(backUrlDecodedPath) - : "/dashboard" - ); - }, 2000); + useEffect(() => { + if (!isAuth) return; + const timer = setTimeout(() => { + router.replace( + backUrlDecodedPath + ? decodeURIComponent(backUrlDecodedPath) + : "/dashboard" + ); + }, 2000); - return () => { - clearTimeout(timer); - }; - }, [isAuth]); + return () => { + clearTimeout(timer); + }; + }, [isAuth]); - if (isAuth) - return ( - - - {t( - "Authorization.typography_your_login_is_valid_and_you_do_not_need_to_login_again" - )} - - - {t("Authorization.typography_redirect_to")}{" "} - {backUrlDecodedPath - ? t("Authorization.typography_routing_previuos_page") - : t("Authorization.typography_routing_dashbaord_page")} - - - } - /> - ); - return <>{children}; + if (isAuth) + return ( + + + {t( + "Authorization.typography_your_login_is_valid_and_you_do_not_need_to_login_again" + )} + + + {t("Authorization.typography_redirect_to")}{" "} + {backUrlDecodedPath + ? t("Authorization.typography_routing_previuos_page") + : t("Authorization.typography_routing_dashbaord_page")} + + + } + /> + ); + return <>{children}; }; export default WithoutAuthMiddleware; diff --git a/src/pages/404.jsx b/src/pages/404.jsx index 9b75470..af810b6 100644 --- a/src/pages/404.jsx +++ b/src/pages/404.jsx @@ -2,12 +2,12 @@ import NotFoundComponent from "@/components/not-found"; import Head from "next/head"; export default function NotFound() { - return ( - <> - - یافت نشد - - - - ); + return ( + <> + + یافت نشد + + + + ); } diff --git a/src/pages/_app.jsx b/src/pages/_app.jsx index be5d828..573bef2 100644 --- a/src/pages/_app.jsx +++ b/src/pages/_app.jsx @@ -1,30 +1,30 @@ import "&/fontiran.scss"; import AppLayout from "@/layouts/AppLayout"; import MuiLayout from "@/layouts/MuiLayout"; -import { LanguageProvider } from "@/lib/app/contexts/language"; -import { LoadingProvider } from "@/lib/app/contexts/loading"; -import { UserProvider } from "@/lib/app/contexts/user"; +import {LanguageProvider} from "@/lib/app/contexts/language"; +import {LoadingProvider} from "@/lib/app/contexts/loading"; +import {UserProvider} from "@/lib/app/contexts/user"; import "moment/locale/fa"; -import { NextIntlProvider } from "next-intl"; +import {NextIntlProvider} from "next-intl"; -const App = ({ Component, pageProps }) => { - return ( - <> - - - - - - - - - - - - - - - ); +const App = ({Component, pageProps}) => { + return ( + <> + + + + + + + + + + + + + + + ); }; export default App; diff --git a/src/pages/_document.jsx b/src/pages/_document.jsx index e763884..f71303f 100644 --- a/src/pages/_document.jsx +++ b/src/pages/_document.jsx @@ -1,67 +1,65 @@ -import { - createEmotionCacheLtr -} from "@/core/utils/createEmotionCache"; +import {createEmotionCacheLtr} from "@/core/utils/createEmotionCache"; import theme from "@/core/utils/theme"; import createEmotionServer from "@emotion/server/create-instance"; -import Document, { Head, Html, Main, NextScript } from "next/document"; +import Document, {Head, Html, Main, NextScript} from "next/document"; export default function MyDocument(props) { - const { emotionStyleTags } = props; + const {emotionStyleTags} = props; - return ( - - - - - - - - {emotionStyleTags} - - -
- - - - ); + return ( + + + + + + + + {emotionStyleTags} + + +
+ + + + ); } MyDocument.getInitialProps = async (ctx) => { - const originalRenderPage = ctx.renderPage; - let cache; - switch (ctx.locale) { - case "fa": - cache = createEmotionCacheLtr(); - break; - } + const originalRenderPage = ctx.renderPage; + let cache; + switch (ctx.locale) { + case "fa": + cache = createEmotionCacheLtr(); + break; + } - const { extractCriticalToChunks } = createEmotionServer(cache); + const {extractCriticalToChunks} = createEmotionServer(cache); - ctx.renderPage = () => - originalRenderPage({ - enhanceApp: (App) => - function EnhanceApp(props) { - return ; - }, - }); + ctx.renderPage = () => + originalRenderPage({ + enhanceApp: (App) => + function EnhanceApp(props) { + return ; + }, + }); - const initialProps = await Document.getInitialProps(ctx); + const initialProps = await Document.getInitialProps(ctx); - const emotionStyles = extractCriticalToChunks(initialProps.html); - const emotionStyleTags = emotionStyles.styles.map((style) => ( -