Merge branch 'feature/amin_reject_update_bankManagement' into 'develop'
Feature/amin reject update bank management See merge request witel-front-end/loan-facilities/expert!159
This commit is contained in:
@@ -505,15 +505,33 @@
|
|||||||
"description": "توضیحات خود را وارد نمائید"
|
"description": "توضیحات خود را وارد نمائید"
|
||||||
},
|
},
|
||||||
"RejectDialog": {
|
"RejectDialog": {
|
||||||
|
"bank_management_reject": "رد درخواست",
|
||||||
|
"typography": "آیا میخواهید این درخواست را رد کنید ؟",
|
||||||
"reject": "عدم تایید",
|
"reject": "عدم تایید",
|
||||||
"context": "آیا از عدم تایید این آیتم اطمینان دارید؟",
|
"context": "آیا از عدم تایید این آیتم اطمینان دارید؟",
|
||||||
"button-cancel": "بستن",
|
"button-cancel": "بستن",
|
||||||
"button-reject": "عدم تایید",
|
"button-reject": "عدم تایید",
|
||||||
|
"button-bank_management_reject": "رد درخواست",
|
||||||
"description": "توضیحات خود را وارد نمائید",
|
"description": "توضیحات خود را وارد نمائید",
|
||||||
"optional": " (اختیاری)",
|
"optional": " (اختیاری)",
|
||||||
"description_error": "وارد کردن توضیحات الزامی است!",
|
"description_error": "وارد کردن توضیحات الزامی است!",
|
||||||
"choose_file": "انتخاب فایل"
|
"choose_file": "انتخاب فایل"
|
||||||
},
|
},
|
||||||
|
"EditDialog": {
|
||||||
|
"edit_approved_amount": "ویرایش مبلغ تصویب شده",
|
||||||
|
"description_error": "وارد کردن توضیحات الزامی است!",
|
||||||
|
"optional": " (اختیاری)",
|
||||||
|
"approved_amount": "مبلغ تصویب شده",
|
||||||
|
"button-cancel": "بستن",
|
||||||
|
"button-edit": "ویرایش",
|
||||||
|
"edit_approved_amount_required": "وارد کردن مبلغ تصویب شده الزامیست",
|
||||||
|
"unit": " (میلیون ریال)",
|
||||||
|
"button-revise": "ارسال",
|
||||||
|
"approved_amount_positive": "مبلغ تصویب شده باید مثبت باشد",
|
||||||
|
"max_amount": "حداکثر مبلغ تصویب شده {value} میلیون ریال می باشد",
|
||||||
|
"approved_amount_number": "مبلغ تصویب شده باید عدد باشد",
|
||||||
|
"description": "توضیحات خود را وارد نمائید"
|
||||||
|
},
|
||||||
"UpdateDialog": {
|
"UpdateDialog": {
|
||||||
"update": "ویرایش",
|
"update": "ویرایش",
|
||||||
"resend": "ارسال مجدد به بانک",
|
"resend": "ارسال مجدد به بانک",
|
||||||
|
|||||||
@@ -0,0 +1,105 @@
|
|||||||
|
import useNotification from "@/lib/app/hooks/useNotification";
|
||||||
|
import useRequest from "@/lib/app/hooks/useRequest";
|
||||||
|
import {Button, DialogActions, DialogContent, Stack,} from "@mui/material"
|
||||||
|
import {useFormik} from "formik";
|
||||||
|
import {useTranslations} from "next-intl";
|
||||||
|
import {EDIT_APPROVED_AMOUNT} from "@/core/data/apiRoutes";
|
||||||
|
import * as Yup from "yup";
|
||||||
|
import PriceField from "@/core/components/PriceField";
|
||||||
|
|
||||||
|
const vehicle_amount = {
|
||||||
|
"اتوبوس": 7000,
|
||||||
|
"مینی بوس": 2000,
|
||||||
|
}
|
||||||
|
|
||||||
|
const EditContent = ({rowId, row, mutate, setOpenEditDialog, vehicle_type}) => {
|
||||||
|
const t = useTranslations();
|
||||||
|
const requestServer = useRequest({auth: true, notification: false});
|
||||||
|
const {update_notification} = useNotification();
|
||||||
|
|
||||||
|
const validationSchema = Yup.object().shape({
|
||||||
|
approved_amount: Yup.mixed().test(
|
||||||
|
"is-number",
|
||||||
|
`${t("EditDialog.approved_amount_number")}`,
|
||||||
|
(value) => !isNaN(value)
|
||||||
|
).test("max-amount", `${t("EditDialog.max_amount", {value: parseInt(vehicle_amount[vehicle_type]).toLocaleString('en')})}`,
|
||||||
|
(value) => value <= vehicle_amount[vehicle_type])
|
||||||
|
.test("positive", `${t("EditDialog.approved_amount_positive")}`, (value) => value >= 0)
|
||||||
|
.required(t("EditDialog.edit_approved_amount_required")),
|
||||||
|
})
|
||||||
|
|
||||||
|
const formik = useFormik({
|
||||||
|
initialValues: {
|
||||||
|
approved_amount: String(row.original.approved_amount / 1000000)
|
||||||
|
}, validationSchema,
|
||||||
|
onSubmit: (values, {setSubmitting}) => {
|
||||||
|
requestServer(`${EDIT_APPROVED_AMOUNT}/${rowId}`, 'post', {
|
||||||
|
data: {
|
||||||
|
approved_amount: values.approved_amount
|
||||||
|
},
|
||||||
|
notification: true
|
||||||
|
}).then(() => {
|
||||||
|
setOpenEditDialog(false)
|
||||||
|
mutate()
|
||||||
|
update_notification()
|
||||||
|
}).catch(() => {
|
||||||
|
}).finally(() => {
|
||||||
|
setSubmitting(false);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const handleAmountChange = (event) => {
|
||||||
|
if (!isNaN(event.target.value)) {
|
||||||
|
formik.setFieldValue("approved_amount", event.target.value)
|
||||||
|
} else {
|
||||||
|
formik.setFieldValue("approved_amount", formik.values.approved_amount)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<DialogContent>
|
||||||
|
<Stack spacing={2}>
|
||||||
|
<Stack>
|
||||||
|
<PriceField
|
||||||
|
name="approved_amount"
|
||||||
|
label={<>
|
||||||
|
<span>{t("EditDialog.edit_approved_amount")}</span><small>{t("EditDialog.unit")}</small></>}
|
||||||
|
type="text"
|
||||||
|
inputProps={{
|
||||||
|
inputMode: "number",
|
||||||
|
min: 0,
|
||||||
|
pattern: "[0-9]*",
|
||||||
|
}}
|
||||||
|
variant="outlined"
|
||||||
|
value={formik.values.approved_amount}
|
||||||
|
onChange={handleAmountChange}
|
||||||
|
onBlur={formik.handleBlur("approved_amount")}
|
||||||
|
error={
|
||||||
|
formik.touched.approved_amount &&
|
||||||
|
Boolean(formik.errors.approved_amount)
|
||||||
|
}
|
||||||
|
helperText={
|
||||||
|
formik.touched.approved_amount && formik.errors.approved_amount
|
||||||
|
}
|
||||||
|
sx={{mt: 1}}
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
<Button onClick={() => setOpenEditDialog(false)} variant="outlined" color="secondary"
|
||||||
|
disabled={formik.isSubmitting} autoFocus>
|
||||||
|
{t("EditDialog.button-cancel")}
|
||||||
|
</Button>
|
||||||
|
<Button onClick={formik.handleSubmit} variant="contained" color="primary"
|
||||||
|
disabled={formik.isSubmitting || !formik.isValid || !formik.dirty}
|
||||||
|
>
|
||||||
|
{t("EditDialog.button-edit")}
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
export default EditContent
|
||||||
40
src/components/dashboard/bank-management/Form/Edit/index.jsx
Normal file
40
src/components/dashboard/bank-management/Form/Edit/index.jsx
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material";
|
||||||
|
import {useTranslations} from "next-intl";
|
||||||
|
import {useState} from "react";
|
||||||
|
import EditIcon from '@mui/icons-material/Edit';
|
||||||
|
import EditContent from "@/components/dashboard/bank-management/Form/Edit/EditContent";
|
||||||
|
|
||||||
|
const EditForm = ({rowId, row, mutate, vehicle_type}) => {
|
||||||
|
const t = useTranslations();
|
||||||
|
const [openEditDialog, setOpenEditDialog] = useState(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Tooltip title={t("EditDialog.edit_approved_amount")}>
|
||||||
|
<IconButton
|
||||||
|
color="primary"
|
||||||
|
onClick={() => {
|
||||||
|
setOpenEditDialog(true)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<EditIcon/>
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
<Dialog fullWidth open={openEditDialog}
|
||||||
|
PaperProps={{
|
||||||
|
sx: {
|
||||||
|
transition: 'all .3s',
|
||||||
|
boxShadow: 'rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px'
|
||||||
|
}
|
||||||
|
}} maxWidth="sm">
|
||||||
|
<DialogTitle>{t("EditDialog.edit_approved_amount")}</DialogTitle>
|
||||||
|
<EditContent
|
||||||
|
mutate={mutate} rowId={rowId} setOpenEditDialog={setOpenEditDialog} row={row}
|
||||||
|
vehicle_type={vehicle_type}
|
||||||
|
/>
|
||||||
|
</Dialog>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
export default EditForm;
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
import UploadSystem from "@/core/components/UploadSystem"
|
||||||
|
import useNotification from "@/lib/app/hooks/useNotification";
|
||||||
|
import useRequest from "@/lib/app/hooks/useRequest";
|
||||||
|
import {Button, DialogActions, DialogContent, FormHelperText, Stack, TextField, Typography} from "@mui/material"
|
||||||
|
import {useFormik} from "formik";
|
||||||
|
import {useTranslations} from "next-intl";
|
||||||
|
import {useState} from "react";
|
||||||
|
import * as Yup from "yup";
|
||||||
|
import {REJECT_BANK_MANAGEMENT} from "@/core/data/apiRoutes";
|
||||||
|
|
||||||
|
const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
|
||||||
|
const [selectedImage, setSelectedImage] = useState("");
|
||||||
|
const [fileType, setfileType] = useState(null);
|
||||||
|
const [fileName, setfileName] = useState(null);
|
||||||
|
const [showAddIcon, setShowAddIcon] = useState(true);
|
||||||
|
const t = useTranslations();
|
||||||
|
const requestServer = useRequest({auth: true})
|
||||||
|
const {update_notification} = useNotification()
|
||||||
|
|
||||||
|
const validationSchema = Yup.object().shape({
|
||||||
|
description: Yup.string().required(t("RejectDialog.description_error")),
|
||||||
|
reject_img: Yup.mixed().notRequired(t("RejectDialog.choose_file"))
|
||||||
|
.test('fileSize', `${t("MachinaryOffice.upload_file_unit")}`, (value) => {
|
||||||
|
return !value || (value.size && value.size <= 5 * 1024 * 1024);
|
||||||
|
})
|
||||||
|
.test('fileType', `${t("MachinaryOffice.upload_file_format")}`, (value) => {
|
||||||
|
const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; // Define your allowed file types
|
||||||
|
return !value || (value.type && allowedTypes.includes(value.type));
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
const formik = useFormik({
|
||||||
|
initialValues: {
|
||||||
|
description: "",
|
||||||
|
reject_img: null
|
||||||
|
},
|
||||||
|
validationSchema,
|
||||||
|
onSubmit: (values, {setSubmitting}) => {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("expert_description", values.description);
|
||||||
|
if (values.reject_img != null) {
|
||||||
|
const attachments = [
|
||||||
|
{
|
||||||
|
title: "فایل ضمیمه کارتابل نظارت بانک",
|
||||||
|
file: values.reject_img
|
||||||
|
}
|
||||||
|
];
|
||||||
|
attachments.forEach((attachment, index) => {
|
||||||
|
formData.append(`attachment[${index}][title]`, attachment.title);
|
||||||
|
formData.append(`attachment[${index}][file]`, attachment.file);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
requestServer(`${REJECT_BANK_MANAGEMENT}/${rowId}`, 'post', {
|
||||||
|
data: formData,
|
||||||
|
}).then((response) => {
|
||||||
|
setOpenRejectDialog(false)
|
||||||
|
mutate()
|
||||||
|
update_notification()
|
||||||
|
}).catch(() => {
|
||||||
|
}).finally(() => {
|
||||||
|
setSubmitting(false);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleUploadChange = (event) => {
|
||||||
|
const uploadedFile = event.target?.files?.[0];
|
||||||
|
if (uploadedFile) {
|
||||||
|
const fileType = event.target?.files?.[0].type;
|
||||||
|
const fileName = event.target?.files?.[0].name;
|
||||||
|
setSelectedImage(URL.createObjectURL(uploadedFile));
|
||||||
|
setfileType(fileType);
|
||||||
|
setfileName(fileName);
|
||||||
|
formik.setFieldValue("reject_img", uploadedFile).then(() => {
|
||||||
|
formik.setFieldTouched("reject_img", true);
|
||||||
|
})
|
||||||
|
setShowAddIcon(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<DialogContent>
|
||||||
|
<Stack spacing={2}>
|
||||||
|
<Stack>
|
||||||
|
<TextField
|
||||||
|
name="description"
|
||||||
|
multiline
|
||||||
|
rows={8}
|
||||||
|
label={t("RejectDialog.description")}
|
||||||
|
value={formik.values.description}
|
||||||
|
onChange={formik.handleChange}
|
||||||
|
onBlur={formik.handleBlur("description")}
|
||||||
|
error={
|
||||||
|
formik.touched.description && Boolean(formik.errors.description)
|
||||||
|
}
|
||||||
|
helperText={formik.touched.description && formik.errors.description}
|
||||||
|
fullWidth
|
||||||
|
variant="outlined"
|
||||||
|
sx={{mt: 1}}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
<Stack>
|
||||||
|
<Typography>{t("UploadSystem.upload_file")}{t("UploadSystem.optional")}</Typography>
|
||||||
|
<UploadSystem
|
||||||
|
selectedImage={selectedImage}
|
||||||
|
handleUploadChange={handleUploadChange} // Pass the updated function directly
|
||||||
|
setselectedImage={setSelectedImage}
|
||||||
|
setFieldValue={formik.setFieldValue} // Remove props.setFieldValue, use formik.setFieldValue
|
||||||
|
fieldname="reject_img"
|
||||||
|
fileType={fileType}
|
||||||
|
fileName={fileName}
|
||||||
|
imageAlt={t("app_name")}
|
||||||
|
imageSize={[250 /*width*/, 150 /*height*/]}
|
||||||
|
setShowAddIcon={setShowAddIcon}
|
||||||
|
showAddIcon={showAddIcon}
|
||||||
|
onBlur={() => formik.handleBlur("reject_img")}
|
||||||
|
error={
|
||||||
|
formik.touched.reject_img &&
|
||||||
|
Boolean(formik.errors.reject_img)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<FormHelperText
|
||||||
|
error={Boolean(formik.errors.reject_img)}
|
||||||
|
>
|
||||||
|
{formik.touched.reject_img && formik.errors.reject_img}
|
||||||
|
</FormHelperText>
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
<Button onClick={() => setOpenRejectDialog(false)} variant="outlined" color="secondary"
|
||||||
|
disabled={formik.isSubmitting} autoFocus>
|
||||||
|
{t("RejectDialog.button-cancel")}
|
||||||
|
</Button>
|
||||||
|
<Button onClick={formik.handleSubmit} variant="contained" color="primary"
|
||||||
|
disabled={formik.isSubmitting || !formik.dirty || !formik.isValid}>
|
||||||
|
{t("RejectDialog.button-reject")}
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
export default RejectContent
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material"
|
||||||
|
import {useTranslations} from "next-intl";
|
||||||
|
import {useState} from "react";
|
||||||
|
import RejectContent from "./RejectContent";
|
||||||
|
import ThumbDownIcon from "@mui/icons-material/ThumbDown";
|
||||||
|
|
||||||
|
const RejectForm = ({rowId, mutate}) => {
|
||||||
|
const t = useTranslations();
|
||||||
|
const [openRejectDialog, setOpenRejectDialog] = useState(false);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Tooltip title={t("RejectDialog.bank_management_reject")}>
|
||||||
|
<IconButton color="primary" onClick={() => setOpenRejectDialog(true)}>
|
||||||
|
<ThumbDownIcon/>
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
<Dialog fullWidth open={openRejectDialog}
|
||||||
|
PaperProps={{sx: {boxShadow: 'rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px'}}}>
|
||||||
|
<DialogTitle>{t("RejectDialog.bank_management_reject")}</DialogTitle>
|
||||||
|
<RejectContent mutate={mutate} rowId={rowId} setOpenRejectDialog={setOpenRejectDialog}/>
|
||||||
|
</Dialog>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
export default RejectForm
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
import {Box} from "@mui/material";
|
import {Box} from "@mui/material";
|
||||||
import UpdateForm from "@/components/dashboard/bank-management/Form/Update";
|
import UpdateForm from "@/components/dashboard/bank-management/Form/Update";
|
||||||
|
import EditForm from "@/components/dashboard/bank-management/Form/Edit";
|
||||||
|
import RejectForm from "@/components/dashboard/bank-management/Form/Reject";
|
||||||
|
|
||||||
const TableRow = ({row, mutate}) => {
|
const TableRow = ({row, mutate}) => {
|
||||||
return (
|
return (
|
||||||
@@ -10,6 +12,24 @@ const TableRow = ({row, mutate}) => {
|
|||||||
mutate={mutate}
|
mutate={mutate}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{
|
||||||
|
row.original.bank_state == 8 && (
|
||||||
|
<RejectForm
|
||||||
|
rowId={row.getValue("id")}
|
||||||
|
mutate={mutate}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
{
|
||||||
|
row.original.bank_state == 8 && (
|
||||||
|
<EditForm
|
||||||
|
rowId={row.getValue("id")}
|
||||||
|
mutate={mutate}
|
||||||
|
vehicle_type={row.original.vehicle_type}
|
||||||
|
row={row}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -256,6 +256,8 @@ export const DELETE_ADMIN_SETTING = BASE_URL + "/dashboard/settings/delete"
|
|||||||
export const GET_BANK_STATEMENT = BASE_URL + "/dashboard/bank_referred_loans"
|
export const GET_BANK_STATEMENT = BASE_URL + "/dashboard/bank_referred_loans"
|
||||||
export const RESEND_BANK_STATEMENT = BASE_URL + "/dashboard/bank_referred_loans/send"
|
export const RESEND_BANK_STATEMENT = BASE_URL + "/dashboard/bank_referred_loans/send"
|
||||||
export const EXPORT_BANK_MANAGEMENT = BASE_URL + "/dashboard/bank_referred_loans/export"
|
export const EXPORT_BANK_MANAGEMENT = BASE_URL + "/dashboard/bank_referred_loans/export"
|
||||||
|
export const REJECT_BANK_MANAGEMENT = BASE_URL + "/dashboard/bank_referred_loans/reject"
|
||||||
|
export const EDIT_APPROVED_AMOUNT = BASE_URL + "/dashboard/bank_referred_loans/update"
|
||||||
|
|
||||||
// loan statistics
|
// loan statistics
|
||||||
export const GET_LOAN_STATISTICS = BASE_URL + "/dashboard/reports/navgan/statistics"
|
export const GET_LOAN_STATISTICS = BASE_URL + "/dashboard/reports/navgan/statistics"
|
||||||
|
|||||||
Reference in New Issue
Block a user