Merge branch 'feature/amin_disable_revert' into 'develop'

Feature/amin disable revert

See merge request witel-front-end/loan-facilities/expert-v2!9
This commit is contained in:
AmirHossein Mahmoodi
2024-05-29 11:40:55 +00:00
7 changed files with 46 additions and 28 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.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(() => {

View File

@@ -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")}
</Button>
<Button onClick={formik.handleSubmit} variant="contained" color="primary"
disabled={formik.isSubmitting || !formik.dirty || !formik.isValid || true}>
disabled={formik.isSubmitting || !formik.dirty || !formik.isValid}>
{t("RevertDialog.button-revert")}
</Button>
</DialogActions>

View File

@@ -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 (
<Typography variant="body2">{renderedCellValue}</Typography>
<Typography variant="body2">{row.original.latest_history.action === 'refer'? row.original.latest_history.expert_description : null}</Typography>
)
},
},

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.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(() => {

View File

@@ -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")}
</Button>
<Button onClick={formik.handleSubmit} variant="contained" color="primary"
disabled={formik.isSubmitting || !formik.dirty || !formik.isValid || true}>
disabled={formik.isSubmitting || !formik.dirty || !formik.isValid}>
{t("RevertDialog.button-revert")}
</Button>
</DialogActions>

View File

@@ -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 (
<Typography variant="body2">{renderedCellValue}</Typography>
<Typography variant="body2">{row.original.latest_history.action === 'refer'? row.original.latest_history.expert_description : null}</Typography>
)
},
},

View File

@@ -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";