Merge branch 'release/v2.6.0'
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
NEXT_PUBLIC_API_NAME = "Loan Facilities Dashboard"
|
NEXT_PUBLIC_API_NAME = "Loan Facilities Dashboard"
|
||||||
NEXT_PUBLIC_API_VERSION = "2.5.4"
|
NEXT_PUBLIC_API_VERSION = "2.6.0"
|
||||||
NEXT_PUBLIC_DEFAULT_LANGUAGE = "fa"
|
NEXT_PUBLIC_DEFAULT_LANGUAGE = "fa"
|
||||||
NEXT_PUBLIC_DEFAULT_DIRECTION = "rtl"
|
NEXT_PUBLIC_DEFAULT_DIRECTION = "rtl"
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import CancelIcon from "@mui/icons-material/Cancel";
|
|||||||
import EditIcon from "@mui/icons-material/Edit";
|
import EditIcon from "@mui/icons-material/Edit";
|
||||||
import PendingIcon from "@mui/icons-material/Pending";
|
import PendingIcon from "@mui/icons-material/Pending";
|
||||||
|
|
||||||
const RequestCard = ({ item }) => {
|
const RequestCard = ({ item, id }) => {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
return (
|
return (
|
||||||
<Grid item xs={12} lg={6} xl={4}>
|
<Grid item xs={12} lg={6} xl={4}>
|
||||||
@@ -115,13 +115,13 @@ const RequestCard = ({ item }) => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
{item.state_id === 17 ? (
|
{item.state_id === 17 ? (
|
||||||
<Button variant="contained" color="warning" sx={{ alignSelf: "flex-end", mt: 2 }}>
|
<Button variant="contained" color="warning" sx={{ alignSelf: "flex-end", mt: 2 }}>
|
||||||
<LinkRouting underline="none" color="inherit" href={`/dashboard/navgan/${item.id}/show`}>
|
<LinkRouting underline="none" color="inherit" href={`/dashboard/${id}/${item.id}/show`}>
|
||||||
{t("LoanFollowUp.loan_edit")}
|
{t("LoanFollowUp.loan_edit")}
|
||||||
</LinkRouting>
|
</LinkRouting>
|
||||||
</Button>
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
<Button variant="contained" color="primary" sx={{ alignSelf: "flex-end", mt: 2 }}>
|
<Button variant="contained" color="primary" sx={{ alignSelf: "flex-end", mt: 2 }}>
|
||||||
<LinkRouting underline="none" color="inherit" href={`/dashboard/navgan/${item.id}/show`}>
|
<LinkRouting underline="none" color="inherit" href={`/dashboard/${id}/${item.id}/show`}>
|
||||||
{t("LoanFollowUp.loan_details")}
|
{t("LoanFollowUp.loan_details")}
|
||||||
</LinkRouting>
|
</LinkRouting>
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Box, Chip, Divider, Grid, Skeleton, Stack, Typography } from "@mui/material";
|
import { Box, Chip, Divider, Grid, Skeleton, Stack, Typography } from "@mui/material";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { SHOW_LOAN_REQUEST_NAVGAN, SHOW_LOAN_REQUEST_REFAHI } from "@/core/data/apiRoutes";
|
import { SHOW_LOAN_REQUEST_NAVGAN, SHOW_LOAN_REQUEST_REFAHI } from "@/core/data/apiRoutes";
|
||||||
import RequestCard from "@/components/dashboard/followUp-loan/RequestCard";
|
import RequestCard from "./RequestCard";
|
||||||
import { FullPageLayout, useRequest } from "@witel/webapp-builder";
|
import { FullPageLayout, useRequest } from "@witel/webapp-builder";
|
||||||
import DirectionsCarIcon from "@mui/icons-material/DirectionsCar";
|
import DirectionsCarIcon from "@mui/icons-material/DirectionsCar";
|
||||||
import VolunteerActivismIcon from "@mui/icons-material/VolunteerActivism";
|
import VolunteerActivismIcon from "@mui/icons-material/VolunteerActivism";
|
||||||
@@ -74,7 +74,7 @@ const LoanFollowUpComponent = () => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
<Grid container spacing={2} sx={{ justifyContent: "center" }}>
|
<Grid container spacing={2} sx={{ justifyContent: "center" }}>
|
||||||
{navganFollowUpList.map((item) => (
|
{navganFollowUpList.map((item) => (
|
||||||
<RequestCard item={item} key={item.id} />
|
<RequestCard id={"navgan"} item={item} key={item.id} />
|
||||||
))}
|
))}
|
||||||
</Grid>
|
</Grid>
|
||||||
</>
|
</>
|
||||||
@@ -124,7 +124,7 @@ const LoanFollowUpComponent = () => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
<Grid container spacing={2} sx={{ justifyContent: "center" }}>
|
<Grid container spacing={2} sx={{ justifyContent: "center" }}>
|
||||||
{refahiFollowUpList.map((item) => (
|
{refahiFollowUpList.map((item) => (
|
||||||
<RequestCard item={item} key={item.id} />
|
<RequestCard id={"refahi"} item={item} key={item.id} />
|
||||||
))}
|
))}
|
||||||
</Grid>
|
</Grid>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import { useTranslations } from "next-intl";
|
import { CenterLayout } from "@witel/webapp-builder";
|
||||||
import { CenterLayout, useUser } from "@witel/webapp-builder";
|
|
||||||
import ShowLoanForm from "@/components/dashboard/navgan/show/form";
|
import ShowLoanForm from "@/components/dashboard/navgan/show/form";
|
||||||
|
|
||||||
const ShowLoan = () => {
|
const ShowLoan = () => {
|
||||||
const t = useTranslations();
|
|
||||||
const { user } = useUser();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CenterLayout>
|
<CenterLayout>
|
||||||
<ShowLoanForm />
|
<ShowLoanForm />
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import { Button, Card, CardActions, CardContent, Stack, Typography } from "@mui/material";
|
import { Button, Card, CardActions, CardContent, Stack, Typography } from "@mui/material";
|
||||||
import DirectionsCarIcon from "@mui/icons-material/DirectionsCar";
|
|
||||||
import VolunteerActivismIcon from "@mui/icons-material/VolunteerActivism";
|
|
||||||
import BuildIcon from "@mui/icons-material/Build";
|
import BuildIcon from "@mui/icons-material/Build";
|
||||||
import MapsHomeWorkIcon from "@mui/icons-material/MapsHomeWork";
|
import MapsHomeWorkIcon from "@mui/icons-material/MapsHomeWork";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
import { useReducer, useState } from "react";
|
||||||
|
import { useTranslations } from "next-intl";
|
||||||
|
import * as React from "react";
|
||||||
|
import { Stack, Step, StepLabel, Stepper } from "@mui/material";
|
||||||
|
import BuldToggleRealLegal from "./BuildToggleRealLegal";
|
||||||
|
import BuildProjectInfo from "./BuildProjectInfo";
|
||||||
|
import BuildRequestDetail from "./BuildRequestDetail";
|
||||||
|
import useLimitedProvince from "@/lib/app/hooks/useLimitedProvince";
|
||||||
|
|
||||||
|
const BuildFormController = ({ handleSubmit, dispatch, state, submitting, editDisabled }) => {
|
||||||
|
const t = useTranslations();
|
||||||
|
const [activeStep, setActiveStep] = useState(0);
|
||||||
|
const { provinceList, isLoadingProvinceList, errorProvinceList } = useLimitedProvince();
|
||||||
|
const steps = [
|
||||||
|
t("RefahiLoanRequest.step_personal_info"),
|
||||||
|
t("RefahiLoanRequest.step_project_info"),
|
||||||
|
t("RefahiLoanRequest.step_contact_info"),
|
||||||
|
];
|
||||||
|
const handleNext = () => setActiveStep((prev) => prev + 1);
|
||||||
|
const handleBack = () => setActiveStep((prev) => prev - 1);
|
||||||
|
return (
|
||||||
|
<Stack>
|
||||||
|
<Stepper sx={{ my: 2 }} activeStep={activeStep} alternativeLabel>
|
||||||
|
{steps.map((label, index) => (
|
||||||
|
<Step key={index}>
|
||||||
|
<StepLabel>{label}</StepLabel>
|
||||||
|
</Step>
|
||||||
|
))}
|
||||||
|
</Stepper>
|
||||||
|
{activeStep === 0 && (
|
||||||
|
<BuldToggleRealLegal
|
||||||
|
provinceList={provinceList}
|
||||||
|
isLoadingProvinceList={isLoadingProvinceList}
|
||||||
|
errorProvinceList={errorProvinceList}
|
||||||
|
state={state}
|
||||||
|
dispatch={dispatch}
|
||||||
|
handleNext={handleNext}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{activeStep === 1 && (
|
||||||
|
<BuildProjectInfo
|
||||||
|
provinceList={provinceList}
|
||||||
|
isLoadingProvinceList={isLoadingProvinceList}
|
||||||
|
errorProvinceList={errorProvinceList}
|
||||||
|
state={state}
|
||||||
|
dispatch={dispatch}
|
||||||
|
handleBack={handleBack}
|
||||||
|
handleNext={handleNext}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{activeStep === 2 && (
|
||||||
|
<BuildRequestDetail
|
||||||
|
state={state}
|
||||||
|
handleBack={handleBack}
|
||||||
|
handleSubmit={handleSubmit}
|
||||||
|
submitting={submitting}
|
||||||
|
editDisabled={editDisabled}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default BuildFormController;
|
||||||
@@ -163,12 +163,12 @@ const BuildProjectInfo = ({
|
|||||||
selectors={[
|
selectors={[
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
value: 1,
|
value: 0,
|
||||||
name: "رفت",
|
name: "رفت",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
value: 0,
|
value: 1,
|
||||||
name: "برگشت",
|
name: "برگشت",
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
|
|||||||
@@ -8,17 +8,9 @@ import * as Yup from "yup";
|
|||||||
import { useFormik } from "formik";
|
import { useFormik } from "formik";
|
||||||
import PickerWithDynamicField from "@/core/components/EditedDatePicker";
|
import PickerWithDynamicField from "@/core/components/EditedDatePicker";
|
||||||
import UploadImage from "./UploadImage";
|
import UploadImage from "./UploadImage";
|
||||||
import { useRequest, useUser } from "@witel/webapp-builder";
|
|
||||||
import { SEND_LOAN_REQUEST_REFAHI } from "@/core/data/apiRoutes";
|
|
||||||
import { useState } from "react";
|
|
||||||
import { useRouter } from "next/router";
|
|
||||||
|
|
||||||
const BuildRequestDetail = ({ state, handleBack, setFinishRefahiLoanRequest, dispatch }) => {
|
const BuildRequestDetail = ({ state, handleBack, handleSubmit, submitting, editDisabled }) => {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
const [submitting, setSubmitting] = useState(false);
|
|
||||||
const requestServer = useRequest();
|
|
||||||
const { getUser, changeUser } = useUser();
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const initialValues = {
|
const initialValues = {
|
||||||
requested_facility_amount: state.requested_facility_amount,
|
requested_facility_amount: state.requested_facility_amount,
|
||||||
@@ -75,64 +67,6 @@ const BuildRequestDetail = ({ state, handleBack, setFinishRefahiLoanRequest, dis
|
|||||||
.required(t("LoanRequest.checkbox_required")),
|
.required(t("LoanRequest.checkbox_required")),
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleSubmit = async (values) => {
|
|
||||||
let updatedState = { ...state, ...values };
|
|
||||||
dispatch({ type: "SET_REQUEST_INFO", requestInfo: values });
|
|
||||||
const formData = new FormData();
|
|
||||||
const is_legal_person = updatedState.person_type === "real" ? 0 : 1;
|
|
||||||
delete updatedState.person_type;
|
|
||||||
if (updatedState.national_serial_number_or_tracking_code === "national_serial_number") {
|
|
||||||
formData.append("national_serial_number", updatedState.national_serial_number);
|
|
||||||
delete updatedState.national_card_tracking_code;
|
|
||||||
} else {
|
|
||||||
formData.append("national_tracking_code", updatedState.national_card_tracking_code);
|
|
||||||
delete updatedState.national_serial_number;
|
|
||||||
}
|
|
||||||
delete updatedState.national_serial_number_or_tracking_code;
|
|
||||||
delete updatedState.checkedBox;
|
|
||||||
formData.append("is_legal_person", is_legal_person);
|
|
||||||
|
|
||||||
updatedState = {
|
|
||||||
...updatedState,
|
|
||||||
birthday: updatedState.birthday.locale("en").format("YYYY-MM-DD"),
|
|
||||||
basic_approval_renewal_date: updatedState.basic_approval_renewal_date.locale("en").format("YYYY-MM-DD"),
|
|
||||||
company_register_date: updatedState.company_register_date
|
|
||||||
? updatedState.company_register_date.locale("en").format("YYYY-MM-DD")
|
|
||||||
: "",
|
|
||||||
facility_usage_history: updatedState.facility_usage_history ? 1 : 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
Object.keys(updatedState).forEach((key) => {
|
|
||||||
if (updatedState[key] !== null && updatedState[key] !== undefined) {
|
|
||||||
formData.append(key, updatedState[key]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (!is_legal_person) {
|
|
||||||
formData.delete("company_register_date");
|
|
||||||
formData.delete("shenase_meli");
|
|
||||||
formData.delete("register_number");
|
|
||||||
formData.delete("company_name");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
setSubmitting(true);
|
|
||||||
await requestServer(SEND_LOAN_REQUEST_REFAHI, "post", {
|
|
||||||
auth: true,
|
|
||||||
notification: true,
|
|
||||||
data: formData,
|
|
||||||
});
|
|
||||||
// router.replace("/dashboard/followUp-loan");
|
|
||||||
getUser((data) => {
|
|
||||||
changeUser(data);
|
|
||||||
setFinishRefahiLoanRequest(true);
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error submitting request:", error);
|
|
||||||
} finally {
|
|
||||||
setSubmitting(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const formik = useFormik({
|
const formik = useFormik({
|
||||||
initialValues,
|
initialValues,
|
||||||
validationSchema,
|
validationSchema,
|
||||||
@@ -452,16 +386,18 @@ const BuildRequestDetail = ({ state, handleBack, setFinishRefahiLoanRequest, dis
|
|||||||
>
|
>
|
||||||
{t("RefahiLoanRequest.back-button")}
|
{t("RefahiLoanRequest.back-button")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
{editDisabled === 17 && (
|
||||||
onClick={formik.handleSubmit}
|
<Button
|
||||||
endIcon={<BeenhereIcon />}
|
onClick={formik.handleSubmit}
|
||||||
variant={"contained"}
|
endIcon={<BeenhereIcon />}
|
||||||
size={"large"}
|
variant={"contained"}
|
||||||
color={"primary"}
|
size={"large"}
|
||||||
disabled={submitting}
|
color={"primary"}
|
||||||
>
|
disabled={submitting}
|
||||||
{t("RefahiLoanRequest.submit-button")}
|
>
|
||||||
</Button>
|
{t("RefahiLoanRequest.submit-button")}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ import * as React from "react";
|
|||||||
import UploadFileNotification from "@/core/components/notifications/UploadFileNotification";
|
import UploadFileNotification from "@/core/components/notifications/UploadFileNotification";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { FormHelperText, Stack } from "@mui/material";
|
import { FormHelperText } from "@mui/material";
|
||||||
|
|
||||||
const UploadImage = ({ formik, fieldName }) => {
|
const UploadImage = ({ formik, fieldName }) => {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
const [selectedImage, setSelectedImage] = useState("");
|
const [selectedImage, setSelectedImage] = useState(formik.values[fieldName] ? formik.values[fieldName] : "");
|
||||||
const [fileType, setFileType] = useState(null);
|
const [fileType, setFileType] = useState(formik.values[fieldName] ? "image/" : null);
|
||||||
const [fileName, setFileName] = useState(null);
|
const [fileName, setFileName] = useState(null);
|
||||||
const [showAddIcon, setShowAddIcon] = useState(true);
|
const [showAddIcon, setShowAddIcon] = useState(!formik.values[fieldName]);
|
||||||
const handleUploadChange = (event) => {
|
const handleUploadChange = (event) => {
|
||||||
const uploadedFile = event.target?.files?.[0];
|
const uploadedFile = event.target?.files?.[0];
|
||||||
if (uploadedFile) {
|
if (uploadedFile) {
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
import { useReducer, useState } from "react";
|
import { useReducer, useState } from "react";
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { Stack, Step, StepLabel, Stepper } from "@mui/material";
|
import { SEND_LOAN_REQUEST_REFAHI } from "@/core/data/apiRoutes";
|
||||||
import BuldToggleRealLegal from "./BuildToggleRealLegal";
|
import { useRequest, useUser } from "@witel/webapp-builder";
|
||||||
import BuildProjectInfo from "./BuildProjectInfo";
|
import BuildFormController from "./BuildFormController";
|
||||||
import BuildRequestDetail from "./BuildRequestDetail";
|
|
||||||
import useLimitedProvince from "@/lib/app/hooks/useLimitedProvince";
|
|
||||||
|
|
||||||
const _data = {
|
const _data = {
|
||||||
person_type: "real",
|
person_type: "real",
|
||||||
@@ -68,56 +65,77 @@ const reducer = (state, action) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const BuildForm = ({ setFinishRefahiLoanRequest }) => {
|
const BuildForm = ({ setFinishRefahiLoanRequest }) => {
|
||||||
const t = useTranslations();
|
const [submitting, setSubmitting] = useState(false);
|
||||||
const [activeStep, setActiveStep] = useState(0);
|
|
||||||
const [state, dispatch] = useReducer(reducer, _data);
|
const [state, dispatch] = useReducer(reducer, _data);
|
||||||
const { provinceList, isLoadingProvinceList, errorProvinceList } = useLimitedProvince();
|
const requestServer = useRequest();
|
||||||
const steps = [
|
const { getUser, changeUser } = useUser();
|
||||||
t("RefahiLoanRequest.step_personal_info"),
|
|
||||||
t("RefahiLoanRequest.step_project_info"),
|
const handleSubmit = async (values) => {
|
||||||
t("RefahiLoanRequest.step_contact_info"),
|
let updatedState = { ...state, ...values };
|
||||||
];
|
dispatch({ type: "SET_REQUEST_INFO", requestInfo: values });
|
||||||
const handleNext = () => setActiveStep((prev) => prev + 1);
|
const formData = new FormData();
|
||||||
const handleBack = () => setActiveStep((prev) => prev - 1);
|
const is_legal_person = updatedState.person_type === "real" ? 0 : 1;
|
||||||
|
delete updatedState.person_type;
|
||||||
|
if (updatedState.national_serial_number_or_tracking_code === "national_serial_number") {
|
||||||
|
formData.append("national_serial_number", updatedState.national_serial_number);
|
||||||
|
delete updatedState.national_card_tracking_code;
|
||||||
|
} else {
|
||||||
|
formData.append("national_tracking_code", updatedState.national_card_tracking_code);
|
||||||
|
delete updatedState.national_serial_number;
|
||||||
|
}
|
||||||
|
delete updatedState.national_serial_number_or_tracking_code;
|
||||||
|
delete updatedState.checkedBox;
|
||||||
|
formData.append("is_legal_person", is_legal_person);
|
||||||
|
|
||||||
|
updatedState = {
|
||||||
|
...updatedState,
|
||||||
|
birthday: updatedState.birthday.locale("en").format("YYYY-MM-DD"),
|
||||||
|
basic_approval_renewal_date: updatedState.basic_approval_renewal_date.locale("en").format("YYYY-MM-DD"),
|
||||||
|
company_register_date: updatedState.company_register_date
|
||||||
|
? updatedState.company_register_date.locale("en").format("YYYY-MM-DD")
|
||||||
|
: "",
|
||||||
|
facility_usage_history: updatedState.facility_usage_history ? 1 : 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
Object.keys(updatedState).forEach((key) => {
|
||||||
|
if (updatedState[key] !== null && updatedState[key] !== undefined) {
|
||||||
|
formData.append(key, updatedState[key]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!is_legal_person) {
|
||||||
|
formData.delete("company_register_date");
|
||||||
|
formData.delete("shenase_meli");
|
||||||
|
formData.delete("register_number");
|
||||||
|
formData.delete("company_name");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
setSubmitting(true);
|
||||||
|
await requestServer(SEND_LOAN_REQUEST_REFAHI, "post", {
|
||||||
|
auth: true,
|
||||||
|
notification: true,
|
||||||
|
data: formData,
|
||||||
|
});
|
||||||
|
getUser((data) => {
|
||||||
|
changeUser(data);
|
||||||
|
setFinishRefahiLoanRequest(true);
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error submitting request:", error);
|
||||||
|
} finally {
|
||||||
|
setSubmitting(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<Stack>
|
<>
|
||||||
<Stepper sx={{ my: 2 }} activeStep={activeStep} alternativeLabel>
|
<BuildFormController
|
||||||
{steps.map((label, index) => (
|
submitting={submitting}
|
||||||
<Step key={index}>
|
state={state}
|
||||||
<StepLabel>{label}</StepLabel>
|
dispatch={dispatch}
|
||||||
</Step>
|
handleSubmit={handleSubmit}
|
||||||
))}
|
setFinishRefahiLoanRequest={setFinishRefahiLoanRequest}
|
||||||
</Stepper>
|
/>
|
||||||
{activeStep === 0 && (
|
</>
|
||||||
<BuldToggleRealLegal
|
|
||||||
provinceList={provinceList}
|
|
||||||
isLoadingProvinceList={isLoadingProvinceList}
|
|
||||||
errorProvinceList={errorProvinceList}
|
|
||||||
state={state}
|
|
||||||
dispatch={dispatch}
|
|
||||||
handleNext={handleNext}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{activeStep === 1 && (
|
|
||||||
<BuildProjectInfo
|
|
||||||
provinceList={provinceList}
|
|
||||||
isLoadingProvinceList={isLoadingProvinceList}
|
|
||||||
errorProvinceList={errorProvinceList}
|
|
||||||
state={state}
|
|
||||||
dispatch={dispatch}
|
|
||||||
handleBack={handleBack}
|
|
||||||
handleNext={handleNext}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{activeStep === 2 && (
|
|
||||||
<BuildRequestDetail
|
|
||||||
state={state}
|
|
||||||
handleBack={handleBack}
|
|
||||||
dispatch={dispatch}
|
|
||||||
setFinishRefahiLoanRequest={setFinishRefahiLoanRequest}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Stack>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
export default BuildForm;
|
export default BuildForm;
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import { useReducer, useState } from "react";
|
||||||
|
import { useTranslations } from "next-intl";
|
||||||
|
import * as React from "react";
|
||||||
|
import { Stack, Step, StepLabel, Stepper } from "@mui/material";
|
||||||
|
import RestoreProjectInfo from "./RestoreProjectInfo";
|
||||||
|
import RestoreRequestDetail from "./RestoreRequestDetail";
|
||||||
|
import RestoreToggleRealLegal from "./RestoreToggleRealLegal";
|
||||||
|
import useLimitedProvince from "@/lib/app/hooks/useLimitedProvince";
|
||||||
|
|
||||||
|
const RestoreFormController = ({ state, dispatch, handleSubmit, submitting, editDisabled }) => {
|
||||||
|
const t = useTranslations();
|
||||||
|
const [activeStep, setActiveStep] = useState(0);
|
||||||
|
const { provinceList, isLoadingProvinceList, errorProvinceList } = useLimitedProvince();
|
||||||
|
const steps = [
|
||||||
|
t("RefahiLoanRequest.step_personal_info"),
|
||||||
|
t("RefahiLoanRequest.step_project_info"),
|
||||||
|
t("RefahiLoanRequest.step_contact_info"),
|
||||||
|
];
|
||||||
|
const handleNext = () => setActiveStep((prev) => prev + 1);
|
||||||
|
const handleBack = () => setActiveStep((prev) => prev - 1);
|
||||||
|
return (
|
||||||
|
<Stack>
|
||||||
|
<Stepper sx={{ my: 2 }} activeStep={activeStep} alternativeLabel>
|
||||||
|
{steps.map((label, index) => (
|
||||||
|
<Step key={index}>
|
||||||
|
<StepLabel>{label}</StepLabel>
|
||||||
|
</Step>
|
||||||
|
))}
|
||||||
|
</Stepper>
|
||||||
|
{activeStep === 0 && (
|
||||||
|
<RestoreToggleRealLegal
|
||||||
|
provinceList={provinceList}
|
||||||
|
isLoadingProvinceList={isLoadingProvinceList}
|
||||||
|
errorProvinceList={errorProvinceList}
|
||||||
|
state={state}
|
||||||
|
dispatch={dispatch}
|
||||||
|
handleNext={handleNext}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{activeStep === 1 && (
|
||||||
|
<RestoreProjectInfo
|
||||||
|
provinceList={provinceList}
|
||||||
|
isLoadingProvinceList={isLoadingProvinceList}
|
||||||
|
errorProvinceList={errorProvinceList}
|
||||||
|
state={state}
|
||||||
|
dispatch={dispatch}
|
||||||
|
handleBack={handleBack}
|
||||||
|
handleNext={handleNext}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{activeStep === 2 && (
|
||||||
|
<RestoreRequestDetail
|
||||||
|
state={state}
|
||||||
|
dispatch={dispatch}
|
||||||
|
handleBack={handleBack}
|
||||||
|
handleSubmit={handleSubmit}
|
||||||
|
submitting={submitting}
|
||||||
|
editDisabled={editDisabled}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default RestoreFormController;
|
||||||
@@ -163,12 +163,12 @@ const RestoreProjectInfo = ({
|
|||||||
selectors={[
|
selectors={[
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
value: 1,
|
value: 0,
|
||||||
name: "رفت",
|
name: "رفت",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
value: 0,
|
value: 1,
|
||||||
name: "برگشت",
|
name: "برگشت",
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
|
|||||||
@@ -8,17 +8,9 @@ import * as Yup from "yup";
|
|||||||
import { useFormik } from "formik";
|
import { useFormik } from "formik";
|
||||||
import PickerWithDynamicField from "@/core/components/EditedDatePicker";
|
import PickerWithDynamicField from "@/core/components/EditedDatePicker";
|
||||||
import UploadImage from "@/components/dashboard/refahi/add-request-loan/forms/BuildForm/UploadImage";
|
import UploadImage from "@/components/dashboard/refahi/add-request-loan/forms/BuildForm/UploadImage";
|
||||||
import { SEND_LOAN_REQUEST_REFAHI } from "@/core/data/apiRoutes";
|
|
||||||
import { useState } from "react";
|
|
||||||
import { useRequest, useUser } from "@witel/webapp-builder";
|
|
||||||
import { useRouter } from "next/router";
|
|
||||||
|
|
||||||
const RestoreRequestDetail = ({ state, handleBack, dispatch, setFinishRefahiLoanRequest }) => {
|
const RestoreRequestDetail = ({ state, handleBack, handleSubmit, submitting, editDisabled }) => {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
const [submitting, setSubmitting] = useState(false);
|
|
||||||
const requestServer = useRequest();
|
|
||||||
const { getUser, changeUser } = useUser();
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const initialValues = {
|
const initialValues = {
|
||||||
requested_facility_amount: state.requested_facility_amount,
|
requested_facility_amount: state.requested_facility_amount,
|
||||||
@@ -68,66 +60,6 @@ const RestoreRequestDetail = ({ state, handleBack, dispatch, setFinishRefahiLoan
|
|||||||
.oneOf([true], t("LoanRequest.checkbox_required"))
|
.oneOf([true], t("LoanRequest.checkbox_required"))
|
||||||
.required(t("LoanRequest.checkbox_required")),
|
.required(t("LoanRequest.checkbox_required")),
|
||||||
});
|
});
|
||||||
const handleSubmit = async (values, props) => {
|
|
||||||
let updatedState = { ...state, ...values };
|
|
||||||
dispatch({ type: "SET_REQUEST_INFO", requestInfo: values });
|
|
||||||
const formData = new FormData();
|
|
||||||
const is_legal_person = updatedState.person_type === "real" ? 0 : 1;
|
|
||||||
delete updatedState.person_type;
|
|
||||||
if (updatedState.national_serial_number_or_tracking_code === "national_serial_number") {
|
|
||||||
formData.append("national_serial_number", updatedState.national_serial_number);
|
|
||||||
delete updatedState.national_card_tracking_code;
|
|
||||||
} else {
|
|
||||||
formData.append("national_tracking_code", updatedState.national_card_tracking_code);
|
|
||||||
delete updatedState.national_serial_number;
|
|
||||||
}
|
|
||||||
delete updatedState.national_serial_number_or_tracking_code;
|
|
||||||
delete updatedState.checkedBox;
|
|
||||||
formData.append("is_legal_person", is_legal_person);
|
|
||||||
|
|
||||||
updatedState = {
|
|
||||||
...updatedState,
|
|
||||||
birthday: updatedState.birthday.locale("en").format("YYYY-MM-DD"),
|
|
||||||
exploitation_license_renewal_date: updatedState.exploitation_license_renewal_date
|
|
||||||
.locale("en")
|
|
||||||
.format("YYYY-MM-DD"),
|
|
||||||
exploitation_date: updatedState.exploitation_date.locale("en").format("YYYY-MM-DD"),
|
|
||||||
company_register_date: updatedState.company_register_date
|
|
||||||
? updatedState.company_register_date.locale("en").format("YYYY-MM-DD")
|
|
||||||
: "",
|
|
||||||
facility_usage_history: updatedState.facility_usage_history ? 1 : 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
Object.keys(updatedState).forEach((key) => {
|
|
||||||
if (updatedState[key] !== null && updatedState[key] !== undefined) {
|
|
||||||
formData.append(key, updatedState[key]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (!is_legal_person) {
|
|
||||||
formData.delete("company_register_date");
|
|
||||||
formData.delete("shenase_meli");
|
|
||||||
formData.delete("register_number");
|
|
||||||
formData.delete("company_name");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
setSubmitting(true);
|
|
||||||
await requestServer(SEND_LOAN_REQUEST_REFAHI, "post", {
|
|
||||||
auth: true,
|
|
||||||
notification: true,
|
|
||||||
data: formData,
|
|
||||||
});
|
|
||||||
// router.replace("/dashboard/followUp-loan");
|
|
||||||
getUser((data) => {
|
|
||||||
changeUser(data);
|
|
||||||
setFinishRefahiLoanRequest(true);
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error submitting request:", error);
|
|
||||||
} finally {
|
|
||||||
setSubmitting(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const formik = useFormik({
|
const formik = useFormik({
|
||||||
initialValues,
|
initialValues,
|
||||||
@@ -400,16 +332,18 @@ const RestoreRequestDetail = ({ state, handleBack, dispatch, setFinishRefahiLoan
|
|||||||
>
|
>
|
||||||
{t("RefahiLoanRequest.back-button")}
|
{t("RefahiLoanRequest.back-button")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
{editDisabled === 17 && (
|
||||||
onClick={formik.handleSubmit}
|
<Button
|
||||||
endIcon={<BeenhereIcon />}
|
onClick={formik.handleSubmit}
|
||||||
variant={"contained"}
|
endIcon={<BeenhereIcon />}
|
||||||
size={"large"}
|
variant={"contained"}
|
||||||
color={"primary"}
|
size={"large"}
|
||||||
disabled={submitting}
|
color={"primary"}
|
||||||
>
|
disabled={submitting}
|
||||||
{t("RefahiLoanRequest.submit-button")}
|
>
|
||||||
</Button>
|
{t("RefahiLoanRequest.submit-button")}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import { useReducer, useState } from "react";
|
import { useReducer, useState } from "react";
|
||||||
import { useTranslations } from "next-intl";
|
import RestoreFormController from "./RestoreFormController";
|
||||||
import * as React from "react";
|
import { useRequest, useUser } from "@witel/webapp-builder";
|
||||||
import { Stack, Step, StepLabel, Stepper } from "@mui/material";
|
import { SEND_LOAN_REQUEST_REFAHI } from "@/core/data/apiRoutes";
|
||||||
import RestoreProjectInfo from "./RestoreProjectInfo";
|
|
||||||
import RestoreRequestDetail from "./RestoreRequestDetail";
|
|
||||||
import RestoreToggleRealLegal from "./RestoreToggleRealLegal";
|
|
||||||
import useLimitedProvince from "@/lib/app/hooks/useLimitedProvince";
|
|
||||||
|
|
||||||
const _data = {
|
const _data = {
|
||||||
person_type: "real",
|
person_type: "real",
|
||||||
@@ -67,56 +63,80 @@ const reducer = (state, action) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const RestoreForm = ({ setFinishRefahiLoanRequest }) => {
|
const RestoreForm = ({ setFinishRefahiLoanRequest }) => {
|
||||||
const t = useTranslations();
|
const [submitting, setSubmitting] = useState(false);
|
||||||
const [activeStep, setActiveStep] = useState(0);
|
|
||||||
const { provinceList, isLoadingProvinceList, errorProvinceList } = useLimitedProvince();
|
|
||||||
const [state, dispatch] = useReducer(reducer, _data);
|
const [state, dispatch] = useReducer(reducer, _data);
|
||||||
const steps = [
|
const requestServer = useRequest();
|
||||||
t("RefahiLoanRequest.step_personal_info"),
|
const { getUser, changeUser } = useUser();
|
||||||
t("RefahiLoanRequest.step_project_info"),
|
|
||||||
t("RefahiLoanRequest.step_contact_info"),
|
const handleSubmit = async (values, props) => {
|
||||||
];
|
let updatedState = { ...state, ...values };
|
||||||
const handleNext = () => setActiveStep((prev) => prev + 1);
|
dispatch({ type: "SET_REQUEST_INFO", requestInfo: values });
|
||||||
const handleBack = () => setActiveStep((prev) => prev - 1);
|
const formData = new FormData();
|
||||||
|
const is_legal_person = updatedState.person_type === "real" ? 0 : 1;
|
||||||
|
delete updatedState.person_type;
|
||||||
|
if (updatedState.national_serial_number_or_tracking_code === "national_serial_number") {
|
||||||
|
formData.append("national_serial_number", updatedState.national_serial_number);
|
||||||
|
delete updatedState.national_card_tracking_code;
|
||||||
|
} else {
|
||||||
|
formData.append("national_tracking_code", updatedState.national_card_tracking_code);
|
||||||
|
delete updatedState.national_serial_number;
|
||||||
|
}
|
||||||
|
delete updatedState.national_serial_number_or_tracking_code;
|
||||||
|
delete updatedState.checkedBox;
|
||||||
|
formData.append("is_legal_person", is_legal_person);
|
||||||
|
|
||||||
|
updatedState = {
|
||||||
|
...updatedState,
|
||||||
|
birthday: updatedState.birthday.locale("en").format("YYYY-MM-DD"),
|
||||||
|
exploitation_license_renewal_date: updatedState.exploitation_license_renewal_date
|
||||||
|
.locale("en")
|
||||||
|
.format("YYYY-MM-DD"),
|
||||||
|
exploitation_date: updatedState.exploitation_date.locale("en").format("YYYY-MM-DD"),
|
||||||
|
company_register_date: updatedState.company_register_date
|
||||||
|
? updatedState.company_register_date.locale("en").format("YYYY-MM-DD")
|
||||||
|
: "",
|
||||||
|
facility_usage_history: updatedState.facility_usage_history ? 1 : 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
Object.keys(updatedState).forEach((key) => {
|
||||||
|
if (updatedState[key] !== null && updatedState[key] !== undefined) {
|
||||||
|
formData.append(key, updatedState[key]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!is_legal_person) {
|
||||||
|
formData.delete("company_register_date");
|
||||||
|
formData.delete("shenase_meli");
|
||||||
|
formData.delete("register_number");
|
||||||
|
formData.delete("company_name");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
setSubmitting(true);
|
||||||
|
await requestServer(SEND_LOAN_REQUEST_REFAHI, "post", {
|
||||||
|
auth: true,
|
||||||
|
notification: true,
|
||||||
|
data: formData,
|
||||||
|
});
|
||||||
|
getUser((data) => {
|
||||||
|
changeUser(data);
|
||||||
|
setFinishRefahiLoanRequest(true);
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error submitting request:", error);
|
||||||
|
} finally {
|
||||||
|
setSubmitting(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack>
|
<>
|
||||||
<Stepper sx={{ my: 2 }} activeStep={activeStep} alternativeLabel>
|
<RestoreFormController
|
||||||
{steps.map((label, index) => (
|
handleSubmit={handleSubmit}
|
||||||
<Step key={index}>
|
dispatch={dispatch}
|
||||||
<StepLabel>{label}</StepLabel>
|
submitting={submitting}
|
||||||
</Step>
|
state={state}
|
||||||
))}
|
/>
|
||||||
</Stepper>
|
</>
|
||||||
{activeStep === 0 && (
|
|
||||||
<RestoreToggleRealLegal
|
|
||||||
provinceList={provinceList}
|
|
||||||
isLoadingProvinceList={isLoadingProvinceList}
|
|
||||||
errorProvinceList={errorProvinceList}
|
|
||||||
state={state}
|
|
||||||
dispatch={dispatch}
|
|
||||||
handleNext={handleNext}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{activeStep === 1 && (
|
|
||||||
<RestoreProjectInfo
|
|
||||||
provinceList={provinceList}
|
|
||||||
isLoadingProvinceList={isLoadingProvinceList}
|
|
||||||
errorProvinceList={errorProvinceList}
|
|
||||||
state={state}
|
|
||||||
dispatch={dispatch}
|
|
||||||
handleBack={handleBack}
|
|
||||||
handleNext={handleNext}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{activeStep === 2 && (
|
|
||||||
<RestoreRequestDetail
|
|
||||||
state={state}
|
|
||||||
dispatch={dispatch}
|
|
||||||
handleBack={handleBack}
|
|
||||||
setFinishRefahiLoanRequest={setFinishRefahiLoanRequest}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Stack>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
export default RestoreForm;
|
export default RestoreForm;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ const AddRequestLoan = () => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
<DoneIcon color={"success"} />
|
<DoneIcon color={"success"} />
|
||||||
</Stack>
|
</Stack>
|
||||||
<Button variant={"contained"} component={NextLinkComposed} to={"/dashboard/refahi/followUp-loan"}>
|
<Button variant={"contained"} component={NextLinkComposed} to={"/dashboard/followUp-loan"}>
|
||||||
{t("LoanRequest.back_to_dashboard")}
|
{t("LoanRequest.back_to_dashboard")}
|
||||||
</Button>
|
</Button>
|
||||||
</CenterLayout>
|
</CenterLayout>
|
||||||
|
|||||||
126
src/components/dashboard/refahi/show/form/index.jsx
Normal file
126
src/components/dashboard/refahi/show/form/index.jsx
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
import { useReducer, useState } from "react";
|
||||||
|
import { useRequest, useUser } from "@witel/webapp-builder";
|
||||||
|
import BuildFormController from "@/components/dashboard/refahi/add-request-loan/forms/BuildForm/BuildFormController";
|
||||||
|
import RestoreFormController from "@/components/dashboard/refahi/add-request-loan/forms/RestoreForm/RestoreFormController";
|
||||||
|
import { UPDATE_LOAN_REFAHI } from "@/core/data/apiRoutes";
|
||||||
|
import { useRouter } from "next/router";
|
||||||
|
|
||||||
|
const reducer = (state, action) => {
|
||||||
|
switch (action.type) {
|
||||||
|
case "SET_PERSONAL_INFO":
|
||||||
|
return { ...state, ...action.personalInfo };
|
||||||
|
case "SET_PROJECT_INFO":
|
||||||
|
return { ...state, ...action.projectInfo };
|
||||||
|
case "SET_REQUEST_INFO":
|
||||||
|
return { ...state, ...action.requestInfo };
|
||||||
|
case "SET_PERSON_TYPE":
|
||||||
|
return { ...state, person_type: action.person_type };
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const ShowLoanForm = ({ defaultData, refahi_type, queryID, editDisabled }) => {
|
||||||
|
const [submitting, setSubmitting] = useState(false);
|
||||||
|
const requestServer = useRequest();
|
||||||
|
const router = useRouter();
|
||||||
|
const { getUser, changeUser } = useUser();
|
||||||
|
const [state, dispatch] = useReducer(reducer, defaultData);
|
||||||
|
|
||||||
|
const handleSubmit = async (values) => {
|
||||||
|
let updatedState = { ...state, ...values };
|
||||||
|
dispatch({ type: "SET_REQUEST_INFO", requestInfo: values });
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
const is_legal_person = updatedState.person_type === "real" ? 0 : 1;
|
||||||
|
delete updatedState.person_type;
|
||||||
|
|
||||||
|
if (updatedState.national_serial_number_or_tracking_code === "national_serial_number") {
|
||||||
|
formData.append("national_serial_number", updatedState.national_serial_number);
|
||||||
|
delete updatedState.national_card_tracking_code;
|
||||||
|
} else {
|
||||||
|
formData.append("national_tracking_code", updatedState.national_card_tracking_code);
|
||||||
|
delete updatedState.national_serial_number;
|
||||||
|
}
|
||||||
|
delete updatedState.national_serial_number_or_tracking_code;
|
||||||
|
delete updatedState.checkedBox;
|
||||||
|
|
||||||
|
formData.append("is_legal_person", is_legal_person);
|
||||||
|
|
||||||
|
// بررسی نوع درخواست رفاهی
|
||||||
|
const isType1 = updatedState.refahi_type === 1;
|
||||||
|
|
||||||
|
updatedState = {
|
||||||
|
...updatedState,
|
||||||
|
birthday: updatedState.birthday.locale("en").format("YYYY-MM-DD"),
|
||||||
|
...(isType1
|
||||||
|
? {
|
||||||
|
basic_approval_renewal_date: updatedState.basic_approval_renewal_date
|
||||||
|
.locale("en")
|
||||||
|
.format("YYYY-MM-DD"),
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
exploitation_license_renewal_date: updatedState.exploitation_license_renewal_date
|
||||||
|
.locale("en")
|
||||||
|
.format("YYYY-MM-DD"),
|
||||||
|
exploitation_date: updatedState.exploitation_date.locale("en").format("YYYY-MM-DD"),
|
||||||
|
}),
|
||||||
|
company_register_date: updatedState.company_register_date
|
||||||
|
? updatedState.company_register_date.locale("en").format("YYYY-MM-DD")
|
||||||
|
: "",
|
||||||
|
facility_usage_history: updatedState.facility_usage_history ? 1 : 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
Object.keys(updatedState).forEach((key) => {
|
||||||
|
if (updatedState[key] !== null && updatedState[key] !== undefined) {
|
||||||
|
formData.append(key, updatedState[key]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!is_legal_person) {
|
||||||
|
formData.delete("company_register_date");
|
||||||
|
formData.delete("shenase_meli");
|
||||||
|
formData.delete("register_number");
|
||||||
|
formData.delete("company_name");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
setSubmitting(true);
|
||||||
|
await requestServer(UPDATE_LOAN_REFAHI + queryID, "post", {
|
||||||
|
auth: true,
|
||||||
|
notification: true,
|
||||||
|
data: formData,
|
||||||
|
});
|
||||||
|
getUser((data) => {
|
||||||
|
changeUser(data);
|
||||||
|
});
|
||||||
|
router.push("/dashboard/followUp_loan");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error submitting request:", error);
|
||||||
|
} finally {
|
||||||
|
setSubmitting(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{refahi_type === 1 ? (
|
||||||
|
<BuildFormController
|
||||||
|
editDisabled={editDisabled}
|
||||||
|
submitting={submitting}
|
||||||
|
state={state}
|
||||||
|
dispatch={dispatch}
|
||||||
|
handleSubmit={handleSubmit}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<RestoreFormController
|
||||||
|
editDisabled={editDisabled}
|
||||||
|
submitting={submitting}
|
||||||
|
state={state}
|
||||||
|
dispatch={dispatch}
|
||||||
|
handleSubmit={handleSubmit}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default ShowLoanForm;
|
||||||
103
src/components/dashboard/refahi/show/index.jsx
Normal file
103
src/components/dashboard/refahi/show/index.jsx
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
import ShowLoanForm from "./form";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { GET_LOAN_DETAILS_REFAHI } from "@/core/data/apiRoutes";
|
||||||
|
import { CenterLayout, useRequest } from "@witel/webapp-builder";
|
||||||
|
import { useRouter } from "next/router";
|
||||||
|
import SvgLoading from "@/core/components/svgs/SvgLoading";
|
||||||
|
import { Stack, Typography } from "@mui/material";
|
||||||
|
import { useTranslations } from "next-intl";
|
||||||
|
import moment from "jalali-moment";
|
||||||
|
|
||||||
|
const ShowLoan = () => {
|
||||||
|
const t = useTranslations();
|
||||||
|
const requestServer = useRequest();
|
||||||
|
const { query } = useRouter();
|
||||||
|
const [LoanDetails, setLoanDetails] = useState({});
|
||||||
|
const [LoanDetailsLoading, setLoanDetailsLoading] = useState(true);
|
||||||
|
const isRefahi1 = LoanDetails.refahi_type === 1;
|
||||||
|
const isRefahi2 = LoanDetails.refahi_type === 2;
|
||||||
|
|
||||||
|
const _data = {
|
||||||
|
person_type: LoanDetails?.is_legal_person === 1 ? "legal" : "real",
|
||||||
|
telephone_number: LoanDetails?.telephone_number || "",
|
||||||
|
activity_type_id: LoanDetails?.activity_type_id || "",
|
||||||
|
refahi_type: LoanDetails?.refahi_type || 1,
|
||||||
|
requested_facility_amount: LoanDetails?.requested_facility_amount || "",
|
||||||
|
person_share: LoanDetails?.person_share || "",
|
||||||
|
user_existing_employment: LoanDetails?.user_existing_employment || "",
|
||||||
|
user_committed_employment: LoanDetails?.user_committed_employment || "",
|
||||||
|
father_name: LoanDetails?.father_name || "",
|
||||||
|
gender: LoanDetails?.gender || "",
|
||||||
|
welfare_complex_degree: LoanDetails?.welfare_complex_degree || "",
|
||||||
|
first_name: LoanDetails?.first_name || "",
|
||||||
|
last_name: LoanDetails?.last_name || "",
|
||||||
|
city_id: LoanDetails?.city_id || "",
|
||||||
|
project_city_id: LoanDetails?.project_city_id || "",
|
||||||
|
province_id: LoanDetails?.province_id || "",
|
||||||
|
project_province_id: LoanDetails?.project_province_id || "",
|
||||||
|
education_id: LoanDetails?.education_id || "",
|
||||||
|
occupation_id: LoanDetails?.occupation_id || "",
|
||||||
|
national_id: LoanDetails?.national_id || "",
|
||||||
|
national_serial_number: LoanDetails?.national_serial_number || "",
|
||||||
|
national_card_tracking_code: LoanDetails?.national_card_tracking_code || "",
|
||||||
|
national_serial_number_or_tracking_code: LoanDetails?.national_serial_number
|
||||||
|
? "national_serial_number"
|
||||||
|
: "national_card_tracking_code",
|
||||||
|
postal_code: LoanDetails?.postal_code || "",
|
||||||
|
address: LoanDetails?.address || "",
|
||||||
|
birthday: moment(LoanDetails?.birthday) || "",
|
||||||
|
investment_amount: LoanDetails?.investment_amount || "",
|
||||||
|
checkedBox: false,
|
||||||
|
facility_usage_history: LoanDetails?.facility_usage_history || false,
|
||||||
|
company_register_date: moment(LoanDetails?.company_register_date) || "",
|
||||||
|
shenase_meli: LoanDetails?.shenase_meli || "",
|
||||||
|
register_number: LoanDetails?.register_number || "",
|
||||||
|
company_name: LoanDetails?.company_name || "",
|
||||||
|
project_axis: LoanDetails?.project_axis || "",
|
||||||
|
project_kilometer_marker: LoanDetails?.project_kilometer_marker || "",
|
||||||
|
project_direction: LoanDetails?.project_direction === "رفت" ? 0 : 1,
|
||||||
|
project_address: LoanDetails?.project_address || "",
|
||||||
|
|
||||||
|
...(isRefahi1 && {
|
||||||
|
basic_approval_number: LoanDetails?.basic_approval_number || "",
|
||||||
|
basic_approval_renewal_date: moment(LoanDetails?.basic_approval_renewal_date) || "",
|
||||||
|
basic_approval_renewal_image: LoanDetails?.basic_approval_renewal_image || null,
|
||||||
|
basic_approval_image: LoanDetails?.basic_approval_image || null,
|
||||||
|
project_physical_progress: LoanDetails?.project_physical_progress || "",
|
||||||
|
}),
|
||||||
|
|
||||||
|
...(isRefahi2 && {
|
||||||
|
exploitation_date: moment(LoanDetails?.exploitation_date) || "",
|
||||||
|
exploitation_license_renewal_date: moment(LoanDetails?.exploitation_license_renewal_date) || "",
|
||||||
|
exploitation_license_image: LoanDetails?.exploitation_license_image || null,
|
||||||
|
exploitation_license_renewal_image: LoanDetails?.exploitation_license_renewal_image || null,
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
useEffect(() => {
|
||||||
|
requestServer(GET_LOAN_DETAILS_REFAHI + query.id, "get", { auth: true, notification: false })
|
||||||
|
.then(({ data }) => {
|
||||||
|
setLoanDetails(data.data);
|
||||||
|
setLoanDetailsLoading(false);
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
}, []);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{LoanDetailsLoading ? (
|
||||||
|
<CenterLayout>
|
||||||
|
<SvgLoading height={150} width={150} />
|
||||||
|
<Typography sx={{ pt: 2 }}>{t("ShowLoan.loading_show_component")}</Typography>
|
||||||
|
</CenterLayout>
|
||||||
|
) : (
|
||||||
|
<ShowLoanForm
|
||||||
|
editDisabled={LoanDetails.state_id}
|
||||||
|
queryID={query.id}
|
||||||
|
refahi_type={LoanDetails.refahi_type}
|
||||||
|
defaultData={_data}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ShowLoan;
|
||||||
@@ -4,21 +4,21 @@ import DownloadIcon from "@mui/icons-material/Download";
|
|||||||
const LoanDescription = () => {
|
const LoanDescription = () => {
|
||||||
return (
|
return (
|
||||||
<Box sx={{ flex: 1 }}>
|
<Box sx={{ flex: 1 }}>
|
||||||
<Stack alignItems={"center"} justifyContent={"center"} sx={{pt : 15}}>
|
<Stack alignItems={"center"} justifyContent={"center"} sx={{ pt: 15 }}>
|
||||||
<Button variant="contained" startIcon={<DownloadIcon />}>
|
<Button variant="contained" startIcon={<DownloadIcon />}>
|
||||||
<Link
|
<Link
|
||||||
variant="subtitle1"
|
variant="subtitle1"
|
||||||
sx={{ padding: 1 }}
|
sx={{ padding: 1 }}
|
||||||
color={"white"}
|
color={"white"}
|
||||||
download
|
download
|
||||||
underline="none"
|
underline="none"
|
||||||
href={"/files/راهنما.pdf"}
|
href={"/files/راهنما.pdf"}
|
||||||
>
|
>
|
||||||
دریافت فایل های راهنما
|
دریافت فایل های راهنما
|
||||||
</Link>
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
export default LoanDescription;
|
export default LoanDescription;
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ export const GET_EDUCATIONS_LIST = BASE_URL + "/education";
|
|||||||
export const GET_OCCUPATIONS_LIST = BASE_URL + "/occupations";
|
export const GET_OCCUPATIONS_LIST = BASE_URL + "/occupations";
|
||||||
|
|
||||||
export const GET_LOAN_DETAILS = BASE_URL + "/navgan/loan/details/";
|
export const GET_LOAN_DETAILS = BASE_URL + "/navgan/loan/details/";
|
||||||
|
export const GET_LOAN_DETAILS_REFAHI = BASE_URL + "/refahi/loan/details/";
|
||||||
export const UPDATE_LOAN = BASE_URL + "/navgan/loan/update/";
|
export const UPDATE_LOAN = BASE_URL + "/navgan/loan/update/";
|
||||||
|
export const UPDATE_LOAN_REFAHI = BASE_URL + "/refahi/loan/update/";
|
||||||
|
|
||||||
export const GET_PROJECT_TITLE = BASE_URL + "/navgan_plans";
|
export const GET_PROJECT_TITLE = BASE_URL + "/navgan_plans";
|
||||||
export const GET_ACTIVITY_LIST = BASE_URL + "/activity_types";
|
export const GET_ACTIVITY_LIST = BASE_URL + "/activity_types";
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import LoanFollowUpComponent from "src/components/dashboard/followUp-loan";
|
import LoanFollowUpComponent from "@/components/dashboard/followUp-loan";
|
||||||
import { globalServerProps } from "@/core/utils/globalServerProps";
|
import { globalServerProps } from "@/core/utils/globalServerProps";
|
||||||
|
|
||||||
export default function FollowUpLoan() {
|
export default function FollowUpLoan() {
|
||||||
|
|||||||
18
src/pages/dashboard/refahi/[id]/show/index.jsx
Normal file
18
src/pages/dashboard/refahi/[id]/show/index.jsx
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { parse } from "next-useragent";
|
||||||
|
import ShowLoan from "@/components/dashboard/refahi/show";
|
||||||
|
import { globalServerProps } from "@/core/utils/globalServerProps";
|
||||||
|
|
||||||
|
export default function ShowLoanRequest() {
|
||||||
|
return <ShowLoan />;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getServerSideProps({ req, locale }) {
|
||||||
|
const { isBot } = parse(req.headers["user-agent"]);
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
...(await globalServerProps({ req, locale })),
|
||||||
|
title: "ShowLoan.show_loan_page",
|
||||||
|
layout: { name: "DashboardLayout" },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user