Merge branch 'feature/Amin_loan_request' into 'develop'

This commit is contained in:
AmirHossein Mahmoodi
2023-12-20 06:57:20 +00:00
18 changed files with 1082 additions and 499 deletions

View File

@@ -17,8 +17,10 @@
"@mui/lab": "^5.0.0-alpha.152",
"@mui/material": "^5.12.0",
"@witel/webapp-builder": "^1.2.3",
"@mui/x-date-pickers": "^6.18.5",
"axios": "^1.4.0",
"colord": "^2.9.3",
"date-fns-jalali": "^2.13.0-0",
"eslint": "8.36.0",
"formik": "^2.2.9",
"fs-extra": "^11.1.1",

View File

@@ -1,7 +1,14 @@
{
"app_name": "سامانه جامع تسهیلات",
"app_short_name": "سامانه تسهیلات",
"birthday": "تاریخ تولد",
"birthday_error": "تاریخ تولد خود را وارد کنید!",
"dashboard": "داشبورد",
"text_field_city_id": "شهر",
"text_field_error_fetching_cities": "لطفا شهر خود را وارد کنید!",
"text_field_loading_cities_list": "درحال دریافت اطلاعات شهر ها...",
"text_field_loading": "درحال دریافت اطلاعات",
"text_field_error_fetching": "خطا در دریافت اطلاعات",
"first_page": "خوش آمدید",
"powered_by_witel": "توسعه یافته توسط وایتل",
"login": "ورود",
@@ -20,6 +27,7 @@
"online_message": "شما به اینترنت وصل هستید",
"offline_message": "اتصال شما به اینترنت قطع شده است",
"routing_to": "در حال انتقال به صفحه",
"error_message_plate_number": "لطفا شماره پلاک خود را وارد کنید!",
"header": {
"open_profile": "پروفایل",
"edit_profile": "ویرایش پروفایل",
@@ -132,48 +140,74 @@
"loan_details": "نمایش"
},
"LoanRequest": {
"finish_loan_request": "درخواست شما با موفقیت ثبت شد",
"button_while_submit": "درحال بارگذاری ...",
"checkbox": "بدینوسیله صحت کلیه اطلاعات مندرج در این فرم را تایید و گواهی میدهم .",
"back_to_dashboard": "پیگیری درخواست ها",
"cityList_empty": "ابتدا استان را وارد کنید",
"cityList_loading": "درحال دریافت لیست شهر ها ...",
"loan_request_page": "ثبت درخواست وام",
"personal_info": "اطلاعات شخصی",
"national_code_number": "کد ملی می بایست شامل اعداد باشد",
"national_code_max": "کد ملی می بایست 10 رقم باشد",
"shenasname_serial_max": "سریال پشت کارت ملی می بایست شامل 10 بخش باشد",
"postal_code_max": "کد پستی می بایست 10 رقم باشد",
"tel_number_max": "شماره ثابت می بایست 11 رقم باشد",
"national_code_positive": "کد ملی می بایست مثبت باشد",
"uploading_documents": "اسناد",
"error_message_name": "لطفا نام خود را وارد کنید!",
"error_message_phone_number": "لطفا شماره تلفن خود را وارد کنید!",
"error_message_plate_number": "لطفا شماره پلاک را به درستی وارد کنید!",
"error_message_occupation_id": "لطفا کد شغل را به درستی وارد کنید!",
"error_message_education_id": "لطفا تحصیلات را به درستی وارد کنید!",
"error_message_tel_number": "لطفا شماره ثابت (با پیش شماره استان) خود را وارد کنید!",
"error_message_vehicle_type": "لطفا نوع وسیله نقلیه خود را وارد کنید!",
"error_message_plate_number": "لطفا شماره پلاک خود را وارد کنید!",
"error_message_navgan_id": "لطفا کد ناوگان خود را وارد کنید!",
"error_message_navgan_id": "لطفا کد هوشمند ناوگان خود را وارد کنید!",
"error_message_province_id": "لطفا استان خود را وارد کنید!",
"error_message_national_id": "لطفا کد ملی خود را وارد کنید!",
"error_message_shenasname_id": "لطفا شماره شناسنامه خود را وارد کنید!",
"text_field_phone_number": "شماره تلفن",
"text_field_enter_your_phone_number": "شماره تلفن خود را وارد کنید",
"error_message_date_of_birth": "لطفا تاریخ تولد خود را وارد کنید!",
"error_message_shenasname_serial": "لطفا سریال پشت کارت ملی خود را وارد کنید!",
"error_message_postal_code": "لطفا کد پستی خود را وارد کنید!",
"error_message_national_code": "لطفا کد ملی خود را وارد کنید!",
"error_message_checkedBox": "لطفا کد صحت اطلاعات خود را تایید کنید!",
"error_message_navgan_type": "لطفا نوع ناوگان خود را وارد کنید!",
"error_message_address": "لطفا آدرس خود را وارد کنید!",
"text_field_tel_number": "شماره ثابت (با پیش شماره استان)",
"text_field_education_id": "تحصیلات",
"text_field_occupation_id": "شغل",
"text_field_enter_your_tel_number": "شماره ثابت (با پیش شماره استان) خود را وارد کنید",
"text_field_name": "نام",
"text_field_plate_part4": "بخش چهارم",
"text_field_plate_part3": "بخش سوم",
"text_field_plate_part2": "بخش دوم",
"text_field_plate_part1": "بخش اول",
"text_field_postal_code": "کد پستی",
"text_field_navgan_type": "نوع ناوگان",
"text_field_address": "آدرس",
"text_field_enter_your_plate_part1": "بخش اول پلاک را وارد کنید",
"text_field_enter_your_plate_part2": "بخش دوم پلاک را وارد کنید",
"text_field_enter_your_plate_part3": "بخش سوم پلاک را وارد کنید",
"text_field_enter_your_plate_part4": "بخش چهارم پلاک راوارد کنید",
"text_field_enter_your_address": "آدرس خود راوارد کنید",
"text_field_enter_your_name": "نام خود را وارد کنید",
"text_field_vehicle_type": "نام وسیله نقلیه",
"text_field_enter_your_vehicle_type": ام وسیله نقلیه خود را وارد کنید",
"text_field_enter_your_postal_code": "کد پستی خود را وارد کنید",
"text_field_vehicle_type": وع وسیله نقلیه",
"text_field_enter_your_vehicle_type": "نوع وسیله نقلیه خود را وارد کنید",
"text_field_province_id": "استان",
"text_field_loading_provinces_list": "درحال دریافت استان ها",
"text_field_loading_provinces_list": "درحال دریافت استان ها ...",
"text_field_error_fetching_provinces": "خطا در دریافت استان ها",
"text_field_enter_your_national_code": "کد ملی خود را وارد کنید",
"text_field_enter_your_province_id": "استان خود را وارد کنید",
"text_field_navgan_id": "شماره ناوگان",
"text_field_enter_your_navgan_id": "شماره ناوگان خود را وارد کنید",
"text_field_enter_your_city_id": "شهر خود را وارد کنید",
"text_field_navgan_id": "کد هوشمند ناوگان",
"text_field_enter_your_navgan_id": "کد هوشمند ناوگان خود را وارد کنید",
"text_field_national_code": "کد ملی",
"text_field_enter_your_national_id": "کد ملی خود را وارد کنید",
"text_field_shenasname_id": "شماره شناسنامه",
"text_field_enter_your_shenasname_id": "شماره شناسنامه خود را وارد کنید",
"text_field_shenasname_serial": "سریال پشت کارت ملی",
"text_field_enter_your_shenasname_serial": "سریال پشت کارت ملی خود را وارد کنید",
"text_field_plate_number": "شماره پلاک",
"text_field_enter_your_plate_number": "شماره پلاک خود را وارد کنید",
"button_submit": "ثبت درخواست",
"file_field_sherkat_naft_doc": "مجوز شرکت نفت",
"file_field_estate_doc": "سند مالکیت",
"file_field_agreement_doc": "موافقت نامه اصولی",
"error_message_sherkat_naft_doc": "مجوز شرکت نفت خود را وارد کنید",
"error_message_estate_doc": "سند مالکیت خود را وارد کنید",
"error_message_agreement_doc": "موافقت نامه اصولی خود را وارد کنید",
"file_field_shenasname_image": "تصویر شناسنامه",
"file_field_national_card_image": "تصویر کارت ملی",
"file_field_payan_khedmat_image": "تصویر کارت پایان خدمت",
"error_message_national_card_image": "تصویر کارت ملی خود را وارد کنید",
"error_message_shenasname_image": "تصویر شناسنامه خود را وارد کنید",
"error_message_payan_khedmat_image": "تصویر کارت پایان خدمت خود را وارد کنید",
"error_message_city_id": "لطفا شهر خود را وارد کنید!",
"add_loan_request_permission": "اکنون امکان ثبت درخواست جدید برای شما مقدور نیست"
},
"EditLoanRequest": {

View File

@@ -1,463 +1,471 @@
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 {Box, Button, Checkbox, FormControlLabel, Grid, Stack, TextField, Typography} from "@mui/material";
import {useFormik} from "formik";
import {useTranslations} from "next-intl";
import {useEffect, useState} from "react";
import * as Yup from "yup";
import {CenterLayout, useRequest} from "@witel/webapp-builder";
import useProvince from "@/lib/app/hooks/useProvince";
import useCities from "@/lib/app/hooks/useCities";
import PlateNumber from "@/core/components/PlateNumber";
import MuiDatePicker from "@/core/components/MuiDatePicker";
import UseEducations from "@/lib/app/hooks/useEducations";
import useOccupations from "@/lib/app/hooks/useOccupations";
import {useState} from "react";
import DoneIcon from '@mui/icons-material/Done';
import {NextLinkComposed} from "@witel/webapp-builder/dist/utils/linkRouting";
import SvgDone from "@/core/components/svgs/SvgDone";
import {SEND_LOAN_REQUEST_NAVGAN} from "@/core/data/apiRoutes";
const AddFormComponent = () => {
const t = useTranslations();
const {directionApp} = useDirection();
const {token} = useUser();
const [finishLoanRequest, setFinishLoanRequest] = useState(false)
const [checked, setChecked] = useState(false);
const requestServer = useRequest()
const {provinceList, isLoadingProvinceList, errorProvinceList} = useProvince()
const {cityTextField, cityList, setProvinceID, isLoadingCityList} = useCities()
const {educationsList, isLoadingEducationsList, errorEducationsList} = UseEducations()
const {occupationsList, isLoadingOccupationsList, errorOccupationsList} = useOccupations()
// 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(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: "",
telephone_number: "",
vehicle_type: "",
plate_number: "",
province_id: "",
city_id: "",
navgan_id: "",
national_code: "",
shenasname_id: "",
national_card_img: null,
shenasname_img: null,
national_id: "",
national_serial_number: "",
postal_code: "",
navgan_type: "",
plate_part1: "",
plate_part2: "الف",
plate_part3: "",
plate_part4: "",
address: "",
birthday: "",
education_id: "",
occupation_id: "",
checkedBox: false
};
// end initial values
// validation
const validationSchema = Yup.object().shape({
name: Yup.string().required(t("LoanRequest.error_message_name")),
phone_number: Yup.string().required(
t("LoanRequest.error_message_phone_number")
),
telephone_number: Yup.mixed()
.test("max", `${t("LoanRequest.tel_number_max")}`, (value) => {
const stringValue = String(value);
return stringValue.length === 11
})
.required(t("LoanRequest.error_message_tel_number")),
vehicle_type: Yup.string().required(
t("LoanRequest.error_message_vehicle_type")
),
plate_number: Yup.string().required(
t("LoanRequest.error_message_plate_number")
navgan_type: Yup.string().required(
t("LoanRequest.error_message_navgan_type")
),
navgan_id: Yup.string().required(t("LoanRequest.error_message_navgan_id")),
occupation_id: Yup.string().required(
t("LoanRequest.error_message_occupation_id")
),
education_id: Yup.string().required(
t("LoanRequest.error_message_education_id")
),
address: Yup.string().required(
t("LoanRequest.error_message_address")
),
birthday: Yup.string().required(
t("LoanRequest.error_message_date_of_birth")
),
postal_code: Yup.mixed()
.test("max", `${t("LoanRequest.postal_code_max")}`, (value) => value.toString().length === 10)
.required(
t("LoanRequest.error_message_postal_code")
),
plate_part1: Yup.mixed().test("max", `${t("LoanRequest.error_message_plate_number")}`, (value) => value.toString().length === 2)
.required(
t("LoanRequest.error_message_plate_number")
),
plate_part2: Yup.mixed()
.required(
t("LoanRequest.error_message_plate_number")
),
plate_part3: Yup.mixed().test("max", `${t("LoanRequest.error_message_plate_number")}`, (value) => value.toString().length === 3)
.required(
t("LoanRequest.error_message_plate_number")
),
plate_part4: Yup.mixed().test("max", `${t("LoanRequest.error_message_plate_number")}`, (value) => value.toString().length === 2)
.required(
t("LoanRequest.error_message_plate_number")
),
navgan_id: Yup.mixed().required(t("LoanRequest.error_message_navgan_id")),
province_id: Yup.string().required(t("LoanRequest.error_message_province_id")),
national_code: Yup.string().required(
t("LoanRequest.error_message_national_code")
),
shenasname_id: Yup.string().required(
t("LoanRequest.error_message_shenasname_id")
),
city_id: Yup.string().required(t("LoanRequest.error_message_city_id")),
national_id: Yup.mixed()
.test("is-number", `${t("LoanRequest.national_code_number")}`,
(value) => !isNaN(value))
.test("positive", `${t("LoanRequest.national_code_positive")}`, (value) => value >= 0)
.test("max", `${t("LoanRequest.national_code_max")}`, (value) => value.toString().length === 10)
.required(t("LoanRequest.error_message_national_id")),
national_serial_number: Yup.string().required(t("LoanRequest.error_message_shenasname_serial")),
});
// end validation
// submit
const handleSubmit = async (values, props) => {
Notifications(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_id);
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);
props.setSubmitting(true)
await axios
.post(SEND_LOAN_REQUEST_NAVGAN, formData, {
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "multipart/form-data",
},
})
.then(function (response) {
Notifications(t, response);
})
.catch(function (error) {
Notifications(t, error.response);
props.setSubmitting(false);
});
await requestServer(SEND_LOAN_REQUEST_NAVGAN, "post", {
auth: true, notification: true, data: {
telephone_number: values.telephone_number,
vehicle_type: values.vehicle_type,
province_id: values.province_id,
city_id: values.city_id,
navgan_id: values.navgan_id,
national_id: values.national_id,
national_serial_number: values.national_serial_number,
postal_code: values.postal_code,
navgan_type: values.navgan_type,
plate_part1: values.plate_part1,
plate_part2: values.plate_part2,
plate_part3: values.plate_part3,
plate_part4: values.plate_part4,
address: values.address,
birthday: values.birthday.locale('en').format("YYYY-MM-DD"),
education_id: values.education_id,
occupation_id: values.occupation_id,
}
}).then(() => {
setFinishLoanRequest(true)
}).catch(() => {
}).finally(() => {
props.setSubmitting(false)
})
};
// end submit
const formik = useFormik({
initialValues, validationSchema, onSubmit: handleSubmit
})
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%",
}}
<>
{finishLoanRequest ?
(
<CenterLayout>
<SvgDone width={200} height={200}/>
<Stack direction={'row'} spacing={0.7} sx={{mb: 4}}>
<Typography variant={'h5'}
align={'center'}>{t("LoanRequest.finish_loan_request")}</Typography>
<DoneIcon color={'success'}/>
</Stack>
<Button variant={'contained'} component={NextLinkComposed}
to={'/dashboard/navgan/followUp-loan'}>
{t("LoanRequest.back_to_dashboard")}
</Button>
</CenterLayout>
) : (
<>
<Grid container spacing={2} sx={{padding: 2}}
>
<Box
sx={{
mx: {xs: 0, sm: 2},
my: 2,
width: "100%",
}}
<Grid item xs={12} sm={4}
>
<Field
as={TextField}
<TextField
sx={{width: "100%"}}
name="name"
variant="outlined"
size="small"
label={t("LoanRequest.text_field_name")}
placeholder={t("LoanRequest.text_field_enter_your_name")}
type={"text"}
error={props.touched.name && props.errors.name ? true : false}
fullWidth
helperText={props.touched.name ? props.errors.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"
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"
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"
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
name="province_id"
label={t("LoanRequest.text_field_province_id")} // t("LoanRequest.text_field_enter_your_province")
size="small"
selectType="province_id"
component={SelectBox}
selectors={provinceList}
select={props.values.province_id}
setFieldValue={props.setFieldValue}
setFieldTouched={props.setFieldTouched}
error={
props.touched.gender && props.errors.province_id ? true : false
}
helperText={
props.touched.gender ? props.errors.province_id : 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"
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"
name="national_id"
variant="outlined"
size="small"
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
type={'tel'}
onChange={formik.handleChange}
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
}
onBlur={formik.handleBlur("national_id")}
error={formik.touched.national_id && Boolean(formik.errors.national_id)}
helperText={formik.touched.national_id && formik.errors.national_id}
fullWidth
helperText={
props.touched.national_code
? props.errors.national_code
: null
}
/>
</Box>
<Box
sx={{
mx: {xs: 0, sm: 2},
my: 2,
width: "100%",
}}
</Grid>
<Grid item xs={12} sm={4}
>
<Field
as={TextField}
<TextField
sx={{width: "100%"}}
name="shenasname_id"
name="national_serial_number"
variant="outlined"
size="small"
label={t("LoanRequest.text_field_shenasname_id")}
label={t("LoanRequest.text_field_shenasname_serial")}
placeholder={t(
"LoanRequest.text_field_enter_your_shenasname_id"
)}
type={"text"}
error={
props.touched.shenasname_id && props.errors.shenasname_id
? true
: false
}
"LoanRequest.text_field_enter_your_shenasname_serial")}
fullWidth
helperText={
props.touched.shenasname_id
? props.errors.shenasname_id
: null
}
onChange={formik.handleChange}
onBlur={formik.handleBlur("national_serial_number")}
error={formik.touched.national_serial_number && Boolean(formik.errors.national_serial_number)}
helperText={formik.touched.national_serial_number && formik.errors.national_serial_number}
/>
</Box>
</Box>
<Box
sx={{
display: "flex",
flexDirection: {xs: "column", sm: "row"},
alignItems: "center",
justifyContent: "space-around",
width: "100%",
}}
>
<UploadSystem
selectedImage={selectedImageShenasname}
handleUploadChange={(e) =>
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")}
/>
<UploadSystem
selectedImage={selectedImageNationalCard}
handleUploadChange={(e) =>
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")}
/>
</Box>
</Grid>
<Grid item xs={12} sm={4}>
<MuiDatePicker
formik={formik}
error={formik.touched.birthday && Boolean(formik.errors.birthday)}
helperText={formik.touched.birthday && formik.errors.birthday}
onBlur={formik.handleBlur("birthday")}
/>
</Grid>
</Grid>
<Grid container spacing={2} sx={{padding: 2}}>
<Grid item xs={12} sm={6}>
<TextField
sx={{width: "100%"}}
name="postal_code"
variant="outlined"
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
type={'tel'}
onChange={formik.handleChange}
size="small"
label={t("LoanRequest.text_field_postal_code")}
placeholder={t("LoanRequest.text_field_enter_your_postal_code")}
fullWidth
onBlur={formik.handleBlur("postal_code")}
error={formik.touched.postal_code && Boolean(formik.errors.postal_code)}
helperText={formik.touched.postal_code && formik.errors.postal_code}
/>
</Grid>
<Grid item xs={12} sm={6}>
<TextField
sx={{width: "100%"}}
name="telephone_number"
variant="outlined"
value={formik.values.telephone_number}
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
type={'tel'}
size="small"
onChange={(event) => {
const inputValue = event.target.value;
if (isNaN(Number(inputValue))) {
return;
}
formik.handleChange({
target: {
name: "telephone_number",
value: inputValue,
},
});
}}
label={t("LoanRequest.text_field_tel_number")}
placeholder={t(
"LoanRequest.text_field_enter_your_tel_number"
)}
fullWidth
onBlur={formik.handleBlur("telephone_number")}
error={formik.touched.telephone_number && Boolean(formik.errors.telephone_number)}
helperText={formik.touched.telephone_number && formik.errors.telephone_number}
/>
</Grid>
</Grid>
<Grid container spacing={2} sx={{padding: 2}}>
<Grid item xs={12} sm={6}>
<SelectBox
name="navgan_type"
label={t("LoanRequest.text_field_navgan_type")}
size="small"
selectType="navgan_type"
selectors={[
{
id: 1,
value: "روستایی",
name: "روستایی"
},
{
id: 2,
value: "عمومی",
name: "عمومی"
},
{
id: 3,
value: "منطقه آزاد",
name: "منطقه آزاد"
}
]}
schema={{value: 'value', name: 'name'}}
select={formik.values.navgan_type}
handleChange={(event) => {
formik.setFieldValue('navgan_type', event.target.value)
}}
setFieldTouched={formik.setFieldTouched}
error={formik.touched.navgan_type && Boolean(formik.errors.navgan_type)}
helperText={formik.touched.navgan_type && formik.errors.navgan_type}
onBlur={formik.handleBlur("navgan_type")}
/>
</Grid>
<Grid item xs={12} sm={6}>
<TextField
sx={{width: "100%"}}
name="navgan_id"
variant="outlined"
inputProps={{inputMode: 'numeric', pattern: '[0-9]*'}}
type={'tel'}
onChange={formik.handleChange}
size="small"
label={t("LoanRequest.text_field_navgan_id")}
placeholder={t("LoanRequest.text_field_enter_your_navgan_id")}
fullWidth
onBlur={formik.handleBlur("navgan_id")}
error={formik.touched.navgan_id && Boolean(formik.errors.navgan_id)}
helperText={formik.touched.navgan_id && formik.errors.navgan_id}
/>
</Grid>
</Grid>
<Grid container spacing={2} sx={{padding: 2}}>
<Grid item xs={12} sm={6}>
<SelectBox
name="province_id"
label={t("LoanRequest.text_field_province_id")}
size="small"
selectType="province_id"
isLoading={isLoadingProvinceList}
errorEcured={errorProvinceList}
selectors={provinceList}
schema={{value: 'value', name: 'name'}}
select={formik.values.province_id}
handleChange={(event) => {
formik.setFieldValue('province_id', event.target.value);
setProvinceID(event.target.value)
formik.setFieldTouched("city_id", false, false);
formik.setFieldValue("city_id", "")
}}
setFieldTouched={formik.setFieldTouched}
error={formik.touched.province_id && Boolean(formik.errors.province_id)}
helperText={formik.touched.province_id && formik.errors.province_id}
onBlur={formik.handleBlur("province_id")}
/>
</Grid>
<Grid item xs={12} sm={6}>
<SelectBox
name="city_id"
label={isLoadingCityList ? `${t("LoanRequest.cityList_loading")}` : (cityList.length === 0 ? `${t("LoanRequest.cityList_empty")}` : cityTextField)}
size="small"
selectType="city_id"
schema={{value: 'value', name: 'name'}}
disabled={cityList.length === 0}
selectors={cityList}
select={formik.values.city_id}
handleChange={(event) => formik.setFieldValue('city_id', event.target.value)}
setFieldTouched={formik.setFieldTouched}
error={formik.touched.city_id && Boolean(formik.errors.city_id)}
helperText={formik.touched.city_id && formik.errors.city_id}
onBlur={formik.handleBlur("city_id")}
/>
</Grid>
</Grid>
<Grid container spacing={2} sx={{padding: 2}}>
<Grid item xs={12} sm={6}>
<SelectBox
name="vehicle_type"
label={t("LoanRequest.text_field_vehicle_type")}
size="small"
schema={{value: 'value', name: 'name'}}
selectType="vehicle_type"
selectors={[
{
id: 0,
value: "اتوبوس",
name: "اتوبوس"
},
{
id: 1,
value: "مینی بوس",
name: "مینی بوس"
},
{
id: 2,
value: "سواری",
name: "سواری"
}
]}
select={formik.values.vehicle_type}
handleChange={(event) => formik.setFieldValue('vehicle_type', event.target.value)}
error={formik.touched.vehicle_type && Boolean(formik.errors.vehicle_type)}
helperText={formik.touched.vehicle_type && formik.errors.vehicle_type}
onBlur={formik.handleBlur("vehicle_type")}
/>
</Grid>
<Grid item xs={12} sm={6}>
<PlateNumber formik={formik}/>
</Grid>
</Grid>
<Grid container spacing={2} sx={{padding: 2}}>
<Grid item xs={12} sm={6}>
<SelectBox
name="education_id"
label={t("LoanRequest.text_field_education_id")}
size="small"
isLoading={isLoadingEducationsList}
errorEcured={errorEducationsList}
selectType="education_id"
selectors={educationsList}
select={formik.values.education_id}
schema={{value: 'id', name: 'title'}}
handleChange={(event) => {
formik.setFieldValue('education_id', event.target.value)
}}
setFieldTouched={formik.setFieldTouched}
error={formik.touched.education_id && Boolean(formik.errors.education_id)}
helperText={formik.touched.education_id && formik.errors.education_id}
onBlur={formik.handleBlur("education_id")}
/>
</Grid>
<Grid item xs={12} sm={6}>
<SelectBox
name="occupation_id"
label={t("LoanRequest.text_field_occupation_id")}
size="small"
isLoading={isLoadingOccupationsList}
errorEcured={errorOccupationsList}
selectType="occupation_id"
schema={{value: 'id', name: 'title'}}
selectors={occupationsList}
select={formik.values.occupation_id}
handleChange={(event) => {
formik.setFieldValue('occupation_id', event.target.value)
}}
setFieldTouched={formik.setFieldTouched}
error={formik.touched.occupation_id && Boolean(formik.errors.occupation_id)}
helperText={formik.touched.occupation_id && formik.errors.occupation_id}
onBlur={formik.handleBlur("occupation_id")}
/>
</Grid>
</Grid>
<Grid container spacing={2} sx={{padding: 2}}>
<Grid item xs={12}>
<TextField
multiline
rows={8}
sx={{width: "100%"}}
name="address"
variant="outlined"
size="small"
label={t("LoanRequest.text_field_address")}
placeholder={t("LoanRequest.text_field_enter_your_address")}
fullWidth
onChange={formik.handleChange}
onBlur={formik.handleBlur("address")}
error={formik.touched.address && Boolean(formik.errors.address)}
helperText={formik.touched.address && formik.errors.address}
/>
</Grid>
</Grid>
<Grid container spacing={2} sx={{padding: 2}}>
<Grid item xs={12}>
<FormControlLabel
color={'error.main'}
control={
<Checkbox
checked={formik.values.checkedBox}
onChange={(event) => {
formik.setFieldValue("checkedBox", event.target.checked)
}}
/>
}
label={`${t("LoanRequest.checkbox")}`}/>
</Grid>
</Grid>
<Box
sx={{
display: "flex",
@@ -469,20 +477,23 @@ const AddFormComponent = () => {
>
<Button
fullWidth
onClick={formik.handleSubmit}
type="submit"
variant="contained"
size="large"
sx={{mt: 2}}
sx={{my: 4}}
endIcon={<DataSaverOnIcon/>}
disabled={props.isSubmitting ? true : false}
disabled={formik.values.checkedBox ? (formik.isSubmitting || !formik.dirty || !formik.isValid) : true}
>
{t("LoanRequest.button_submit")}
{formik.isSubmitting
? t("LoanRequest.button_while_submit")
: t("LoanRequest.button_submit")}
</Button>
</Box>
</StyledForm>
</Stack>
)}
</Formik>
</>
)
}
</>
);
};

