Merge branch 'feature/mohammad_change_upload_type' into 'develop'
Feature/mohammad change upload type See merge request witel-front-end/loan-facilities/expert!125
This commit is contained in:
@@ -101,7 +101,6 @@ const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type, hand
|
||||
return allowedTypes.includes(value.type);
|
||||
})
|
||||
});
|
||||
|
||||
const formik = useFormik({
|
||||
initialValues: {
|
||||
description: "",
|
||||
@@ -116,7 +115,18 @@ const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type, hand
|
||||
formData.append("sakht_period", values.sakht_period);
|
||||
formData.append("tanafos_period", values.tanafos_period);
|
||||
if (values.description != "") formData.append("expert_description", values.description);
|
||||
if (values.confirm_img != null) formData.append("attachment", values.confirm_img);
|
||||
if (values.confirm_img != null) {
|
||||
const attachments = [
|
||||
{
|
||||
title: "فایل ضمیمه کارتابل قیمت گذاری",
|
||||
file: values.confirm_img
|
||||
}
|
||||
];
|
||||
attachments.forEach((attachment, index) => {
|
||||
formData.append(`attachment[${index}][title]`, attachment.title);
|
||||
formData.append(`attachment[${index}][file]`, attachment.file);
|
||||
});
|
||||
}
|
||||
requestServer(`${CONFIRM_MACHINARY_OFFICE}/${rowId}`, 'post', {
|
||||
data: formData,
|
||||
notification: true
|
||||
|
||||
@@ -30,8 +30,18 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
|
||||
onSubmit: (values, {setSubmitting}) => {
|
||||
const formData = new FormData();
|
||||
formData.append("expert_description", values.description);
|
||||
if (values.reject_img != null) formData.append("attachment", values.reject_img);
|
||||
|
||||
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_MACHINARY_OFFICE}/${rowId}`, 'post', {
|
||||
data: formData,
|
||||
}).then((response) => {
|
||||
|
||||
@@ -29,6 +29,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl
|
||||
const [showAddIcon, setShowAddIcon] = useState(true);
|
||||
const requestServer = useRequest({auth: true, notification: false})
|
||||
const {update_notification} = useNotification()
|
||||
const [attachmentsData, setAttachmentsData] = useState([]);
|
||||
const [accordionStates, setAccordionStates] = useState([]);
|
||||
const [hasImageShown, setHasImageShown] = useState(false);
|
||||
const [imageLink, setImageLink] = useState(null);
|
||||
@@ -52,9 +53,14 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl
|
||||
useEffect(() => {
|
||||
requestServer(`${CONFIRM_PROVINCE_MANAGER_DETAILS}/${rowId}`, 'get')
|
||||
.then((response) => {
|
||||
const booleanData = Array.from({length: response.data.data.attachment_files.length}, () => false);
|
||||
setAccordionStates(booleanData);
|
||||
setDetailsData(response.data)
|
||||
const allAttachments = [];
|
||||
response.data.data.histories.map((history) => {
|
||||
history.attachments.map((attachment) => {
|
||||
allAttachments.push(attachment);
|
||||
});
|
||||
});
|
||||
setAttachmentsData(allAttachments);
|
||||
setDetailsData(response.data);
|
||||
})
|
||||
.catch(() => {
|
||||
}).finally(() => {
|
||||
@@ -62,6 +68,13 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (attachmentsData.length !== 0) {
|
||||
const booleanData = Array.from({length: attachmentsData.length}, () => false);
|
||||
setAccordionStates(booleanData);
|
||||
}
|
||||
}, [attachmentsData]);
|
||||
|
||||
const handleAccordionChange = (index) => {
|
||||
const newAccordionStates = accordionStates.map((state, i) => i === index ? !state : false);
|
||||
setAccordionStates(newAccordionStates);
|
||||
@@ -73,7 +86,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl
|
||||
} else {
|
||||
handleSizeChangeClick('xl');
|
||||
setHasImageShown(true);
|
||||
setImageLink(detailsList.data.attachment_files[index])
|
||||
setImageLink(attachmentsData[index])
|
||||
setIsSkeleton(true)
|
||||
}
|
||||
};
|
||||
@@ -85,9 +98,19 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl
|
||||
}, validationSchema,
|
||||
onSubmit: (values, {setSubmitting}) => {
|
||||
const formData = new FormData();
|
||||
if (values.description != "") formData.append("expert_description", values.description);
|
||||
if (values.confirm_img != null) formData.append("attachment", values.confirm_img);
|
||||
|
||||
if (values.description !== "") formData.append("expert_description", values.description);
|
||||
if (values.confirm_img != null) {
|
||||
const attachments = [
|
||||
{
|
||||
title: "فایل ضمیمه کارتابل بررسی وام های تبصره 18",
|
||||
file: values.confirm_img
|
||||
}
|
||||
];
|
||||
attachments.forEach((attachment, index) => {
|
||||
formData.append(`attachment[${index}][title]`, attachment.title);
|
||||
formData.append(`attachment[${index}][file]`, attachment.file);
|
||||
});
|
||||
}
|
||||
requestServer(`${CONFIRM_NAVGAN_PROVINCE_MANAGER}/${rowId}`, 'post', {
|
||||
data: formData,
|
||||
notification: true
|
||||
@@ -122,8 +145,8 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl
|
||||
};
|
||||
|
||||
const renderCustomAccordions = () => {
|
||||
if (detailsList && detailsList.data && detailsList.data.attachment_files) {
|
||||
return detailsList.data.attachment_files.map((file, index) => (
|
||||
if (attachmentsData) {
|
||||
return attachmentsData.map((file, index) => (
|
||||
<CustomAccordion
|
||||
key={index}
|
||||
title={`${file.title}`}
|
||||
@@ -131,7 +154,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl
|
||||
hasAccordionOpened={null}
|
||||
handleAccordionChange={() => handleAccordionChange(index)}
|
||||
accordionIndex={index}
|
||||
downloadFile={file.attachment}
|
||||
downloadFile={file.file}
|
||||
/>
|
||||
));
|
||||
}
|
||||
|
||||
@@ -30,8 +30,18 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
|
||||
onSubmit: (values, {setSubmitting}) => {
|
||||
const formData = new FormData();
|
||||
formData.append("expert_description", values.description);
|
||||
if (values.reject_img != null) formData.append("attachment", values.reject_img);
|
||||
|
||||
if (values.reject_img != null) {
|
||||
const attachments = [
|
||||
{
|
||||
title: "فایل ضمیمه کارتابل بررسی وام های تبصره 18",
|
||||
file: values.reject_img
|
||||
}
|
||||
];
|
||||
attachments.forEach((attachment, index) => {
|
||||
formData.append(`attachment[${index}][title]`, attachment.title);
|
||||
formData.append(`attachment[${index}][file]`, attachment.file);
|
||||
});
|
||||
}
|
||||
requestServer(`${REJECT_NAVGAN_PROVINCE_MANAGER}/${rowId}`, 'post', {
|
||||
data: formData,
|
||||
}).then((response) => {
|
||||
|
||||
@@ -28,7 +28,8 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl
|
||||
const [fileType, setfileType] = useState(null);
|
||||
const [fileName, setfileName] = useState(null);
|
||||
const [showAddIcon, setShowAddIcon] = useState(true);
|
||||
const requestServer = useRequest({auth: true, notification: false})
|
||||
const requestServer = useRequest({auth: true, notification: false});
|
||||
const [attachmentsData, setAttachmentsData] = useState([]);
|
||||
const [accordionStates, setAccordionStates] = useState([]);
|
||||
const [hasAccordionOpened, setHasAccordionOpened] = useState([]);
|
||||
const {update_notification} = useNotification();
|
||||
@@ -42,10 +43,14 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl
|
||||
useEffect(() => {
|
||||
requestServer(`${GET_TRANSPORTATION_ASSISTANCE_DETAILS}/${rowId}`, 'get')
|
||||
.then((response) => {
|
||||
const booleanData = Array.from({length: response.data.data.attachment_files.length}, () => false);
|
||||
setAccordionStates(booleanData);
|
||||
setHasAccordionOpened(booleanData);
|
||||
setDetailsData(response.data)
|
||||
const allAttachments = [];
|
||||
response.data.data.histories.map((history) => {
|
||||
history.attachments.map((attachment) => {
|
||||
allAttachments.push(attachment);
|
||||
});
|
||||
});
|
||||
setDetailsData(response.data);
|
||||
setAttachmentsData(allAttachments);
|
||||
})
|
||||
.catch(() => {
|
||||
}).finally(() => {
|
||||
@@ -53,6 +58,14 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (attachmentsData.length !== 0) {
|
||||
const booleanData = Array.from({length: attachmentsData.length}, () => false);
|
||||
setAccordionStates(booleanData);
|
||||
setHasAccordionOpened(booleanData);
|
||||
}
|
||||
}, [attachmentsData]);
|
||||
|
||||
const handleAccordionChange = (index) => {
|
||||
const newAccordionStates = accordionStates.map((state, i) => i === index ? !state : false);
|
||||
setAccordionStates(newAccordionStates);
|
||||
@@ -60,12 +73,12 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl
|
||||
if (!newAccordionStates[index]) {
|
||||
handleSizeChangeClick('sm');
|
||||
setHasImageShown(false);
|
||||
setIsSkeleton(false)
|
||||
setIsSkeleton(false);
|
||||
} else {
|
||||
handleSizeChangeClick('xl');
|
||||
setHasImageShown(true);
|
||||
setImageLink(detailsList.data.attachment_files[index])
|
||||
setIsSkeleton(true)
|
||||
setImageLink(attachmentsData[index]);
|
||||
setIsSkeleton(true);
|
||||
const newHasAccordionOpened = [...hasAccordionOpened];
|
||||
newHasAccordionOpened[index] = true;
|
||||
setHasAccordionOpened(newHasAccordionOpened);
|
||||
@@ -93,9 +106,19 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl
|
||||
}, validationSchema,
|
||||
onSubmit: (values, {setSubmitting}) => {
|
||||
const formData = new FormData();
|
||||
if (values.description != "") formData.append("expert_description", values.description);
|
||||
if (values.confirm_img != null) formData.append("attachment", values.confirm_img);
|
||||
|
||||
if (values.description !== "") formData.append("expert_description", values.description);
|
||||
if (values.confirm_img != null) {
|
||||
const attachments = [
|
||||
{
|
||||
title: "فایل ضمیمه کارتابل بررسی وام های تبصره 18",
|
||||
file: values.confirm_img
|
||||
}
|
||||
];
|
||||
attachments.forEach((attachment, index) => {
|
||||
formData.append(`attachment[${index}][title]`, attachment.title);
|
||||
formData.append(`attachment[${index}][file]`, attachment.file);
|
||||
});
|
||||
}
|
||||
requestServer(`${CONFIRM_TRANSPORTATION_ASSISTANCE}/${rowId}`, 'post', {
|
||||
data: formData,
|
||||
notification: true
|
||||
@@ -133,8 +156,8 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl
|
||||
};
|
||||
|
||||
const renderCustomAccordions = () => {
|
||||
if (detailsList && detailsList.data && detailsList.data.attachment_files) {
|
||||
return detailsList.data.attachment_files.map((file, index) => (
|
||||
if (attachmentsData) {
|
||||
return attachmentsData.map((file, index) => (
|
||||
<CustomAccordion
|
||||
key={index}
|
||||
title={`${file.title}`}
|
||||
@@ -142,7 +165,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl
|
||||
hasAccordionOpened={hasAccordionOpened[index]}
|
||||
handleAccordionChange={() => handleAccordionChange(index)}
|
||||
accordionIndex={index}
|
||||
downloadFile={file.attachment}
|
||||
downloadFile={file.file}
|
||||
/>
|
||||
));
|
||||
}
|
||||
@@ -185,7 +208,9 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl
|
||||
multiline
|
||||
rows={8}
|
||||
label={<>
|
||||
<span>{t("ConfirmDialog.description")}</span><small>{t("ConfirmDialog.optional")}</small></>}
|
||||
<span>{t("ConfirmDialog.description")}</span>
|
||||
<small>{t("ConfirmDialog.optional")}</small>
|
||||
</>}
|
||||
value={formik.values.description}
|
||||
onChange={handleDescriptionChange}
|
||||
fullWidth
|
||||
@@ -213,9 +238,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl
|
||||
Boolean(formik.errors.confirm_img)
|
||||
}
|
||||
/>
|
||||
<FormHelperText
|
||||
error={Boolean(formik.errors.confirm_img)}
|
||||
>
|
||||
<FormHelperText error={Boolean(formik.errors.confirm_img)}>
|
||||
{formik.touched.confirm_img && formik.errors.confirm_img}
|
||||
</FormHelperText>
|
||||
</Stack>
|
||||
|
||||
@@ -30,8 +30,18 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
|
||||
onSubmit: (values, {setSubmitting}) => {
|
||||
const formData = new FormData();
|
||||
formData.append("expert_description", values.description);
|
||||
if (values.reject_img != null) formData.append("attachment", values.reject_img);
|
||||
|
||||
if (values.reject_img != null) {
|
||||
const attachments = [
|
||||
{
|
||||
title: "فایل ضمیمه کارتابل بررسی وام های تبصره 18",
|
||||
file: values.reject_img
|
||||
}
|
||||
];
|
||||
attachments.forEach((attachment, index) => {
|
||||
formData.append(`attachment[${index}][title]`, attachment.title);
|
||||
formData.append(`attachment[${index}][file]`, attachment.file);
|
||||
});
|
||||
}
|
||||
requestServer(`${REJECT_TRANSPORTATION_ASSISTANCE}/${rowId}`, 'post', {
|
||||
data: formData,
|
||||
}).then((response) => {
|
||||
|
||||
Reference in New Issue
Block a user