From 1c7ed780bfff9769a822265055c00b955b229852 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Mon, 10 Jul 2023 17:13:57 +0330 Subject: [PATCH] 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" ? : } );