complete upload file changes in gheimat gozari cartable
This commit is contained in:
@@ -14,10 +14,7 @@ import {
|
||||
} from "@mui/material"
|
||||
import {useFormik} from "formik";
|
||||
import {useTranslations} from "next-intl";
|
||||
import {
|
||||
CONFIRM_MACHINARY_OFFICE,
|
||||
CONFIRM_MACHINARY_OFFICE_DETAILS
|
||||
} from "@/core/data/apiRoutes";
|
||||
import {CONFIRM_MACHINARY_OFFICE, CONFIRM_MACHINARY_OFFICE_DETAILS} from "@/core/data/apiRoutes";
|
||||
import {useEffect, useState} from "react";
|
||||
import PriceField from "@/core/components/PriceField";
|
||||
import * as Yup from "yup";
|
||||
@@ -28,13 +25,13 @@ const vehicle_amount = {
|
||||
"اتوبوس": 7000,
|
||||
"مینی بوس": 2000,
|
||||
}
|
||||
const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type , handleSizeChangeClick}) => {
|
||||
const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type, handleSizeChangeClick}) => {
|
||||
const t = useTranslations();
|
||||
const [selectedImage, setSelectedImage] = useState("");
|
||||
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 {update_notification} = useNotification()
|
||||
const [accordionStates, setAccordionStates] = useState([]);
|
||||
const [hasImageShown, setHasImageShown] = useState(false);
|
||||
@@ -46,7 +43,7 @@ const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type , han
|
||||
useEffect(() => {
|
||||
requestServer(`${CONFIRM_MACHINARY_OFFICE_DETAILS}/${rowId}`, 'get')
|
||||
.then((response) => {
|
||||
const booleanData = Array.from({ length: response.data.data.attachment_files.length }, () => false);
|
||||
const booleanData = Array.from({length: response.data.data.attachment_files.length}, () => false);
|
||||
setAccordionStates(booleanData);
|
||||
setDetailsData(response.data)
|
||||
})
|
||||
@@ -60,13 +57,11 @@ const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type , han
|
||||
const newAccordionStates = accordionStates.map((state, i) => i === index ? !state : false);
|
||||
setAccordionStates(newAccordionStates);
|
||||
|
||||
if (!newAccordionStates[index])
|
||||
{
|
||||
if (!newAccordionStates[index]) {
|
||||
handleSizeChangeClick('sm');
|
||||
setHasImageShown(false);
|
||||
setIsSkeleton(false)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
handleSizeChangeClick('xl');
|
||||
setHasImageShown(true);
|
||||
setImageLink(detailsList.data.attachment_files[index])
|
||||
@@ -93,7 +88,6 @@ const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type , han
|
||||
return allowedTypes.includes(value.type);
|
||||
})
|
||||
});
|
||||
|
||||
const formik = useFormik({
|
||||
initialValues: {
|
||||
description: "",
|
||||
@@ -104,7 +98,13 @@ const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type , han
|
||||
const formData = new FormData();
|
||||
formData.append("proposed_amount", values.proposed_amount);
|
||||
if (values.description != "") formData.append("expert_description", values.description);
|
||||
if (values.confirm_img != null) formData.append("attachment", values.confirm_img);
|
||||
const attachment = [
|
||||
{
|
||||
title: "فایل ضمیمه کارتابل قیمت گذاری",
|
||||
file: values.confirm_img
|
||||
}
|
||||
];
|
||||
if (values.confirm_img != null) formData.append("attachment", JSON.stringify(attachment));
|
||||
requestServer(`${CONFIRM_MACHINARY_OFFICE}/${rowId}`, 'post', {
|
||||
data: formData,
|
||||
}).then((response) => {
|
||||
@@ -166,7 +166,7 @@ const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type , han
|
||||
<DialogContent>
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={hasImageShown ? 6 : 12}>
|
||||
{loading ? <LinearProgress /> : renderCustomAccordions()}
|
||||
{loading ? <LinearProgress/> : renderCustomAccordions()}
|
||||
<Stack spacing={2}>
|
||||
<Stack>
|
||||
<TextField
|
||||
@@ -237,8 +237,13 @@ const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type , han
|
||||
</Stack>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<Stack sx={{ display: hasImageShown ? 'flex' : 'none', alignItems: 'center', gap: 0.5 , justifyContent:'center'}}>
|
||||
<ImageContent imageLink={imageLink} isSkeleton={isSkeleton} setIsSkeleton={setIsSkeleton}/>
|
||||
<Stack sx={{
|
||||
display: hasImageShown ? 'flex' : 'none',
|
||||
alignItems: 'center',
|
||||
gap: 0.5,
|
||||
justifyContent: 'center'
|
||||
}}>
|
||||
<ImageContent imageLink={imageLink} isSkeleton={isSkeleton} setIsSkeleton={setIsSkeleton}/>
|
||||
</Stack>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
@@ -30,7 +30,13 @@ 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);
|
||||
const attachment = [
|
||||
{
|
||||
title: "فایل ضمیمه کارتابل قیمت گذاری",
|
||||
file: values.reject_img
|
||||
}
|
||||
];
|
||||
if (values.reject_img != null) formData.append("attachment", attachment);
|
||||
|
||||
requestServer(`${REJECT_MACHINARY_OFFICE}/${rowId}`, 'post', {
|
||||
data: formData,
|
||||
|
||||
Reference in New Issue
Block a user