View File

@@ -1,29 +1,21 @@
import CenterLayout from "@/layouts/CenterLayout";
import DashboardLayouts from "@/layouts/dashboardLayouts";
import useUser from "@/lib/app/hooks/useUser";
import {Box, Chip, Divider} from "@mui/material";
import {useTranslations} from "next-intl";
import AddFormComponent from "@/components/dashboard/navgan/add-request-loan/forms/AddForm";
const LoanRequestComponent = () => {
const t = useTranslations();
const {user} = useUser();
return (
<DashboardLayouts>
<CenterLayout>
<Box sx={{width: "80%", my: 2}}>
<>
<Box>
<Divider>
<Chip
label={`${t("LoanRequest.loan_request_page")} | ${
user.type_name
}`}
label={`${t("LoanRequest.loan_request_page")} | ${t("user_navy")} `}
/>
</Divider>
</Box>
<AddFormComponent/>
</CenterLayout>
</DashboardLayouts>
</>
);
};

View File

@@ -95,6 +95,21 @@ const SendUserDataComponent = ({
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
fullWidth
type="submit"
@@ -105,6 +120,7 @@ const SendUserDataComponent = ({
>
{t("LoginPage.button_request_verification")}
</Button>
</Grid>
</Grid>
</Stack>
</StyledForm>

View File

View File

View File

@@ -0,0 +1,87 @@
import * as React from 'react';
import {useState} from 'react';
import Button from '@mui/material/Button';
import {AdapterDateFnsJalali} from "@mui/x-date-pickers/AdapterDateFnsJalali";
import {LocalizationProvider} from '@mui/x-date-pickers/LocalizationProvider';
import {DatePicker} from '@mui/x-date-pickers/DatePicker';
import {useTranslations} from "next-intl";
import moment from "jalali-moment";
import {FormControl, FormHelperText} from "@mui/material";
function ButtonField(props) {
const t = useTranslations();
const {
setOpen,
label,
id,
disabled,
InputProps: {ref} = {},
inputProps: {'aria-label': ariaLabel} = {},
} = props;
return (
<Button
sx={{width: "100%", padding: 0.8}}
variant="outlined"
color={props.slotProps.formik.touched.birthday && Boolean(props.slotProps.formik.errors.birthday) ? "error" : "primary"}
id={id}
disabled={disabled}
ref={ref}
aria-label={ariaLabel}
onClick={() => setOpen?.((prev) => !prev)}
>
{label ? `${t("birthday")}: ${label}` : `${t("birthday")}`}
</Button>
);
}
function ButtonDatePicker(props) {
const t = useTranslations();
const [open, setOpen] = useState(false);
return (
<DatePicker
slots={{field: ButtonField, ...props.slots}}
disableFuture
disabled={props.disabled}
slotProps={{
formik: props.formik,
field: {setOpen},
textField: {
helperText: props.formik.errors.birthday ? `${t("birthday_error")}` : null
}
}}
{...props}
open={open}
onClose={() => setOpen(false)}
onOpen={() => setOpen(true)}
/>
);
}
export default function PickerWithButtonField({formik, disabled}) {
return (
<FormControl
variant={"outlined"}
fullWidth
size="small"
error={true}
>
<LocalizationProvider dateAdapter={AdapterDateFnsJalali}>
<ButtonDatePicker
label={formik.values.birthday === "" ? null : formik.values.birthday
.locale("fa")
.format("YYYY/MM/DD")}
value={formik.values.birthday === "" ? null : formik.values.birthday.toDate()}
formik={formik}
disabled={disabled}
onChange={(newValue) => {
formik.setFieldValue("birthday", moment(newValue))
}}
/>
</LocalizationProvider>
<FormHelperText>{formik.touched.birthday && formik.errors.birthday}</FormHelperText>
</FormControl>
);
}

View File

@@ -0,0 +1,236 @@
import {Box, Button, Drawer, FormHelperText, Stack, TextField} from "@mui/material";
import {useTranslations} from "next-intl";
import AccessibleIcon from '@mui/icons-material/Accessible';
import {useState} from "react";
const plate_words = [
{
id: 1,
value: "الف",
name: "الف"
},
{
id: 2,
value: "ب",
name: "ب"
},
{
id: 3,
value: "پ",
name: "پ"
},
{
id: 4,
value: "ت",
name: "ت"
},
{
id: 5,
value: "ث",
name: "ث"
},
{
id: 6,
value: "ج",
name: "ج"
},
{
id: 7,
value: "د",
name: "د"
},
{
id: 8,
value: "ز",
name: "ز"
},
{
id: 9,
value: "س",
name: "س"
},
{
id: 10,
value: "ش",
name: "ش"
},
{
id: 11,
value: "ص",
name: "ص"
},
{
id: 12,
value: "ط",
name: "ط"
},
{
id: 13,
value: "ع",
name: "ع"
},
{
id: 14,
value: "ف",
name: "ف"
},
{
id: 15,
value: "ق",
name: "ق"
},
{
id: 16,
value: "ک",
name: "گ"
},
{
id: 17,
value: "ل",
name: "ل"
},
{
id: 18,
value: "م",
name: "م"
},
{
id: 19,
value: "ن",
name: "ن"
},
{
id: 20,
value: "و",
name: "و"
},
{
id: 21,
value: "ه",
name: "ه"
},
{
id: 22,
value: "ی",
name: "ی"
},
{
id: 23,
value: "*",
name: <AccessibleIcon/>
},
]
const PlateNumber = ({formik, disabled}) => {
const t = useTranslations();
const [plateDrawer, setPlateDrawer] = useState(false);
const isErrorPlate = Boolean(formik.errors.plate_part1 || formik.errors.plate_part3 || formik.errors.plate_part4)
const isTouched = (formik.touched.plate_part1 || formik.touched.plate_part3 || formik.touched.plate_part4)
return (
<>
<Stack direction={'row'}
sx={{
border: 1,
overflow: 'hidden',
borderColor: (isTouched && isErrorPlate) ? 'error.main' : 'divider',
borderRadius: 1
}}>
<TextField
name={'plate_part4'}
type={'tel'}
value={formik.values.plate_part4}
disabled={disabled}
size={'small'}
placeholder={'xx'} sx={{flexGrow: 2, "& fieldset": {border: 'none'}}}
inputProps={{sx: {textAlign: 'center'}}}
onChange={(event) => event.target.value.length <= 2 ? formik.setFieldValue("plate_part4", event.target.value) : null}
onBlur={formik.handleBlur}
error={formik.touched.plate_part4 && Boolean(formik.errors.plate_part4)}
/>
<TextField
name={'plate_part3'}
type={'tel'}
value={formik.values.plate_part3}
size={'small'}
disabled={disabled}
placeholder={'xxx'}
sx={{
flexGrow: 3,
borderLeft: 1,
borderRadius: 0,
borderColor: 'divider',
"& fieldset": {border: 'none'}
}}
inputProps={{sx: {textAlign: 'center'}}}
onChange={(event) => event.target.value.length <= 3 ? formik.setFieldValue("plate_part3", event.target.value) : null}
onBlur={formik.handleBlur}
error={formik.touched.plate_part3 && Boolean(formik.errors.plate_part3)}
/>
<Box sx={{flexGrow: 1}}>
<Button
onClick={() => setPlateDrawer(true)}
sx={{height: '100%', borderRadius: 0, borderColor: 'divider'}}
size={'small'}
data-selected-word={formik.values.plate_part2}
disabled={disabled}
fullWidth
>
{plate_words.find(p => p.value === formik.values.plate_part2).name}
</Button>
</Box>
<Drawer
anchor={"bottom"}
open={plateDrawer}
onClose={() => setPlateDrawer(false)}
>
<Box sx={{
display: "flex",
flexWrap: "wrap",
mx: "auto",
my: 2,
gap: 2,
width: "60%",
justifyContent: "center"
}}>
{plate_words.map((item) => (
<Button
key={item.id}
onClick={() => {
formik.setFieldValue("plate_part2", item.value)
setPlateDrawer(false);
}}
sx={{
width: "fit-content"
}}
variant="contained"
>
{item.name}
</Button>
))}
</Box>
</Drawer>
<TextField
name={'plate_part1'}
type={'tel'}
disabled={disabled}
value={formik.values.plate_part1}
size={'small'}
placeholder={'xx'}
sx={{flexGrow: 2, "& fieldset": {border: 'none'}}}
inputProps={{sx: {textAlign: 'center'}}}
onChange={(event) => event.target.value.length <= 2 ? formik.setFieldValue("plate_part1", event.target.value) : null}
onBlur={formik.handleBlur}
error={true}
/>
<Stack sx={{width: 24, borderLeft: 1, borderColor: 'divider'}}>
<Box sx={{flexGrow: 1, bgcolor: '#1ebc1e'}}></Box>
<Box sx={{flexGrow: 1, bgcolor: 'white'}}></Box>
<Box sx={{flexGrow: 1, bgcolor: '#f52121'}}></Box>
</Stack>
</Stack>
<FormHelperText
error={(isTouched && isErrorPlate)}>{(isTouched && isErrorPlate) ? `${t("LoanRequest.error_message_plate_number")}` : null}</FormHelperText>
</>
)
}
export default PlateNumber

View File

@@ -1,48 +1,53 @@
import {FormControl, FormHelperText, InputLabel, MenuItem, Select,} from "@mui/material";
import {useTranslations} from "next-intl";
function SelectBox({
select,
selectType,
name,
selectors,
label,
setFieldValue,
setFieldTouched,
handleChange,
error,
onBlur,
schema,
disabled,
helperText,
isLoading,
errorEcured
}) {
const t = useTranslations();
const selectId = String(select);
const handleChange = (event) => {
setFieldValue(selectType, event.target.value);
};
const handleBlur = () => {
setFieldTouched(select, true);
};
return (
<FormControl
variant="outlined"
margin="normal"
disabled={disabled || false}
variant={"outlined"}
fullWidth
size="small"
error={error}
sx={{mt: 0}}
>
<InputLabel id="language-label">{label}</InputLabel>
<InputLabel>{label}</InputLabel>
<Select
labelId="language-label"
id={selectId}
name={selectId}
label={label}
name={name}
size="small"
value={select}
value={isLoading ? "" : select}
onChange={handleChange}
label="Language"
onBlur={handleBlur}
onBlur={onBlur}
>
{selectors.map((selector) => (
<MenuItem key={selector.id} value={selector.value}>
{selector.name}
{isLoading ? (
<MenuItem sx={{color: "primary.main"}}>{t("text_field_loading")}</MenuItem>
) : errorEcured ? (
<MenuItem sx={{color: "secondary.main"}}>
{t("text_field_error_fetching")}
</MenuItem>
))}
) : (
selectors.map((selector) => (
<MenuItem key={selector.id} value={selector[schema.value]}>
{selector[schema.name]}
</MenuItem>
))
)}
</Select>
<FormHelperText>{helperText}</FormHelperText>
</FormControl>

View File

@@ -0,0 +1,96 @@
import {useTheme} from "@mui/material";
const SvgDone = ({width, height}) => {
const theme = useTheme()
const fillColor = theme.palette.primary.main
return (
<svg xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" width={width} height={height}
viewBox="0 0 680.83858 584.23207">
<path id="b9ccae5a-ffdd-4f5c-9c1e-05af9f0f3372-220" data-name="Path 438"
d="M310.70569,694.02818a24.21459,24.21459,0,0,0,23.38269-4.11877c8.18977-6.87441,10.758-18.196,12.8467-28.68191l6.17973-31.01657-12.9377,8.90837c-9.30465,6.40641-18.81826,13.01866-25.26011,22.29785s-9.25223,21.94707-4.07792,31.988"
transform="translate(-259.58071 -157.88396)" fill="#e6e6e6"/>
<path id="f4ad1d06-bd03-4ced-a5c4-c19a65ab4ee5-221" data-name="Path 439"
d="M312.7034,733.73874c-1.62839-11.86368-3.30382-23.88078-2.15884-35.87167,1.01467-10.64932,4.26373-21.04881,10.87831-29.57938a49.20592,49.20592,0,0,1,12.62466-11.44039c1.26215-.79648,2.42409,1.20354,1.16733,1.997a46.77949,46.77949,0,0,0-18.50446,22.32562c-4.02857,10.24607-4.67545,21.41582-3.98154,32.3003.41944,6.58218,1.31074,13.1212,2.20588,19.65251a1.19817,1.19817,0,0,1-.808,1.42251,1.16348,1.16348,0,0,1-1.42253-.808Z"
transform="translate(-259.58071 -157.88396)" fill="#f2f2f2"/>
<path id="baf785f8-b4c6-42cf-85bd-8a16037845f7-222" data-name="Path 442"
d="M324.42443,714.70229a17.82513,17.82513,0,0,0,15.53141,8.01862c7.8644-.37318,14.41806-5.85973,20.31713-11.07027l17.452-15.4088-11.54987-.55281c-8.30619-.39784-16.82672-.771-24.73813,1.79338s-15.20758,8.72639-16.654,16.91541"
transform="translate(-259.58071 -157.88396)" fill="#e6e6e6"/>
<path id="a14e4330-7125-4e03-a856-d6453c34f6cc-223" data-name="Path 443"
d="M308.10042,740.55843c7.83972-13.87142,16.93234-29.28794,33.1808-34.21552a37.02609,37.02609,0,0,1,13.95545-1.441c1.48189.128,1.11179,2.41174-.367,2.28454a34.39833,34.39833,0,0,0-22.27164,5.89215c-6.27994,4.27453-11.16975,10.21755-15.30781,16.51907-2.53511,3.86051-4.80576,7.88445-7.07642,11.903C309.48824,742.78513,307.36641,741.85759,308.10042,740.55843Z"
transform="translate(-259.58071 -157.88396)" fill="#f2f2f2"/>
<path id="ac20a106-7eb8-4a45-8835-674ef3bf3222-224" data-name="Path 141"
d="M935.3957,569.31654H503.18092a5.03014,5.03014,0,0,1-5.02359-5.02359V162.90754a5.03017,5.03017,0,0,1,5.02359-5.02358H935.3957a5.03017,5.03017,0,0,1,5.02359,5.02358V564.292a5.02922,5.02922,0,0,1-5.02359,5.02359Z"
transform="translate(-259.58071 -157.88396)" fill="#fff"/>
<path id="a8878079-c7cd-406f-a434-8b15b914b9b4-225" data-name="Path 141"
d="M935.3957,569.31654H503.18092a5.03014,5.03014,0,0,1-5.02359-5.02359V162.90754a5.03017,5.03017,0,0,1,5.02359-5.02358H935.3957a5.03017,5.03017,0,0,1,5.02359,5.02358V564.292a5.02922,5.02922,0,0,1-5.02359,5.02359ZM503.18092,159.88944a3.01808,3.01808,0,0,0-3.01152,3.01151V564.292a3.01808,3.01808,0,0,0,3.01152,3.01152H935.3957a3.01717,3.01717,0,0,0,3.01153-3.01152V162.90754a3.01809,3.01809,0,0,0-3.01153-3.01151Z"
transform="translate(-259.58071 -157.88396)" fill="#cacaca"/>
<path id="af64f961-e9a2-4c53-a333-5060c7f850d2-226" data-name="Path 142"
d="M707.41023,262.18528a3.41053,3.41053,0,0,0,0,6.82105H894.55305a3.41053,3.41053,0,0,0,0-6.82105Z"
transform="translate(-259.58071 -157.88396)" fill="#e4e4e4"/>
<path id="baad4cfb-158d-4439-9cc3-22475bf47b22-227" data-name="Path 143"
d="M707.41023,282.65037a3.41054,3.41054,0,0,0,0,6.82106h95.54019a3.41054,3.41054,0,0,0,0-6.82106Z"
transform="translate(-259.58071 -157.88396)" fill="#e4e4e4"/>
<path id="f3456279-91e5-49ad-aa43-9838b26fb6ca-228" data-name="Path 142"
d="M543.84146,392.7046a3.41054,3.41054,0,0,0,0,6.82106h350.8937a3.41054,3.41054,0,0,0,0-6.82106Z"
transform="translate(-259.58071 -157.88396)" fill="#e4e4e4"/>
<path id="a3288adf-49f8-485f-8ae9-1e4f1a13d849-229" data-name="Path 143"
d="M543.84146,413.1697a3.41054,3.41054,0,0,0,0,6.82106H803.13254a3.41054,3.41054,0,0,0,0-6.82106Z"
transform="translate(-259.58071 -157.88396)" fill="#e4e4e4"/>
<path id="e63a5b48-5a7d-40a2-b9b0-6adec326348a-230" data-name="Path 142"
d="M543.84146,433.17177a3.41054,3.41054,0,0,0,0,6.82106h350.8937a3.41054,3.41054,0,0,0,0-6.82106Z"
transform="translate(-259.58071 -157.88396)" fill="#e4e4e4"/>
<path id="a1c669b4-dfc3-4cfa-a7be-66b71399844d-231" data-name="Path 143"
d="M543.84146,453.63687a3.41054,3.41054,0,0,0,0,6.82106H803.13254a3.41054,3.41054,0,0,0,0-6.82106Z"
transform="translate(-259.58071 -157.88396)" fill="#e4e4e4"/>
<path id="bfec50d1-ffb1-4de6-a9ef-a1085e40e016-232" data-name="Path 142"
d="M543.84146,474.17177a3.41054,3.41054,0,0,0,0,6.82106h350.8937a3.41054,3.41054,0,0,0,0-6.82106Z"
transform="translate(-259.58071 -157.88396)" fill="#e4e4e4"/>
<path id="bc9696ec-ec99-41d5-9116-3ad9737a38ac-233" data-name="Path 143"
d="M543.84146,494.63687a3.41054,3.41054,0,0,0,0,6.82106H803.13254a3.41054,3.41054,0,0,0,0-6.82106Z"
transform="translate(-259.58071 -157.88396)" fill="#e4e4e4"/>
<path d="M599.41943,324.82812a49,49,0,1,1,48.99952-49A49.05567,49.05567,0,0,1,599.41943,324.82812Z"
transform="translate(-259.58071 -157.88396)" fill={fillColor}/>
<path
d="M450.67833,510.10041a12.24754,12.24754,0,0,0-14.953-11.36231l-16.19641-22.82521-16.27138,6.45945,23.32519,31.91237a12.31392,12.31392,0,0,0,24.09559-4.1843Z"
transform="translate(-259.58071 -157.88396)" fill="#a0616a"/>
<path
d="M419.11211,508.40888l-49.00774-63.57777L388.46714,387.12c1.34563-14.50936,10.425-18.56089,10.81135-18.72645l.5893-.25281,15.979,42.6119-11.73235,31.28625,28.79671,48.4319Z"
transform="translate(-259.58071 -157.88396)" fill="#3f3d56"/>
<path
d="M589.30794,312.41993a12.24758,12.24758,0,0,0-10.17219,15.78672l-21.50463,17.91269,7.69816,15.72326,30.01343-25.72272a12.31392,12.31392,0,0,0-6.03477-23.69995Z"
transform="translate(-259.58071 -157.88396)" fill="#a0616a"/>
<path
d="M590.06206,344.02244l-59.59835,53.77665-58.95815-13.84578c-14.57-.21979-19.31136-8.9587-19.50629-9.33113l-.29761-.568,41.2489-19.22578,32.0997,9.27828,46.06046-32.45509Z"
transform="translate(-259.58071 -157.88396)" fill="#3f3d56"/>
<polygon points="227.248 568.437 243.261 568.436 250.878 506.672 227.245 506.673 227.248 568.437"
fill="#a0616a"/>
<path
d="M483.39733,721.74476h50.32614a0,0,0,0,1,0,0V741.189a0,0,0,0,1,0,0h-36.207a14.11914,14.11914,0,0,1-14.11914-14.11914v-5.32505A0,0,0,0,1,483.39733,721.74476Z"
transform="translate(757.57348 1305.02654) rotate(179.99738)" fill="#2f2e41"/>
<polygon points="163.247 568.437 179.26 568.436 186.878 506.672 163.245 506.673 163.247 568.437"
fill="#a0616a"/>
<path
d="M419.397,721.74476H469.7231a0,0,0,0,1,0,0V741.189a0,0,0,0,1,0,0h-36.207A14.11914,14.11914,0,0,1,419.397,727.06981v-5.32505a0,0,0,0,1,0,0Z"
transform="translate(629.57273 1305.02946) rotate(179.99738)" fill="#2f2e41"/>
<polygon
points="157.552 342.991 158.858 434.42 160.165 554.584 188.899 551.972 203.267 386.094 221.553 551.972 251.218 551.972 254.206 384.788 243.757 348.216 157.552 342.991"
fill="#2f2e41"/>
<path
d="M473.37417,513.1531c-31.26533.00239-60.04471-14.14839-60.43319-14.34263l-.32273-.16136-2.62373-62.96637c-.76082-2.22509-15.74263-46.13091-18.28-60.08625-2.57083-14.13882,34.68842-26.54742,39.213-27.99853l1.02678-11.37405,41.75366-4.49918,5.292,14.5536,14.97942,5.6168a7.40924,7.40924,0,0,1,4.59212,8.7043l-8.32539,33.85619,20.33325,112.01266-4.37755.18946C495.709,511.39658,484.38425,513.1525,473.37417,513.1531Z"
transform="translate(-259.58071 -157.88396)" fill="#3f3d56"/>
<circle cx="454.46738" cy="294.45965" r="30.06284"
transform="matrix(0.87745, -0.47966, 0.47966, 0.87745, -345.12824, 96.19037)" fill="#a0616a"/>
<path
d="M430.1166,323.56132c5.72926,6.10289,16.36927,2.82672,17.1158-5.51069a10.07153,10.07153,0,0,0-.01268-1.94523c-.38544-3.69311-2.519-7.046-2.008-10.94542a5.73974,5.73974,0,0,1,1.05046-2.687c4.56548-6.11359,15.28263,2.73444,19.59138-2.8,2.642-3.39359-.46364-8.73664,1.56381-12.52956,2.67591-5.006,10.60183-2.53654,15.57222-5.27809,5.53017-3.05032,5.1994-11.53517,1.55907-16.6961-4.43955-6.294-12.22348-9.65241-19.91044-10.13643s-15.32094,1.59394-22.4974,4.39069c-8.15392,3.17767-16.23969,7.56925-21.25749,14.739-6.10218,8.71919-6.68942,20.44132-3.6376,30.63677C419.10222,311.0013,425.43805,318.57766,430.1166,323.56132Z"
transform="translate(-259.58071 -157.88396)" fill="#2f2e41"/>
<path d="M641.58071,741.9626h-381a1,1,0,0,1,0-2h381a1,1,0,0,1,0,2Z"
transform="translate(-259.58071 -157.88396)" fill="#cacaca"/>
<path
d="M596.58984,294.33545a3.488,3.488,0,0,1-2.38134-.93555l-16.15723-15.00732a3.49994,3.49994,0,0,1,4.76367-5.12891l13.68555,12.71192,27.07666-27.07618a3.5,3.5,0,1,1,4.94922,4.9502l-29.46094,29.46094A3.49275,3.49275,0,0,1,596.58984,294.33545Z"
transform="translate(-259.58071 -157.88396)" fill="#fff"/>
</svg>
)
}
export default SvgDone

View File

@@ -14,5 +14,8 @@ export const SEND_LOAN_REQUEST_WELFARE = BASE_URL + "/refahi/loan/store";
export const UPDATE_LOAN_REQUEST_WELFARE = BASE_URL + "/refahi/loan/update/";
export const DETAILS_LOAN_REQUEST_WELFARE = BASE_URL + "/refahi/loan/details/";
export const GET_PROVINCE_LIST = BASE_URL + "/provinces";
export const GET_CITIES_LIST = BASE_URL + "/cities";
export const GET_EDUCATIONS_LIST = BASE_URL + "/education";
export const GET_OCCUPATIONS_LIST = BASE_URL + "/occupations";

View File

@@ -0,0 +1,38 @@
import {useEffect, useState} from "react";
import {useRequest} from "@witel/webapp-builder";
import {useTranslations} from "next-intl";
import {GET_CITIES_LIST} from "@/core/data/apiRoutes";
const useCities = () => {
const t = useTranslations();
const [provinceID, setProvinceID] = useState(null)
const [cityList, setCityList] = useState([]);
const [cityTextField, setCityTextField] = useState(t("text_field_city_id"));
const [isLoadingCityList, setIsLoadingCityList] = useState(false)
const requestServer = useRequest({auth: true, notification: false})
useEffect(() => {
if (provinceID === null) return
setIsLoadingCityList(true)
setCityTextField(t("text_field_loading_cities_list"))
requestServer(`${GET_CITIES_LIST}?province_id=${provinceID}`, "get", {auth: true, notification: false})
.then(({data}) => {
const result = data.data;
const formattedData = result.map((city, index) => ({
id: index,
name: city.name,
value: city.id,
}));
setCityList(formattedData);
setIsLoadingCityList(false)
setCityTextField(t("text_field_city_id"))
}).catch(() => {
setIsLoadingCityList(false)
setCityTextField(t("text_field_error_fetching_cities"))
});
}, [provinceID])
return {cityTextField, cityList, setProvinceID, isLoadingCityList}
}
export default useCities

View File

@@ -0,0 +1,29 @@
import {GET_EDUCATIONS_LIST} from "@/core/data/apiRoutes";
import {useRequest} from "@witel/webapp-builder";
import {useEffect, useState} from "react";
const useEducations = () => {
const [isLoadingEducationsList, setIsLoadingEducationsList] = useState(false)
const [errorEducationsList, setErrorEducationsList] = useState(false)
const [educationsList, setEducationsList] = useState([])
const requestServer = useRequest({auth: true, notification: false})
useEffect(() => {
setIsLoadingEducationsList(true)
requestServer(GET_EDUCATIONS_LIST, 'get', {auth: true, notification: false}).then(({data}) => {
setIsLoadingEducationsList(false)
setEducationsList(data.data);
}).catch(() => {
setIsLoadingEducationsList(false)
setErrorEducationsList(true)
})
}, [])
return {
educationsList,
isLoadingEducationsList,
errorEducationsList
}
};
export default useEducations;

View File

@@ -0,0 +1,29 @@
import {GET_OCCUPATIONS_LIST} from "@/core/data/apiRoutes";
import {useRequest} from "@witel/webapp-builder";
import {useEffect, useState} from "react";
const useOccupations = () => {
const [isLoadingOccupationsList, setIsLoadingOccupationsList] = useState(false)
const [errorOccupationsList, setErrorOccupationsList] = useState(false)
const [occupationsList, setOccupationsList] = useState([])
const requestServer = useRequest({auth: true, notification: false})
useEffect(() => {
setIsLoadingOccupationsList(true)
requestServer(GET_OCCUPATIONS_LIST, 'get', {auth: true, notification: false}).then(({data}) => {
setIsLoadingOccupationsList(false)
setOccupationsList(data.data);
}).catch(() => {
setIsLoadingOccupationsList(false)
setErrorOccupationsList(true)
})
}, [])
return {
occupationsList,
isLoadingOccupationsList,
errorOccupationsList
}
};
export default useOccupations;

View File

@@ -1,28 +1,33 @@
import {GET_PROVINCE_LIST} from "@/core/data/apiRoutes";
import useRequest from "@/lib/app/hooks/useRequest";
import useSWR from "swr";
import {useRequest} from "@witel/webapp-builder";
import {useEffect, useState} from "react";
const useProvince = () => {
const [isLoadingProvinceList, setIsLoadingProvinceList] = useState(false)
const [errorProvinceList, setErrorProvinceList] = useState(false)
const [provinceList, setProvinceList] = useState([])
const requestServer = useRequest({auth: true, notification: false})
//swr config
const fetcher = (...args) => {
return requestServer(args, 'get').then(({data}) => {
return data;
useEffect(()=> {
setIsLoadingProvinceList(true)
requestServer(GET_PROVINCE_LIST, 'get',{auth : true, notification : false}).then(({data}) => {
const formattedData = data.map((province, index) => ({
id: index,
name: province.name,
value: province.id,
}));
setIsLoadingProvinceList(false)
setProvinceList(formattedData);
}).catch(() => {
setIsLoadingProvinceList(false)
setErrorProvinceList(true)
})
};
const {data, isLoading} = useSWR(GET_PROVINCE_LIST, fetcher, {
revalidateIfStale: false,
revalidateOnFocus: false,
revalidateOnReconnect: false
});
},[])
return {
provinceList: data,
isLoadingProvinceList: isLoading,
errorProvinceList: !data
provinceList,
isLoadingProvinceList,
errorProvinceList
}
};

View File