remove conflicts
This commit is contained in:
@@ -38,6 +38,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type, hand
|
||||
const [showAddIconB, setShowAddIconB] = 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);
|
||||
@@ -48,8 +49,14 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type, hand
|
||||
useEffect(() => {
|
||||
requestServer(`${EXPORT_PASSENGER_BOSS_DETAILS}/${rowId}`, 'get')
|
||||
.then((response) => {
|
||||
const booleanData = Array.from({length: response.data.data.attachment_files.length}, () => false);
|
||||
setAccordionStates(booleanData);
|
||||
const allAttachments = [];
|
||||
response.data.data.histories.map((history) => {
|
||||
history.attachments.map((attachment) => {
|
||||
allAttachments.push(attachment);
|
||||
});
|
||||
});
|
||||
setDetailsData(response.data);
|
||||
setAttachmentsData(allAttachments);
|
||||
setDetailsData(response.data)
|
||||
})
|
||||
.catch(() => {
|
||||
@@ -58,6 +65,13 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type, hand
|
||||
});
|
||||
}, []);
|
||||
|
||||
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);
|
||||
@@ -69,7 +83,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type, hand
|
||||
} else {
|
||||
handleSizeChangeClick('xl');
|
||||
setHasImageShown(true);
|
||||
setImageLink(detailsList.data.attachment_files[index])
|
||||
setImageLink(attachmentsData[index])
|
||||
setIsSkeleton(true)
|
||||
}
|
||||
};
|
||||
@@ -131,7 +145,6 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type, hand
|
||||
requestServer(`${CONFIRM_PASSENGER_BOSS}/${rowId}`, 'post',{
|
||||
notification: true,
|
||||
data: formData,
|
||||
notification: true
|
||||
}).then((response) => {
|
||||
setOpenConfirmDialog(false)
|
||||
mutate()
|
||||
@@ -184,8 +197,8 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type, hand
|
||||
};
|
||||
|
||||
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}`}
|
||||
@@ -193,13 +206,12 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type, hand
|
||||
hasAccordionOpened={null}
|
||||
handleAccordionChange={() => handleAccordionChange(index)}
|
||||
accordionIndex={index}
|
||||
downloadFile={file.attachment}
|
||||
downloadFile={file.file}
|
||||
/>
|
||||
));
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
|
||||
Reference in New Issue
Block a user