split welfare and navy

This commit is contained in:
2023-07-15 17:07:56 +03:30
parent 0717e6c754
commit 8e277c33ca
3 changed files with 499 additions and 443 deletions

View File

@@ -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 (
<Formik
initialValues={initialValues}
// onSubmit={handleSubmit}
validationSchema={validationSchema}
>
{(props) => (
<Stack
spacing={2}
sx={{
p: 1,
width: "100%",
}}
>
<StyledForm sx={{ width: "100%" }}>
<Box
sx={{
display: "flex",
flexDirection: { xs: "column", sm: "row" },
alignItems: "start",
justifyContent: "center",
width: "100%",
}}
>
<Box
sx={{
mx: { xs: 0, sm: 2 },
my: 2,
width: "100%",
}}
>
<Field
as={TextField}
sx={{ width: "100%" }}
name="first_name"
variant="outlined"
size="small"
InputProps={{
readOnly: true,
}}
label={t("LoanRequest.text_field_first_name")}
placeholder={t(
"LoanRequest.text_field_enter_your_first_name"
)}
type={"text"}
error={
props.touched.first_name && props.errors.first_name
? true
: false
}
fullWidth
helperText={
props.touched.first_name ? props.errors.first_name : null
}
/>
</Box>
<Box
sx={{
mx: { xs: 0, sm: 2 },
my: 2,
width: "100%",
}}
>
<Field
as={TextField}
sx={{ width: "100%" }}
name="last_name"
variant="outlined"
size="small"
InputProps={{
readOnly: true,
}}
label={t("LoanRequest.text_field_last_name")}
placeholder={t("LoanRequest.text_field_enter_your_last_name")}
type={"text"}
error={
props.touched.last_name && props.errors.last_name
? true
: false
}
fullWidth
helperText={
props.touched.last_name ? props.errors.last_name : null
}
/>
</Box>
<Box
sx={{
mx: { xs: 0, sm: 2 },
my: 2,
width: "100%",
}}
>
<Field
as={TextField}
sx={{ width: "100%" }}
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"
)}
type={"text"}
error={
props.touched.phone_number && props.errors.phone_number
? true
: false
}
fullWidth
helperText={
props.touched.phone_number
? props.errors.phone_number
: null
}
/>
</Box>
</Box>
<Box
sx={{
display: "flex",
flexDirection: { xs: "column", sm: "row" },
alignItems: "start",
justifyContent: "center",
width: "100%",
}}
>
<Box
sx={{
mx: { xs: 0, sm: 2 },
my: 2,
width: "100%",
}}
>
<Field
as={TextField}
sx={{ width: "100%" }}
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"
)}
type={"text"}
error={
props.touched.vehicle_type && props.errors.vehicle_type
? true
: false
}
fullWidth
helperText={
props.touched.vehicle_type
? props.errors.vehicle_type
: null
}
/>
</Box>
<Box
sx={{
mx: { xs: 0, sm: 2 },
my: 2,
width: "100%",
}}
>
<Field
as={TextField}
sx={{ width: "100%" }}
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"
)}
type={"text"}
error={
props.touched.plate_number && props.errors.plate_number
? true
: false
}
fullWidth
helperText={
props.touched.plate_number
? props.errors.plate_number
: null
}
/>
</Box>
<Box
sx={{
mx: { xs: 0, sm: 2 },
my: 2,
width: "100%",
}}
>
<Field
as={TextField}
sx={{ width: "100%" }}
name="province"
variant="outlined"
size="small"
InputProps={{
readOnly: true,
}}
label={t("LoanRequest.text_field_province")}
placeholder={t("LoanRequest.text_field_enter_your_province")}
type={"text"}
error={
props.touched.province && props.errors.province
? true
: false
}
fullWidth
helperText={
props.touched.province ? props.errors.province : null
}
/>
</Box>
</Box>
<Box
sx={{
display: "flex",
flexDirection: { xs: "column", sm: "row" },
alignItems: "start",
justifyContent: "center",
width: "100%",
}}
>
<Box
sx={{
mx: { xs: 0, sm: 2 },
my: 2,
width: "100%",
}}
>
<Field
as={TextField}
sx={{ width: "100%" }}
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"}
error={
props.touched.navgan_id && props.errors.navgan_id
? true
: false
}
fullWidth
helperText={
props.touched.navgan_id ? props.errors.navgan_id : null
}
/>
</Box>
<Box
sx={{
mx: { xs: 0, sm: 2 },
my: 2,
width: "100%",
}}
>
<Field
as={TextField}
sx={{ width: "100%" }}
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"
)}
type={"text"}
error={
props.touched.national_code && props.errors.national_code
? true
: false
}
fullWidth
helperText={
props.touched.national_code
? props.errors.national_code
: null
}
/>
</Box>
<Box
sx={{
mx: { xs: 0, sm: 2 },
my: 2,
width: "100%",
}}
>
<Field
as={TextField}
sx={{ width: "100%" }}
name="birth_certificate_id"
variant="outlined"
size="small"
InputProps={{
readOnly: true,
}}
label={t("LoanRequest.text_field_birth_certificate_id")}
placeholder={t(
"LoanRequest.text_field_enter_your_birth_certificate_id"
)}
type={"text"}
error={
props.touched.birth_certificate_id &&
props.errors.birth_certificate_id
? true
: false
}
fullWidth
helperText={
props.touched.birth_certificate_id
? props.errors.birth_certificate_id
: null
}
/>
</Box>
</Box>
<Box
sx={{
display: "flex",
flexDirection: { xs: "column", sm: "row" },
alignItems: "center",
justifyContent: "space-around",
width: "100%",
}}
>
<Box>
<Image
width={300}
height={300}
src="/images/login.svg"
priority
alt={t("app_name")}
/>
</Box>
<Box>
<Image
width={300}
height={300}
src="/images/login.svg"
priority
alt={t("app_name")}
/>
</Box>
</Box>
<Box
sx={{
display: "flex",
flexDirection: { xs: "column", sm: "row" },
alignItems: "center",
mx: "auto",
width: { xs: "100%", sm: "30%", md: "25%" },
}}
>
<Button
fullWidth
type="submit"
variant="contained"
size="large"
endIcon={<DataSaverOnIcon />}
disabled={props.isSubmitting ? true : false}
>
{t("LoanRequest.button_submit")}
</Button>
</Box>
</StyledForm>
</Stack>
)}
</Formik>
);
};
export default NavyForm;

