Merge branch 'develop' of https://gitlab.com/witel-front-end/loan-facilities/user into develop
This commit is contained in:
@@ -45,7 +45,7 @@
|
|||||||
"button_back_dashboard": "بازگشت به صفحه اصلی"
|
"button_back_dashboard": "بازگشت به صفحه اصلی"
|
||||||
},
|
},
|
||||||
"Titles": {
|
"Titles": {
|
||||||
"title_login_page": "صفحه ورود",
|
"title_login_page": "ورود به سامانه",
|
||||||
"title_register_page": "صفحه ثبت نام",
|
"title_register_page": "صفحه ثبت نام",
|
||||||
"title_login_navy_page": "ورود اعضای ناوگان",
|
"title_login_navy_page": "ورود اعضای ناوگان",
|
||||||
"title_login_welfare_services_page": "ورود اعضای خدمات رفاهی",
|
"title_login_welfare_services_page": "ورود اعضای خدمات رفاهی",
|
||||||
@@ -124,7 +124,12 @@
|
|||||||
"loan_request_correction": "اصلاح درخواست",
|
"loan_request_correction": "اصلاح درخواست",
|
||||||
"loan_request_detail": "مشاهده جزئیات",
|
"loan_request_detail": "مشاهده جزئیات",
|
||||||
"request_number": "درخواست شماره",
|
"request_number": "درخواست شماره",
|
||||||
"no_request_found": "درخواستی یافت نشد"
|
"no_request_found": "درخواستی یافت نشد",
|
||||||
|
"loan_unique_code": "کد یکتا",
|
||||||
|
"loan_date": "تاریخ درخواست",
|
||||||
|
"loan_status": "وضعیت",
|
||||||
|
"loan_bank_branch": "اطلاعات شعبه",
|
||||||
|
"loan_details": "نمایش"
|
||||||
},
|
},
|
||||||
"LoanRequest": {
|
"LoanRequest": {
|
||||||
"loan_request_page": "ثبت درخواست وام",
|
"loan_request_page": "ثبت درخواست وام",
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
import DashboardLayouts from "@/layouts/dashboardLayouts";
|
|
||||||
import {
|
import {
|
||||||
Grid,
|
Grid,
|
||||||
Stack,
|
Stack,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import {useEffect, useState} from "react";
|
import {useEffect, useState} from "react";
|
||||||
import {SHOW_LOAN_REQUEST_NAVGAN} from "@/core/data/apiRoutes";
|
import {SHOW_LOAN_REQUEST_NAVGAN} from "@/core/data/apiRoutes";
|
||||||
import useLoading from "@/lib/app/hooks/useLoading";
|
|
||||||
import useRequest from "@/lib/app/hooks/useRequest";
|
|
||||||
import moment from "jalali-moment";
|
import moment from "jalali-moment";
|
||||||
import RequestCard from "@/components/dashboard/navgan/followUp-loan/RequestCard";
|
import RequestCard from "@/components/dashboard/navgan/followUp-loan/RequestCard";
|
||||||
|
import {useLoading, useRequest} from "@witel/webapp-builder";
|
||||||
|
|
||||||
const LoanFollowUpComponent = () => {
|
const LoanFollowUpComponent = () => {
|
||||||
const requestServer = useRequest();
|
const requestServer = useRequest();
|
||||||
@@ -34,7 +32,6 @@ const LoanFollowUpComponent = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardLayouts>
|
|
||||||
<Stack
|
<Stack
|
||||||
spacing={2}
|
spacing={2}
|
||||||
sx={{
|
sx={{
|
||||||
@@ -53,7 +50,6 @@ const LoanFollowUpComponent = () => {
|
|||||||
))}
|
))}
|
||||||
</Grid>
|
</Grid>
|
||||||
</Stack>
|
</Stack>
|
||||||
</DashboardLayouts>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -30,18 +30,6 @@ const LoanRegister = () => {
|
|||||||
padding: 1
|
padding: 1
|
||||||
}}>
|
}}>
|
||||||
<LinkRouting underline="none" color="inherit" href={'/login'}>
|
<LinkRouting underline="none" color="inherit" href={'/login'}>
|
||||||
<Typography variant="h6">
|
|
||||||
{t("firstPage.login_button")}
|
|
||||||
</Typography>
|
|
||||||
</LinkRouting>
|
|
||||||
</Container>
|
|
||||||
<Container maxWidth={'xs'} sx={{
|
|
||||||
backgroundColor: "primary.main",
|
|
||||||
textAlign: "center",
|
|
||||||
borderRadius: 2,
|
|
||||||
padding: 1
|
|
||||||
}}>
|
|
||||||
<LinkRouting underline="none" color="inherit" href={'/register'}>
|
|
||||||
<Typography variant="h6">
|
<Typography variant="h6">
|
||||||
{t("firstPage.register_button")}
|
{t("firstPage.register_button")}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import ResendToken from "@/core/components/ResendToken";
|
import ResendToken from "@/core/components/ResendToken";
|
||||||
import StyledForm from "@/core/components/StyledForm";
|
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 useUser from "@/lib/app/hooks/useUser";
|
|
||||||
import ChangeCircleIcon from "@mui/icons-material/ChangeCircle";
|
import ChangeCircleIcon from "@mui/icons-material/ChangeCircle";
|
||||||
import LoginIcon from "@mui/icons-material/Login";
|
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";
|
||||||
@@ -11,8 +8,8 @@ import {Field, Formik} from "formik";
|
|||||||
import {useTranslations} from "next-intl";
|
import {useTranslations} from "next-intl";
|
||||||
import * as Yup from "yup";
|
import * as Yup from "yup";
|
||||||
import SvgLogin from "@/core/components/svgs/SvgLogin";
|
import SvgLogin from "@/core/components/svgs/SvgLogin";
|
||||||
import useRequest from "@/lib/app/hooks/useRequest";
|
|
||||||
import AutoSubmit from "@/core/components/AutoSubmit";
|
import AutoSubmit from "@/core/components/AutoSubmit";
|
||||||
|
import {CenterLayout, FullPageLayout, useRequest, useUser} from "@witel/webapp-builder";
|
||||||
|
|
||||||
const SendTokenComponent = ({
|
const SendTokenComponent = ({
|
||||||
PhoneNumber,
|
PhoneNumber,
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
import LinkRouting from "@/core/components/LinkRouting";
|
|
||||||
import StyledForm from "@/core/components/StyledForm";
|
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 FingerprintIcon from "@mui/icons-material/Fingerprint";
|
import FingerprintIcon from "@mui/icons-material/Fingerprint";
|
||||||
import PersonAddIcon from "@mui/icons-material/PersonAdd";
|
import PersonAddIcon from "@mui/icons-material/PersonAdd";
|
||||||
import {Button, Container, Grid, Paper, Stack, TextField, Typography,} from "@mui/material";
|
import {Button, Container, Grid, Paper, Stack, TextField, Typography,} from "@mui/material";
|
||||||
@@ -11,7 +8,8 @@ import {useTranslations} from "next-intl";
|
|||||||
import {useSearchParams} from "next/navigation";
|
import {useSearchParams} from "next/navigation";
|
||||||
import * as Yup from "yup";
|
import * as Yup from "yup";
|
||||||
import SvgLogin from "@/core/components/svgs/SvgLogin";
|
import SvgLogin from "@/core/components/svgs/SvgLogin";
|
||||||
import useRequest from "@/lib/app/hooks/useRequest";
|
import {CenterLayout, FullPageLayout, LinkRouting, useRequest} from "@witel/webapp-builder";
|
||||||
|
|
||||||
|
|
||||||
const SendUserDataComponent = ({
|
const SendUserDataComponent = ({
|
||||||
setOtpToken,
|
setOtpToken,
|
||||||
@@ -97,21 +95,6 @@ const SendUserDataComponent = ({
|
|||||||
flexDirection: {xs: "column-reverse", sm: "row"},
|
flexDirection: {xs: "column-reverse", sm: "row"},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Grid item xs={12} sm={6} sx={{pr: {xs: 0, sm: 1}}}>
|
|
||||||
<LinkRouting href={"/register"}>
|
|
||||||
<Button
|
|
||||||
fullWidth
|
|
||||||
type="button"
|
|
||||||
variant="outlined"
|
|
||||||
size="large"
|
|
||||||
endIcon={<PersonAddIcon/>}
|
|
||||||
disabled={props.isSubmitting}
|
|
||||||
>
|
|
||||||
{t("LoginPage.button_make_account")}
|
|
||||||
</Button>
|
|
||||||
</LinkRouting>
|
|
||||||
</Grid>
|
|
||||||
<Grid item xs={12} sm={6} sx={{pl: {xs: 0, sm: 1}}}>
|
|
||||||
<Button
|
<Button
|
||||||
fullWidth
|
fullWidth
|
||||||
type="submit"
|
type="submit"
|
||||||
@@ -122,7 +105,6 @@ const SendUserDataComponent = ({
|
|||||||
>
|
>
|
||||||
{t("LoginPage.button_request_verification")}
|
{t("LoginPage.button_request_verification")}
|
||||||
</Button>
|
</Button>
|
||||||
</Grid>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Stack>
|
</Stack>
|
||||||
</StyledForm>
|
</StyledForm>
|
||||||
|
|||||||
@@ -1,131 +0,0 @@
|
|||||||
import LinkRouting from "@/core/components/LinkRouting";
|
|
||||||
import StyledForm from "@/core/components/StyledForm";
|
|
||||||
import {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 {Button, Container, Paper, Stack, TextField, Typography,} from "@mui/material";
|
|
||||||
import {Field, Formik} from "formik";
|
|
||||||
import {useTranslations} from "next-intl";
|
|
||||||
import {useSearchParams} from "next/navigation";
|
|
||||||
import * as Yup from "yup";
|
|
||||||
import SvgLogin from "@/core/components/svgs/SvgLogin";
|
|
||||||
import useRequest from "@/lib/app/hooks/useRequest";
|
|
||||||
|
|
||||||
const RequestOtpComponent = ({
|
|
||||||
setOtpToken,
|
|
||||||
setPhoneNumber,
|
|
||||||
PhoneNumber,
|
|
||||||
setTimer,
|
|
||||||
initialTimerValue,
|
|
||||||
}) => {
|
|
||||||
const t = useTranslations();
|
|
||||||
const requestServer = useRequest();
|
|
||||||
|
|
||||||
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_phone_number")
|
|
||||||
),
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleSubmit = (values, props) => {
|
|
||||||
requestServer(SEND_OTP_TOKEN, "post", {
|
|
||||||
auth: false, data: {
|
|
||||||
phone_number: values.phone_number,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.then(function (response) {
|
|
||||||
setPhoneNumber(values.phone_number);
|
|
||||||
setOtpToken(true);
|
|
||||||
setTimer(initialTimerValue);
|
|
||||||
}).catch(function (error) {
|
|
||||||
props.setSubmitting(false);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FullPageLayout sx={{p: 1}}>
|
|
||||||
<CenterLayout>
|
|
||||||
<Container maxWidth="sm">
|
|
||||||
<Paper elevation={0}>
|
|
||||||
<Formik
|
|
||||||
initialValues={initialValues}
|
|
||||||
onSubmit={handleSubmit}
|
|
||||||
validationSchema={validationSchema}
|
|
||||||
>
|
|
||||||
{(props) => (
|
|
||||||
<Stack spacing={2} sx={{p: 2}}>
|
|
||||||
<Stack
|
|
||||||
sx={{width: "100%"}}
|
|
||||||
alignItems='center'
|
|
||||||
>
|
|
||||||
<SvgLogin width={300} height={200}/>
|
|
||||||
</Stack>
|
|
||||||
<Typography margin={2} variant="h4" textAlign="center">
|
|
||||||
{t("Titles.title_register_page")}
|
|
||||||
</Typography>
|
|
||||||
<StyledForm sx={{width: "100%"}}>
|
|
||||||
<Stack spacing={3} sx={{p: 2}}>
|
|
||||||
<Field
|
|
||||||
as={TextField}
|
|
||||||
name="phone_number"
|
|
||||||
variant="outlined"
|
|
||||||
label={t("RegisterPage.text_field_phone_number")}
|
|
||||||
placeholder={t(
|
|
||||||
"RegisterPage.text_field_enter_your_phone_number"
|
|
||||||
)}
|
|
||||||
type={"text"}
|
|
||||||
error={
|
|
||||||
!!(props.touched.phone_number && props.errors.phone_number)
|
|
||||||
}
|
|
||||||
fullWidth
|
|
||||||
helperText={
|
|
||||||
props.touched.phone_number
|
|
||||||
? props.errors.phone_number
|
|
||||||
: null
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
fullWidth
|
|
||||||
type="submit"
|
|
||||||
variant="contained"
|
|
||||||
size="large"
|
|
||||||
endIcon={<FingerprintIcon/>}
|
|
||||||
disabled={props.isSubmitting}
|
|
||||||
>
|
|
||||||
{t("RegisterPage.button_request_verification")}
|
|
||||||
</Button>
|
|
||||||
</Stack>
|
|
||||||
</StyledForm>
|
|
||||||
</Stack>
|
|
||||||
)}
|
|
||||||
</Formik>
|
|
||||||
</Paper>
|
|
||||||
</Container>
|
|
||||||
</CenterLayout>
|
|
||||||
<Stack direction="row" alignItems="center" justifyContent="center">
|
|
||||||
<LinkRouting
|
|
||||||
sx={{margin: 2}}
|
|
||||||
href={
|
|
||||||
backUrlDecodedPath
|
|
||||||
? decodeURIComponent(backUrlDecodedPath)
|
|
||||||
: "/register"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{t("RegisterPage.link_routing_back_to")}{" "}
|
|
||||||
{backUrlDecodedPath
|
|
||||||
? t("RegisterPage.link_routing_previuos_page")
|
|
||||||
: t("RegisterPage.link_routing_register")}
|
|
||||||
</LinkRouting>
|
|
||||||
</Stack>
|
|
||||||
</FullPageLayout>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default RequestOtpComponent;
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
import LinkRouting, {NextLinkComposed} from "@/core/components/LinkRouting";
|
|
||||||
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 SvgDashboard from "@/core/components/svgs/SvgDashboard";
|
|
||||||
|
|
||||||
const RegisterComponent = () => {
|
|
||||||
const t = useTranslations();
|
|
||||||
const {isAuth} = useUser();
|
|
||||||
|
|
||||||
const searchParams = useSearchParams();
|
|
||||||
const backUrlDecodedPath = searchParams.get("back_url");
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FullPageLayout sx={{p: 1}}>
|
|
||||||
<CenterLayout spacing={3}>
|
|
||||||
<SvgDashboard width={300} height={200}/>
|
|
||||||
{isAuth ? (
|
|
||||||
<Button
|
|
||||||
variant="contained"
|
|
||||||
component={NextLinkComposed}
|
|
||||||
to={{
|
|
||||||
pathname: "/dashboard",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{t("dashboard")}
|
|
||||||
</Button>
|
|
||||||
) : (
|
|
||||||
<Box>
|
|
||||||
<Grid
|
|
||||||
container
|
|
||||||
rowSpacing={{xs: 1, sm: 0}}
|
|
||||||
sx={{
|
|
||||||
flexDirection: {xs: "column", sm: "row"},
|
|
||||||
alignItems: "center",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Grid item xs={12} sm={6} sx={{px: {xs: 0, sm: 1}}}>
|
|
||||||
<Button
|
|
||||||
sx={{whiteSpace: "nowrap"}}
|
|
||||||
variant="contained"
|
|
||||||
size="large"
|
|
||||||
component={NextLinkComposed}
|
|
||||||
to={{
|
|
||||||
pathname: "register/navy",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{t("register_navy")}
|
|
||||||
</Button>
|
|
||||||
</Grid>
|
|
||||||
{/*<Grid item xs={12} sm={6} sx={{px: {xs: 0, sm: 1}}}>*/}
|
|
||||||
{/* <Button*/}
|
|
||||||
{/* sx={{whiteSpace: "nowrap"}}*/}
|
|
||||||
{/* variant="contained"*/}
|
|
||||||
{/* size="large"*/}
|
|
||||||
{/* component={NextLinkComposed}*/}
|
|
||||||
{/* to={{*/}
|
|
||||||
{/* pathname: "register/welfare-services",*/}
|
|
||||||
{/* }}*/}
|
|
||||||
{/* >*/}
|
|
||||||
{/* {t("register_welfare_services")}*/}
|
|
||||||
{/* </Button>*/}
|
|
||||||
{/*</Grid>*/}
|
|
||||||
</Grid>
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</CenterLayout>
|
|
||||||
<Stack direction="row" alignItems="center" justifyContent="center">
|
|
||||||
<LinkRouting
|
|
||||||
sx={{margin: 2}}
|
|
||||||
href={
|
|
||||||
backUrlDecodedPath
|
|
||||||
? decodeURIComponent(backUrlDecodedPath)
|
|
||||||
: "/"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{t("RegisterPage.link_routing_back_to")}{" "}
|
|
||||||
{backUrlDecodedPath
|
|
||||||
? t("RegisterPage.link_routing_previuos_page")
|
|
||||||
: t("LoginPage.link_routing_main_page")}
|
|
||||||
</LinkRouting>
|
|
||||||
</Stack>
|
|
||||||
</FullPageLayout>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default RegisterComponent;
|
|
||||||
@@ -1,176 +0,0 @@
|
|||||||
import StyledForm from "@/core/components/StyledForm";
|
|
||||||
import {REGISTER} from "@/core/data/apiRoutes";
|
|
||||||
import CenterLayout from "@/layouts/CenterLayout";
|
|
||||||
import FullPageLayout from "@/layouts/FullPageLayout";
|
|
||||||
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 {Field, Formik} from "formik";
|
|
||||||
import {useTranslations} from "next-intl";
|
|
||||||
import * as Yup from "yup";
|
|
||||||
import ResendToken from "@/core/components/ResendToken";
|
|
||||||
import useUser from "@/lib/app/hooks/useUser";
|
|
||||||
import SvgRegister from "@/core/components/svgs/SvgRegister";
|
|
||||||
import useRequest from "@/lib/app/hooks/useRequest";
|
|
||||||
import AutoSubmit from "@/core/components/AutoSubmit";
|
|
||||||
|
|
||||||
const UserRegisterComponent = ({
|
|
||||||
PhoneNumber,
|
|
||||||
setOtpToken,
|
|
||||||
initialTimerValue,
|
|
||||||
timer,
|
|
||||||
setTimer,
|
|
||||||
}) => {
|
|
||||||
const t = useTranslations();
|
|
||||||
const {setToken} = useUser();
|
|
||||||
const requestServer = useRequest();
|
|
||||||
|
|
||||||
const initialValues = {
|
|
||||||
type_id: "1",
|
|
||||||
verification_code: "",
|
|
||||||
phone_number: PhoneNumber,
|
|
||||||
national_id: "",
|
|
||||||
};
|
|
||||||
|
|
||||||
const validationSchema = Yup.object().shape({
|
|
||||||
verification_code: Yup.string().required(
|
|
||||||
t("RegisterPage.error_message_verification_code")
|
|
||||||
),
|
|
||||||
national_id: Yup.string().required(
|
|
||||||
t("RegisterPage.error_message_national_id")
|
|
||||||
),
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleSubmit = (values, props) => {
|
|
||||||
requestServer(REGISTER, "post", {
|
|
||||||
auth: false, data: {
|
|
||||||
type_id: values.type_id,
|
|
||||||
national_id: values.national_id,
|
|
||||||
phone_number: values.phone_number,
|
|
||||||
verification_code: values.verification_code,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.then(function (response) {
|
|
||||||
setOtpToken(true);
|
|
||||||
setToken(response.data.token);
|
|
||||||
}).catch(function (error) {
|
|
||||||
props.setSubmitting(false);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FullPageLayout sx={{p: 1}}>
|
|
||||||
<CenterLayout>
|
|
||||||
<Container maxWidth="sm">
|
|
||||||
<Paper elevation={0}>
|
|
||||||
<Formik
|
|
||||||
initialValues={initialValues}
|
|
||||||
onSubmit={handleSubmit}
|
|
||||||
validationSchema={validationSchema}
|
|
||||||
>
|
|
||||||
{(props) => (
|
|
||||||
<Stack spacing={2} sx={{p: 2}}>
|
|
||||||
<Stack
|
|
||||||
sx={{width: "100%"}}
|
|
||||||
alignItems='center'
|
|
||||||
>
|
|
||||||
<SvgRegister width={300} height={200}/>
|
|
||||||
</Stack>
|
|
||||||
<Typography margin={2} variant="h4" textAlign="center">
|
|
||||||
{t("register_navy")}
|
|
||||||
</Typography>
|
|
||||||
<StyledForm sx={{width: "100%"}}>
|
|
||||||
<Stack spacing={3} sx={{p: 2}}>
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
display: {xs: "column", sm: "flex"},
|
|
||||||
alignItems: "center",
|
|
||||||
textAlign: {xs: "center", sm: "unset"},
|
|
||||||
justifyContent: "space-between",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography variant="button" sx={{display: "block"}}>
|
|
||||||
{t("LoginPage.sent_token_to")}: {PhoneNumber}
|
|
||||||
</Typography>
|
|
||||||
<Button
|
|
||||||
size="small"
|
|
||||||
startIcon={<ChangeCircleIcon/>}
|
|
||||||
variant="outlined"
|
|
||||||
sx={{whiteSpace: "nowrap", my: {xs: 1, sm: 0}}}
|
|
||||||
onClick={() => setOtpToken(false)}
|
|
||||||
>
|
|
||||||
{t("LoginPage.change_phone_number")}
|
|
||||||
</Button>
|
|
||||||
</Box>
|
|
||||||
<Field
|
|
||||||
as={TextField}
|
|
||||||
name="verification_code"
|
|
||||||
variant="outlined"
|
|
||||||
label={t("LoginPage.text_field_verification_code")}
|
|
||||||
placeholder={t(
|
|
||||||
"LoginPage.text_field_enter_your_verification_code"
|
|
||||||
)}
|
|
||||||
type={"number"}
|
|
||||||
error={
|
|
||||||
!!(props.touched.verification_code && props.errors.verification_code)
|
|
||||||
}
|
|
||||||
fullWidth
|
|
||||||
helperText={
|
|
||||||
props.touched.verification_code
|
|
||||||
? props.errors.verification_code
|
|
||||||
: null
|
|
||||||
}
|
|
||||||
onChange={(e) => e.target.value.length <= 6 ? props.setFieldValue("verification_code", e.target.value) : ""}
|
|
||||||
/>
|
|
||||||
<AutoSubmit/>
|
|
||||||
<ResendToken
|
|
||||||
initialTimerValue={initialTimerValue}
|
|
||||||
timer={timer}
|
|
||||||
setTimer={setTimer}
|
|
||||||
PhoneNumber={PhoneNumber}
|
|
||||||
/>
|
|
||||||
<Divider>
|
|
||||||
<Chip label={t("RegisterPage.complete_information")}/>
|
|
||||||
</Divider>
|
|
||||||
<Field
|
|
||||||
as={TextField}
|
|
||||||
name="national_id"
|
|
||||||
variant="outlined"
|
|
||||||
label={t("RegisterPage.text_field_national_id")}
|
|
||||||
placeholder={t(
|
|
||||||
"RegisterPage.text_field_enter_your_national_id"
|
|
||||||
)}
|
|
||||||
type={"text"}
|
|
||||||
error={
|
|
||||||
!!(props.touched.national_id && props.errors.national_id)
|
|
||||||
}
|
|
||||||
fullWidth
|
|
||||||
helperText={
|
|
||||||
props.touched.national_id
|
|
||||||
? props.errors.national_id
|
|
||||||
: null
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
fullWidth
|
|
||||||
type="submit"
|
|
||||||
variant="contained"
|
|
||||||
size="large"
|
|
||||||
endIcon={<LoginIcon/>}
|
|
||||||
disabled={props.isSubmitting}
|
|
||||||
>
|
|
||||||
{t("RegisterPage.button_submit")}
|
|
||||||
</Button>
|
|
||||||
</Stack>
|
|
||||||
</StyledForm>
|
|
||||||
</Stack>
|
|
||||||
)}
|
|
||||||
</Formik>
|
|
||||||
</Paper>
|
|
||||||
</Container>
|
|
||||||
</CenterLayout>
|
|
||||||
</FullPageLayout>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default UserRegisterComponent;
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
import {useState} from "react";
|
|
||||||
import RequestOtpComponent from "../RequestOtp";
|
|
||||||
import UserRegisterComponent 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 (
|
|
||||||
<RequestOtpComponent
|
|
||||||
setOtpToken={setOtpToken}
|
|
||||||
PhoneNumber={PhoneNumber}
|
|
||||||
setPhoneNumber={setPhoneNumber}
|
|
||||||
setTimer={setTimer}
|
|
||||||
initialTimerValue={initialTimerValue}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<UserRegisterComponent
|
|
||||||
PhoneNumber={PhoneNumber}
|
|
||||||
setOtpToken={setOtpToken}
|
|
||||||
timer={timer}
|
|
||||||
setTimer={setTimer}
|
|
||||||
initialTimerValue={initialTimerValue}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default NavyComponent;
|
|
||||||
@@ -1,174 +0,0 @@
|
|||||||
import StyledForm from "@/core/components/StyledForm";
|
|
||||||
import {REGISTER} from "@/core/data/apiRoutes";
|
|
||||||
import CenterLayout from "@/layouts/CenterLayout";
|
|
||||||
import FullPageLayout from "@/layouts/FullPageLayout";
|
|
||||||
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 {Field, Formik} from "formik";
|
|
||||||
import {useTranslations} from "next-intl";
|
|
||||||
import * as Yup from "yup";
|
|
||||||
import ResendToken from "@/core/components/ResendToken";
|
|
||||||
import useUser from "@/lib/app/hooks/useUser";
|
|
||||||
import SvgRegister from "@/core/components/svgs/SvgRegister";
|
|
||||||
import useRequest from "@/lib/app/hooks/useRequest";
|
|
||||||
|
|
||||||
const UserRegisterComponent = ({
|
|
||||||
PhoneNumber,
|
|
||||||
setOtpToken,
|
|
||||||
initialTimerValue,
|
|
||||||
timer,
|
|
||||||
setTimer,
|
|
||||||
}) => {
|
|
||||||
const t = useTranslations();
|
|
||||||
const {setToken} = useUser();
|
|
||||||
const requestServer = useRequest();
|
|
||||||
|
|
||||||
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_verification_code")
|
|
||||||
),
|
|
||||||
national_id: Yup.string().required(
|
|
||||||
t("RegisterPage.error_message_national_id")
|
|
||||||
),
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleSubmit = (values, props) => {
|
|
||||||
requestServer(REGISTER, "post", {
|
|
||||||
auth: false, data: {
|
|
||||||
type_id: values.type_id,
|
|
||||||
national_id: values.national_id,
|
|
||||||
phone_number: values.phone_number,
|
|
||||||
verification_code: values.verification_code,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.then(function (response) {
|
|
||||||
setOtpToken(true);
|
|
||||||
setToken(response.data.token);
|
|
||||||
}).catch(function (error) {
|
|
||||||
props.setSubmitting(false);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FullPageLayout sx={{p: 1}}>
|
|
||||||
<CenterLayout>
|
|
||||||
<Container maxWidth="sm">
|
|
||||||
<Paper elevation={0}>
|
|
||||||
<Formik
|
|
||||||
initialValues={initialValues}
|
|
||||||
onSubmit={handleSubmit}
|
|
||||||
validationSchema={validationSchema}
|
|
||||||
>
|
|
||||||
{(props) => (
|
|
||||||
<Stack spacing={2} sx={{p: 2}}>
|
|
||||||
<Stack
|
|
||||||
sx={{width: "100%"}}
|
|
||||||
alignItems='center'
|
|
||||||
>
|
|
||||||
<SvgRegister width={300} height={200}/>
|
|
||||||
</Stack>
|
|
||||||
<Typography margin={2} variant="h4" textAlign="center">
|
|
||||||
{t("register_welfare_services")}
|
|
||||||
</Typography>
|
|
||||||
<StyledForm sx={{width: "100%"}}>
|
|
||||||
<Stack spacing={3} sx={{p: 2}}>
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
display: {xs: "column", sm: "flex"},
|
|
||||||
alignItems: "center",
|
|
||||||
textAlign: {xs: "center", sm: "unset"},
|
|
||||||
justifyContent: "space-between",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography variant="button" sx={{display: "block"}}>
|
|
||||||
{t("LoginPage.sent_token_to")}: {PhoneNumber}
|
|
||||||
</Typography>
|
|
||||||
<Button
|
|
||||||
size="small"
|
|
||||||
startIcon={<ChangeCircleIcon/>}
|
|
||||||
variant="outlined"
|
|
||||||
onClick={() => setOtpToken(false)}
|
|
||||||
sx={{whiteSpace: "nowrap", my: {xs: 1, sm: 0}}}
|
|
||||||
>
|
|
||||||
{t("LoginPage.change_phone_number")}
|
|
||||||
</Button>
|
|
||||||
</Box>
|
|
||||||
<Field
|
|
||||||
as={TextField}
|
|
||||||
name="verification_code"
|
|
||||||
variant="outlined"
|
|
||||||
label={t("LoginPage.text_field_verification_code")}
|
|
||||||
placeholder={t(
|
|
||||||
"LoginPage.text_field_enter_your_verification_code"
|
|
||||||
)}
|
|
||||||
type={"text"}
|
|
||||||
error={
|
|
||||||
!!(props.touched.verification_code && props.errors.verification_code)
|
|
||||||
}
|
|
||||||
fullWidth
|
|
||||||
helperText={
|
|
||||||
props.touched.verification_code
|
|
||||||
? props.errors.verification_code
|
|
||||||
: null
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<ResendToken
|
|
||||||
initialTimerValue={initialTimerValue}
|
|
||||||
timer={timer}
|
|
||||||
setTimer={setTimer}
|
|
||||||
PhoneNumber={PhoneNumber}
|
|
||||||
disabled={props.isSubmitting}
|
|
||||||
/>
|
|
||||||
<Divider>
|
|
||||||
<Chip label={t("RegisterPage.complete_information")}/>
|
|
||||||
</Divider>
|
|
||||||
<Field
|
|
||||||
as={TextField}
|
|
||||||
name="national_id"
|
|
||||||
variant="outlined"
|
|
||||||
label={t("RegisterPage.text_field_national_id")}
|
|
||||||
placeholder={t(
|
|
||||||
"RegisterPage.text_field_enter_your_national_id"
|
|
||||||
)}
|
|
||||||
type={"text"}
|
|
||||||
error={
|
|
||||||
!!(props.touched.national_id && props.errors.national_id)
|
|
||||||
}
|
|
||||||
fullWidth
|
|
||||||
helperText={
|
|
||||||
props.touched.national_id
|
|
||||||
? props.errors.national_id
|
|
||||||
: null
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
fullWidth
|
|
||||||
type="submit"
|
|
||||||
variant="contained"
|
|
||||||
size="large"
|
|
||||||
endIcon={<LoginIcon/>}
|
|
||||||
disabled={props.isSubmitting}
|
|
||||||
>
|
|
||||||
{t("RegisterPage.button_submit")}
|
|
||||||
</Button>
|
|
||||||
</Stack>
|
|
||||||
</StyledForm>
|
|
||||||
</Stack>
|
|
||||||
)}
|
|
||||||
</Formik>
|
|
||||||
</Paper>
|
|
||||||
</Container>
|
|
||||||
</CenterLayout>
|
|
||||||
</FullPageLayout>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default UserRegisterComponent;
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
import {useState} from "react";
|
|
||||||
import RequestOtpComponent from "../RequestOtp";
|
|
||||||
import UserRegisterComponent from "./UserRegister";
|
|
||||||
|
|
||||||
const WelfareServicesComponent = () => {
|
|
||||||
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 (
|
|
||||||
<RequestOtpComponent
|
|
||||||
setOtpToken={setOtpToken}
|
|
||||||
PhoneNumber={PhoneNumber}
|
|
||||||
setPhoneNumber={setPhoneNumber}
|
|
||||||
setTimer={setTimer}
|
|
||||||
initialTimerValue={initialTimerValue}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<UserRegisterComponent
|
|
||||||
PhoneNumber={PhoneNumber}
|
|
||||||
setOtpToken={setOtpToken}
|
|
||||||
timer={timer}
|
|
||||||
setTimer={setTimer}
|
|
||||||
initialTimerValue={initialTimerValue}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default WelfareServicesComponent;
|
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
import Notifications from "@/core/components/notifications";
|
|
||||||
import useDirection from "@/lib/app/hooks/useDirection";
|
|
||||||
import {Button} from "@mui/material";
|
import {Button} from "@mui/material";
|
||||||
import axios from "axios";
|
|
||||||
import {useTranslations} from "next-intl";
|
import {useTranslations} from "next-intl";
|
||||||
import {useEffect} from "react";
|
import {useEffect} from "react";
|
||||||
import {LOGIN, SEND_OTP_TOKEN} from "../data/apiRoutes";
|
import {LOGIN, SEND_OTP_TOKEN} from "../data/apiRoutes";
|
||||||
import useRequest from "@/lib/app/hooks/useRequest";
|
import {useDirection, useRequest} from "@witel/webapp-builder";
|
||||||
|
|
||||||
const ResendToken = ({initialTimerValue, timer, setTimer, PhoneNumber, disabled}) => {
|
const ResendToken = ({initialTimerValue, timer, setTimer, PhoneNumber, disabled}) => {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import {DashboardLayout as DashboardLayoutPure, useUser} from "@witel/webapp-bui
|
|||||||
import headerProfileItems from "@/core/data/headerProfileItems";
|
import headerProfileItems from "@/core/data/headerProfileItems";
|
||||||
import sidebarMenu from "@/core/data/sidebarMenu";
|
import sidebarMenu from "@/core/data/sidebarMenu";
|
||||||
import {GET_SIDEBAR_NOTIFICATION} from "@/core/data/apiRoutes";
|
import {GET_SIDEBAR_NOTIFICATION} from "@/core/data/apiRoutes";
|
||||||
|
import UserInfo from "@/middlewares/UserInfo";
|
||||||
import {useTranslations} from "next-intl";
|
import {useTranslations} from "next-intl";
|
||||||
import moment from "jalali-moment";
|
import moment from "jalali-moment";
|
||||||
|
|
||||||
@@ -12,14 +13,13 @@ const DashboardLayout = (props) => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DashboardLayoutPure
|
<DashboardLayoutPure
|
||||||
middlewares={{list: [], props: {...middlewaresProps}}}
|
middlewares={{list: [UserInfo], props: {...middlewaresProps,loginUrl:'/login'}}}
|
||||||
loginUrl={'/login'}
|
|
||||||
user_introduction={user.phone_number}
|
user_introduction={user.phone_number}
|
||||||
headerProfileItems={headerProfileItems}
|
headerProfileItems={headerProfileItems}
|
||||||
headerSubtitle={`${t('today')} ${moment().locale('fa').format('LL')}`}
|
headerSubtitle={`${t('today')} ${moment().locale('fa').format('LL')}`}
|
||||||
sidebarMenu={sidebarMenu}
|
sidebarMenu={sidebarMenu}
|
||||||
urlNotification={GET_SIDEBAR_NOTIFICATION}
|
urlNotification={GET_SIDEBAR_NOTIFICATION}
|
||||||
BC_segmentsToRemove={[]}
|
BC_segmentsToRemove={['navgan']}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
|||||||
9
src/middlewares/UserInfo.jsx
Normal file
9
src/middlewares/UserInfo.jsx
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import {useUser} from "@witel/webapp-builder";
|
||||||
|
|
||||||
|
const UserInfo = ({children}) => {
|
||||||
|
const {user} = useUser();
|
||||||
|
const userAccess = user.profile_completed;
|
||||||
|
return userAccess ? <>{children}</> : '';
|
||||||
|
};
|
||||||
|
|
||||||
|
export default UserInfo;
|
||||||
@@ -4,7 +4,7 @@ import {WithoutAuthMiddleware} from "@witel/webapp-builder";
|
|||||||
|
|
||||||
export default function Login() {
|
export default function Login() {
|
||||||
return (
|
return (
|
||||||
<WithoutAuthMiddleware defaultUrl={'/'}>
|
<WithoutAuthMiddleware defaultUrl={'/dashboard'}>
|
||||||
<LoginComponent/>
|
<LoginComponent/>
|
||||||
</WithoutAuthMiddleware>
|
</WithoutAuthMiddleware>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
import RegisterComponent from "@/components/register";
|
|
||||||
import {parse} from "next-useragent";
|
|
||||||
import {WithoutAuthMiddleware} from "@witel/webapp-builder";
|
|
||||||
|
|
||||||
export default function Register() {
|
|
||||||
return (
|
|
||||||
<WithoutAuthMiddleware defaultUrl={'/'}>
|
|
||||||
<RegisterComponent/>
|
|
||||||
</WithoutAuthMiddleware>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getServerSideProps({req, locale}) {
|
|
||||||
const {isBot} = parse(req.headers["user-agent"]);
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
messages: (await import(`&/locales/${locale}/app.json`)).default,
|
|
||||||
title: "Titles.title_register_page",
|
|
||||||
isBot,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
import NavyComponent from "@/components/register/navy";
|
|
||||||
import WithoutAuthMiddleware from "@/middlewares/WithoutAuth";
|
|
||||||
import {parse} from "next-useragent";
|
|
||||||
|
|
||||||
export default function Register() {
|
|
||||||
return (
|
|
||||||
<WithoutAuthMiddleware>
|
|
||||||
<NavyComponent/>
|
|
||||||
</WithoutAuthMiddleware>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getServerSideProps({req, locale}) {
|
|
||||||
const {isBot} = parse(req.headers["user-agent"]);
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
messages: (await import(`&/locales/${locale}/app.json`)).default,
|
|
||||||
title: "Titles.title_register_navy_page",
|
|
||||||
isBot,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import WithoutAuthMiddleware from "@/middlewares/WithoutAuth";
|
|
||||||
import {parse} from "next-useragent";
|
|
||||||
|
|
||||||
export default function Register() {
|
|
||||||
return (
|
|
||||||
<WithoutAuthMiddleware>
|
|
||||||
{/*<WelfareServicesComponent/>*/}
|
|
||||||
</WithoutAuthMiddleware>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getServerSideProps({req, locale}) {
|
|
||||||
const {isBot} = parse(req.headers["user-agent"]);
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
messages: (await import(`&/locales/${locale}/app.json`)).default,
|
|
||||||
title: "Titles.title_register_welfare_services_page",
|
|
||||||
isBot,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user