show attachments

This commit is contained in:
2024-05-29 13:20:40 +03:30
parent 77be6b0e2c
commit 0b656ce9cb
2 changed files with 28 additions and 16 deletions

View File

@@ -53,14 +53,20 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl
useEffect(() => {
requestServer(`${CONFIRM_PROVINCE_MANAGER_DETAILS}/${rowId}`, 'get')
.then((response) => {
const allAttachments = [];
response.data.data.histories.map((history) => {
history.attachments.map((attachment) => {
allAttachments.push(attachment);
});
});
setAttachmentsData(allAttachments);
setDetailsData(response.data);
if (response.data.data.histories.length !== 0) {
let latest_attachments = []
let attachments = []
response.data.data.histories.map((allAttachment) => {
if (allAttachment.previous_state_id === 4 || allAttachment.previous_state_id === 5) {
if (!latest_attachments.includes(allAttachment.previous_state_id)) {
attachments = [...attachments, ...allAttachment.attachments]
latest_attachments.push(allAttachment.previous_state_id)
}
}
setDetailsData(response.data);
setAttachmentsData(attachments);
})
}
})
.catch(() => {
}).finally(() => {

View File

@@ -44,14 +44,20 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl
useEffect(() => {
requestServer(`${GET_TRANSPORTATION_ASSISTANCE_DETAILS}/${rowId}`, 'get')
.then((response) => {
const allAttachments = [];
response.data.data.histories.map((history) => {
history.attachments.map((attachment) => {
allAttachments.push(attachment);
});
});
setDetailsData(response.data);
setAttachmentsData(allAttachments);
if (response.data.data.histories.length !== 0) {
let latest_attachments = []
let attachments = []
response.data.data.histories.map((allAttachment) => {
if (allAttachment.previous_state_id !== 4)
return
if (!latest_attachments.includes(allAttachment.previous_state_id)) {
attachments = [...attachments, ...allAttachment.attachments]
latest_attachments.push(allAttachment.previous_state_id)
}
})
setDetailsData(response.data);
setAttachmentsData(attachments);
}
})
.catch(() => {
}).finally(() => {