diff --git a/src/components/dashboard/navgan-province-manager/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/navgan-province-manager/Form/ConfirmForm/ConfirmContent.jsx index 0423bd0..312bbf2 100644 --- a/src/components/dashboard/navgan-province-manager/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/navgan-province-manager/Form/ConfirmForm/ConfirmContent.jsx @@ -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.latest_histories.length !== 0) { + let latest_attachments = [] + let attachments = [] + response.data.data.latest_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(() => { diff --git a/src/components/dashboard/navgan-province-manager/Form/RevertForm/RevertContent.jsx b/src/components/dashboard/navgan-province-manager/Form/RevertForm/RevertContent.jsx index 23f4268..64d1dec 100644 --- a/src/components/dashboard/navgan-province-manager/Form/RevertForm/RevertContent.jsx +++ b/src/components/dashboard/navgan-province-manager/Form/RevertForm/RevertContent.jsx @@ -4,6 +4,7 @@ import {Button, DialogActions, DialogContent, Stack, TextField} from "@mui/mater import {useFormik} from "formik"; import {useTranslations} from "next-intl"; import * as Yup from "yup"; +import {REFER_NAVGAN_PROVINCE_MANAGER} from "@/core/data/apiRoutes"; const RevertContent = ({rowId, mutate, setOpenRevertDialog}) => { const t = useTranslations(); @@ -20,7 +21,7 @@ const RevertContent = ({rowId, mutate, setOpenRevertDialog}) => { }, validationSchema, onSubmit: (values, {setSubmitting}) => { - requestServer(`${REJECT_TRANSPORTATION_ASSISTANCE}/${rowId}`, 'post', { + requestServer(`${REFER_NAVGAN_PROVINCE_MANAGER}/${rowId}`, 'post', { data: { expert_description: values.description }, @@ -69,7 +70,7 @@ const RevertContent = ({rowId, mutate, setOpenRevertDialog}) => { {t("RevertDialog.button-cancel")} diff --git a/src/components/dashboard/passenger-boss/index.jsx b/src/components/dashboard/passenger-boss/index.jsx index 76aea5b..a8205ff 100644 --- a/src/components/dashboard/passenger-boss/index.jsx +++ b/src/components/dashboard/passenger-boss/index.jsx @@ -271,16 +271,16 @@ function DashboardPassengerOfficeComponent() { ), }, { - accessorFn: (row) => row.refer_reason, - id: "refer_reason", + accessorFn: (row) => row.latest_history.expert_description, + id: "latest_history.expert_description", header: t("PassengerBoss.refer_reason"), enableColumnFilter: false, datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue, row}) => { + Cell: ({row}) => { return ( - {renderedCellValue} + {row.original.latest_history.action === 'refer'? row.original.latest_history.expert_description : null} ) }, }, diff --git a/src/components/dashboard/transportation-assistance/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/transportation-assistance/Form/ConfirmForm/ConfirmContent.jsx index c3b04b4..22f9f1f 100644 --- a/src/components/dashboard/transportation-assistance/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/transportation-assistance/Form/ConfirmForm/ConfirmContent.jsx @@ -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.latest_histories.length !== 0) { + let latest_attachments = [] + let attachments = [] + response.data.data.latest_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(() => { diff --git a/src/components/dashboard/transportation-assistance/Form/RevertForm/RevertContent.jsx b/src/components/dashboard/transportation-assistance/Form/RevertForm/RevertContent.jsx index 1a2e524..0528e80 100644 --- a/src/components/dashboard/transportation-assistance/Form/RevertForm/RevertContent.jsx +++ b/src/components/dashboard/transportation-assistance/Form/RevertForm/RevertContent.jsx @@ -4,6 +4,7 @@ import {Button, DialogActions, DialogContent, Stack, TextField} from "@mui/mater import {useFormik} from "formik"; import {useTranslations} from "next-intl"; import * as Yup from "yup"; +import {REFER_TRANSPORTATION_ASSISTANCE} from "@/core/data/apiRoutes"; const RevertContent = ({rowId, mutate, setOpenRevertDialog}) => { const t = useTranslations(); @@ -20,7 +21,7 @@ const RevertContent = ({rowId, mutate, setOpenRevertDialog}) => { }, validationSchema, onSubmit: (values, {setSubmitting}) => { - requestServer(`${REJECT_TRANSPORTATION_ASSISTANCE}/${rowId}`, 'post', { + requestServer(`${REFER_TRANSPORTATION_ASSISTANCE}/${rowId}`, 'post', { data: { expert_description : values.description }, @@ -69,7 +70,7 @@ const RevertContent = ({rowId, mutate, setOpenRevertDialog}) => { {t("RevertDialog.button-cancel")} diff --git a/src/components/dashboard/transportation-assistance/index.jsx b/src/components/dashboard/transportation-assistance/index.jsx index a807635..62efc0a 100644 --- a/src/components/dashboard/transportation-assistance/index.jsx +++ b/src/components/dashboard/transportation-assistance/index.jsx @@ -413,16 +413,16 @@ function DashboardTransportationAssistanceComponent() { ), }, { - accessorFn: (row) => row.refer_reason, - id: "refer_reason", + accessorFn: (row) => row.latest_history.expert_description, + id: "latest_history.expert_description", header: t("TransportationAssistance.refer_reason"), enableColumnFilter: false, datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue, row}) => { + Cell: ({row}) => { return ( - {renderedCellValue} + {row.original.latest_history.action === 'refer'? row.original.latest_history.expert_description : null} ) }, }, diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index f0d4774..841d6f4 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -56,6 +56,8 @@ export const CONFIRM_TRANSPORTATION_ASSISTANCE = export const REJECT_TRANSPORTATION_ASSISTANCE = BASE_URL + "/dashboard/transportation_assistant/reject"; +export const REFER_TRANSPORTATION_ASSISTANCE = + BASE_URL + "/dashboard/transportation_assistant/refer"; export const EXPORT_TRANSPORTATION_ASSISTANCE = BASE_URL + "/dashboard/transportation_assistant/export"; //transportation assistance @@ -103,6 +105,8 @@ export const CONFIRM_NAVGAN_PROVINCE_MANAGER = export const REJECT_NAVGAN_PROVINCE_MANAGER = BASE_URL + "/dashboard/province_manager/reject"; +export const REFER_NAVGAN_PROVINCE_MANAGER = + BASE_URL + "/dashboard/province_manager/refer"; export const EXPORT_NAVGAN_PROVINCE_MANAGER = BASE_URL + "/dashboard/province_manager/export";