View File

@@ -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 (
<h4>ولفیر سرویس</h4>
);
};
export default WelfareServicesForm;

View File

@@ -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 (
<DashboardLayouts>
<CenterLayout>
<Formik
initialValues={initialValues}
// onSubmit={handleSubmit}
validationSchema={validationSchema}
>
{(props) => (
<Stack
spacing={2}
sx={{
p: 1,
width: "100%",
}}
>
<StyledForm sx={{ width: "100%" }}>
<Box
sx={{
display: "flex",
flexDirection: { xs: "column", sm: "row" },
alignItems: "start",
justifyContent: "center",
width: "100%",
}}
>
<Box
sx={{
mx: { xs: 0, sm: 2 },
my: 2,
width: "100%",
}}
>
<Field
as={TextField}
sx={{ width: "100%" }}
name="first_name"
variant="outlined"
size="small"
InputProps={{
readOnly: true,
}}
label={t("LoanRequest.text_field_first_name")}
placeholder={t(
"LoanRequest.text_field_enter_your_first_name"
)}
type={"text"}
error={
props.touched.first_name && props.errors.first_name
? true
: false
}
fullWidth
helperText={
props.touched.first_name
? props.errors.first_name
: null
}
/>
</Box>
<Box
sx={{
mx: { xs: 0, sm: 2 },
my: 2,
width: "100%",
}}
>
<Field
as={TextField}
sx={{ width: "100%" }}
name="last_name"
variant="outlined"
size="small"
InputProps={{
readOnly: true,
}}
label={t("LoanRequest.text_field_last_name")}
placeholder={t(
"LoanRequest.text_field_enter_your_last_name"
)}
type={"text"}
error={
props.touched.last_name && props.errors.last_name
? true
: false
}
fullWidth
helperText={
props.touched.last_name ? props.errors.last_name : null
}
/>
</Box>
<Box
sx={{
mx: { xs: 0, sm: 2 },
my: 2,
width: "100%",
}}
>
<Field
as={TextField}
sx={{ width: "100%" }}
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"
)}
type={"text"}
error={
props.touched.phone_number && props.errors.phone_number
? true
: false
}
fullWidth
helperText={
props.touched.phone_number
? props.errors.phone_number
: null
}
/>
</Box>
</Box>
<Box
sx={{
display: "flex",
flexDirection: { xs: "column", sm: "row" },
alignItems: "start",
justifyContent: "center",
width: "100%",
}}
>
<Box
sx={{
mx: { xs: 0, sm: 2 },
my: 2,
width: "100%",
}}
>
<Field
as={TextField}
sx={{ width: "100%" }}
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"
)}
type={"text"}
error={
props.touched.vehicle_type && props.errors.vehicle_type
? true
: false
}
fullWidth
helperText={
props.touched.vehicle_type
? props.errors.vehicle_type
: null
}
/>
</Box>
<Box
sx={{
mx: { xs: 0, sm: 2 },
my: 2,
width: "100%",
}}
>
<Field
as={TextField}
sx={{ width: "100%" }}
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"
)}
type={"text"}
error={
props.touched.plate_number && props.errors.plate_number
? true
: false
}
fullWidth
helperText={
props.touched.plate_number
? props.errors.plate_number
: null
}
/>
</Box>
<Box
sx={{
mx: { xs: 0, sm: 2 },
my: 2,
width: "100%",
}}
>
<Field
as={TextField}
sx={{ width: "100%" }}
name="province"
variant="outlined"
size="small"
InputProps={{
readOnly: true,
}}
label={t("LoanRequest.text_field_province")}
placeholder={t(
"LoanRequest.text_field_enter_your_province"
)}
type={"text"}
error={
props.touched.province && props.errors.province
? true
: false
}
fullWidth
helperText={
props.touched.province ? props.errors.province : null
}
/>
</Box>
</Box>
<Box
sx={{
display: "flex",
flexDirection: { xs: "column", sm: "row" },
alignItems: "start",
justifyContent: "center",
width: "100%",
}}
>
<Box
sx={{
mx: { xs: 0, sm: 2 },
my: 2,
width: "100%",
}}
>
<Field
as={TextField}
sx={{ width: "100%" }}
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"}
error={
props.touched.navgan_id && props.errors.navgan_id
? true
: false
}
fullWidth
helperText={
props.touched.navgan_id ? props.errors.navgan_id : null
}
/>
</Box>
<Box
sx={{
mx: { xs: 0, sm: 2 },
my: 2,
width: "100%",
}}
>
<Field
as={TextField}
sx={{ width: "100%" }}
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"
)}
type={"text"}
error={
props.touched.national_code &&
props.errors.national_code
? true
: false
}
fullWidth
helperText={
props.touched.national_code
? props.errors.national_code
: null
}
/>
</Box>
<Box
sx={{
mx: { xs: 0, sm: 2 },
my: 2,
width: "100%",
}}
>
<Field
as={TextField}
sx={{ width: "100%" }}
name="birth_certificate_id"
variant="outlined"
size="small"
InputProps={{
readOnly: true,
}}
label={t("LoanRequest.text_field_birth_certificate_id")}
placeholder={t(
"LoanRequest.text_field_enter_your_birth_certificate_id"
)}
type={"text"}
error={
props.touched.birth_certificate_id &&
props.errors.birth_certificate_id
? true
: false
}
fullWidth
helperText={
props.touched.birth_certificate_id
? props.errors.birth_certificate_id
: null
}
/>
</Box>
</Box>
<Box
sx={{
display: "flex",
flexDirection: { xs: "column", sm: "row" },
alignItems: "center",
justifyContent: "space-around",
width: "100%",
}}
>
<Box>
<Image
width={300}
height={300}
src="/images/login.svg"
priority
alt={t("app_name")}
/>
</Box>
<Box>
<Image
width={300}
height={300}
src="/images/login.svg"
priority
alt={t("app_name")}
/>
</Box>
</Box>
<Box
sx={{
display: "flex",
flexDirection: { xs: "column", sm: "row" },
alignItems: "center",
mx: "auto",
width: { xs: "100%", sm: "30%", md: "25%" },
}}
>
<Button
fullWidth
type="submit"
variant="contained"
size="large"
endIcon={<DataSaverOnIcon />}
disabled={props.isSubmitting ? true : false}
>
{t("LoanRequest.button_submit")}
</Button>
</Box>
</StyledForm>
</Stack>
)}
</Formik>
{user.type_id == 1 ? <NavyForm /> : <WelfareServicesForm />}
</CenterLayout>
</DashboardLayouts>
);