add revert button
This commit is contained in:
@@ -218,6 +218,7 @@
|
||||
"navgan_id": "کد ناوگان",
|
||||
"vehicle_type": "نوع ماشین",
|
||||
"state_name": "وضعیت درخواست",
|
||||
"revert": "ارجاع به معاون حمل و نقل",
|
||||
"confirm": "تایید نهایی و ارجاع به بانک",
|
||||
"upload_file_unit": "فایل بارگذاری شده باید حداکثر 5Mb باشد",
|
||||
"upload_file_format": "فرمت قابل قبول : png,jpg,pdf",
|
||||
@@ -233,6 +234,7 @@
|
||||
"button-reserve-confirm": "رزرو",
|
||||
"city_name": "شهرستان",
|
||||
"plate_number": "پلاک",
|
||||
"refer_reason": "علت ارجاع",
|
||||
"statement_count": "تعداد صورت وضعیت",
|
||||
"id": "کد یکتا",
|
||||
"score": "اولویت",
|
||||
@@ -253,7 +255,7 @@
|
||||
"navgan_id": "کد ناوگان",
|
||||
"vehicle_type": "نوع ماشین",
|
||||
"state_name": "وضعیت درخواست",
|
||||
"confirm": "ارجاع به معاون حمل و نقل",
|
||||
"confirm": "تایید و ارجاع به معاون حمل و نقل",
|
||||
"upload_file": "فایل خود را بارگذاری کنید(اختیاری)",
|
||||
"upload_expert_img": "فایل گزارش کارشناسی را بارگذاری کنید",
|
||||
"upload_file_required": "وارد کردن گزارش کارشناسی الزامیست",
|
||||
@@ -352,6 +354,7 @@
|
||||
"TransportationAssistance": {
|
||||
"name": "نام",
|
||||
"city_name": "شهرستان",
|
||||
"refer_reason": "علت ارجاع",
|
||||
"plate_number": "پلاک",
|
||||
"id": "کد یکتا",
|
||||
"facility_bank": "سهم بانک",
|
||||
@@ -378,7 +381,8 @@
|
||||
"navgan_id": "کد ناوگان",
|
||||
"vehicle_type": "نوع ماشین",
|
||||
"state_name": "وضعیت درخواست",
|
||||
"confirm": "ارجاع به مدیر کل",
|
||||
"confirm": "تایید و ارجاع به مدیر کل",
|
||||
"revert": "ارجاع به کارتابل کارگروه",
|
||||
"upload_file_unit": "فایل بارگذاری شده باید حداکثر 5Mb باشد",
|
||||
"upload_file_format": "فرمت قابل قبول : png,jpg,pdf",
|
||||
"excel_report": "گزارش اکسل",
|
||||
@@ -488,7 +492,7 @@
|
||||
"updated_at": "تاریخ بروزرسانی"
|
||||
},
|
||||
"ConfirmDialog": {
|
||||
"confirm": "ارجاع",
|
||||
"confirm": "تایید",
|
||||
"month": "(ماه)",
|
||||
"context": "آیا از تایید این آیتم اطمینان دارید؟",
|
||||
"button-cancel": "بستن",
|
||||
@@ -580,6 +584,15 @@
|
||||
"description_error": "وارد کردن توضیحات الزامی است!",
|
||||
"choose_file": "انتخاب فایل"
|
||||
},
|
||||
"RevertDialog": {
|
||||
"typography": "آیا میخواهید این درخواست را رد کنید ؟",
|
||||
"revert": "ارجاع",
|
||||
"context": "آیا از عدم تایید این آیتم اطمینان دارید؟",
|
||||
"button-cancel": "بستن",
|
||||
"button-revert": "ارجاع",
|
||||
"description": "توضیحات خود را وارد نمائید",
|
||||
"description_error": "وارد کردن توضیحات الزامی است!"
|
||||
},
|
||||
"EditDialog": {
|
||||
"edit_approved_amount": "ویرایش مبلغ مصوب",
|
||||
"description_error": "وارد کردن توضیحات الزامی است!",
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
import useNotification from "@/lib/app/hooks/useNotification";
|
||||
import useRequest from "@/lib/app/hooks/useRequest";
|
||||
import {Button, DialogActions, DialogContent, Stack, TextField} from "@mui/material"
|
||||
import {useFormik} from "formik";
|
||||
import {useTranslations} from "next-intl";
|
||||
import * as Yup from "yup";
|
||||
|
||||
const RevertContent = ({rowId, mutate, setOpenRevertDialog}) => {
|
||||
const t = useTranslations();
|
||||
const requestServer = useRequest({auth: true})
|
||||
const {update_notification} = useNotification()
|
||||
|
||||
const validationSchema = Yup.object().shape({
|
||||
description: Yup.string().required(t("RevertDialog.description_error")),
|
||||
});
|
||||
|
||||
const formik = useFormik({
|
||||
initialValues: {
|
||||
description: "",
|
||||
},
|
||||
validationSchema,
|
||||
onSubmit: (values, {setSubmitting}) => {
|
||||
requestServer(`${REJECT_TRANSPORTATION_ASSISTANCE}/${rowId}`, 'post', {
|
||||
data: {
|
||||
expert_description : values.description
|
||||
},
|
||||
}).then(() => {
|
||||
setOpenRevertDialog(false)
|
||||
mutate()
|
||||
update_notification()
|
||||
}).catch(() => {
|
||||
}).finally(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const handleDescriptionChange = (event) => {
|
||||
formik.setFieldValue("description", event.target.value);
|
||||
formik.handleChange(event);
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<Stack spacing={2}>
|
||||
<Stack>
|
||||
<TextField
|
||||
name="description"
|
||||
multiline
|
||||
rows={8}
|
||||
label={t("RevertDialog.description")}
|
||||
value={formik.values.description}
|
||||
onChange={handleDescriptionChange}
|
||||
onBlur={formik.handleBlur("description")}
|
||||
error={
|
||||
formik.touched.description && Boolean(formik.errors.description)
|
||||
}
|
||||
helperText={formik.touched.description && formik.errors.description}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
sx={{mt: 1}}
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={() => setOpenRevertDialog(false)} variant="outlined" color="secondary"
|
||||
disabled={formik.isSubmitting} autoFocus>
|
||||
{t("RevertDialog.button-cancel")}
|
||||
</Button>
|
||||
<Button onClick={formik.handleSubmit} variant="contained" color="primary"
|
||||
disabled={formik.isSubmitting || !formik.dirty || !formik.isValid}>
|
||||
{t("RevertDialog.button-revert")}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</>
|
||||
)
|
||||
}
|
||||
export default RevertContent
|
||||
@@ -0,0 +1,25 @@
|
||||
import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material"
|
||||
import {useTranslations} from "next-intl";
|
||||
import {useState} from "react";
|
||||
import CallReceivedIcon from '@mui/icons-material/CallReceived';
|
||||
import RevertContent from "@/components/dashboard/navgan-province-manager/Form/RevertForm/RevertContent";
|
||||
|
||||
const Revert = ({rowId, mutate}) => {
|
||||
const t = useTranslations();
|
||||
const [openRevertDialog, setOpenRevertDialog] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Tooltip title={t("RevertDialog.revert")}>
|
||||
<IconButton color="primary" onClick={() => setOpenRevertDialog(true)}>
|
||||
<CallReceivedIcon/>
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog fullWidth open={openRevertDialog}
|
||||
PaperProps={{sx: {boxShadow: 'rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px'}}}>
|
||||
<DialogTitle>{t("NavganProvinceManager.revert")}</DialogTitle>
|
||||
<RevertContent mutate={mutate} rowId={rowId} setOpenRevertDialog={setOpenRevertDialog}/>
|
||||
</Dialog>
|
||||
</>
|
||||
)
|
||||
}
|
||||
export default Revert
|
||||
@@ -1,6 +1,7 @@
|
||||
import {Box} from "@mui/material";
|
||||
import Confirm from "./Form/ConfirmForm";
|
||||
import Reject from "./Form/RejectForm";
|
||||
import Revert from "@/components/dashboard/navgan-province-manager/Form/RevertForm";
|
||||
|
||||
const TableRow = ({row, mutate}) => {
|
||||
|
||||
@@ -10,6 +11,10 @@ const TableRow = ({row, mutate}) => {
|
||||
rowId={row.getValue("id")}
|
||||
mutate={mutate}
|
||||
/>
|
||||
<Revert
|
||||
rowId={row.getValue("id")}
|
||||
mutate={mutate}
|
||||
/>
|
||||
<Reject
|
||||
rowId={row.getValue("id")}
|
||||
mutate={mutate}
|
||||
|
||||
@@ -289,6 +289,20 @@ function DashboardPassengerOfficeComponent() {
|
||||
</Stack>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => row.refer_reason,
|
||||
id: "refer_reason",
|
||||
header: t("PassengerBoss.refer_reason"),
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterFn: "contains",
|
||||
columnFilterModeOptions: ["contains", "equals", "notEquals"],
|
||||
Cell: ({renderedCellValue, row}) => {
|
||||
return (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => row.state_name,
|
||||
id: "state_id",
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
import useNotification from "@/lib/app/hooks/useNotification";
|
||||
import useRequest from "@/lib/app/hooks/useRequest";
|
||||
import {Button, DialogActions, DialogContent, Stack, TextField} from "@mui/material"
|
||||
import {useFormik} from "formik";
|
||||
import {useTranslations} from "next-intl";
|
||||
import * as Yup from "yup";
|
||||
|
||||
const RevertContent = ({rowId, mutate, setOpenRevertDialog}) => {
|
||||
const t = useTranslations();
|
||||
const requestServer = useRequest({auth: true})
|
||||
const {update_notification} = useNotification()
|
||||
|
||||
const validationSchema = Yup.object().shape({
|
||||
description: Yup.string().required(t("RevertDialog.description_error")),
|
||||
});
|
||||
|
||||
const formik = useFormik({
|
||||
initialValues: {
|
||||
description: "",
|
||||
},
|
||||
validationSchema,
|
||||
onSubmit: (values, {setSubmitting}) => {
|
||||
requestServer(`${REJECT_TRANSPORTATION_ASSISTANCE}/${rowId}`, 'post', {
|
||||
data: {
|
||||
expert_description : values.description
|
||||
},
|
||||
}).then(() => {
|
||||
setOpenRevertDialog(false)
|
||||
mutate()
|
||||
update_notification()
|
||||
}).catch(() => {
|
||||
}).finally(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const handleDescriptionChange = (event) => {
|
||||
formik.setFieldValue("description", event.target.value);
|
||||
formik.handleChange(event);
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<Stack spacing={2}>
|
||||
<Stack>
|
||||
<TextField
|
||||
name="description"
|
||||
multiline
|
||||
rows={8}
|
||||
label={t("RevertDialog.description")}
|
||||
value={formik.values.description}
|
||||
onChange={handleDescriptionChange}
|
||||
onBlur={formik.handleBlur("description")}
|
||||
error={
|
||||
formik.touched.description && Boolean(formik.errors.description)
|
||||
}
|
||||
helperText={formik.touched.description && formik.errors.description}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
sx={{mt: 1}}
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={() => setOpenRevertDialog(false)} variant="outlined" color="secondary"
|
||||
disabled={formik.isSubmitting} autoFocus>
|
||||
{t("RevertDialog.button-cancel")}
|
||||
</Button>
|
||||
<Button onClick={formik.handleSubmit} variant="contained" color="primary"
|
||||
disabled={formik.isSubmitting || !formik.dirty || !formik.isValid}>
|
||||
{t("RevertDialog.button-revert")}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</>
|
||||
)
|
||||
}
|
||||
export default RevertContent
|
||||
@@ -0,0 +1,25 @@
|
||||
import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material"
|
||||
import {useTranslations} from "next-intl";
|
||||
import {useState} from "react";
|
||||
import CallReceivedIcon from '@mui/icons-material/CallReceived';
|
||||
import RevertContent from "@/components/dashboard/transportation-assistance/Form/RevertForm/RevertContent";
|
||||
|
||||
const Revert = ({rowId, mutate}) => {
|
||||
const t = useTranslations();
|
||||
const [openRevertDialog, setOpenRevertDialog] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Tooltip title={t("RevertDialog.revert")}>
|
||||
<IconButton color="primary" onClick={() => setOpenRevertDialog(true)}>
|
||||
<CallReceivedIcon/>
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog fullWidth open={openRevertDialog}
|
||||
PaperProps={{sx: {boxShadow: 'rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px'}}}>
|
||||
<DialogTitle>{t("TransportationAssistance.revert")}</DialogTitle>
|
||||
<RevertContent mutate={mutate} rowId={rowId} setOpenRevertDialog={setOpenRevertDialog}/>
|
||||
</Dialog>
|
||||
</>
|
||||
)
|
||||
}
|
||||
export default Revert
|
||||
@@ -1,6 +1,7 @@
|
||||
import {Box} from "@mui/material";
|
||||
import Confirm from "./Form/ConfirmForm";
|
||||
import Reject from "./Form/RejectForm";
|
||||
import Revert from "@/components/dashboard/transportation-assistance/Form/RevertForm";
|
||||
|
||||
const TableRow = ({row, mutate}) => {
|
||||
|
||||
@@ -10,6 +11,10 @@ const TableRow = ({row, mutate}) => {
|
||||
rowId={row.getValue("id")}
|
||||
mutate={mutate}
|
||||
/>
|
||||
<Revert
|
||||
rowId={row.getValue("id")}
|
||||
mutate={mutate}
|
||||
/>
|
||||
<Reject
|
||||
rowId={row.getValue("id")}
|
||||
mutate={mutate}
|
||||
|
||||
@@ -412,6 +412,20 @@ function DashboardTransportationAssistanceComponent() {
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => row.refer_reason,
|
||||
id: "refer_reason",
|
||||
header: t("TransportationAssistance.refer_reason"),
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterFn: "contains",
|
||||
columnFilterModeOptions: ["contains", "equals", "notEquals"],
|
||||
Cell: ({renderedCellValue, row}) => {
|
||||
return (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => row.state_name,
|
||||
id: "state_id",
|
||||
|
||||
Reference in New Issue
Block a user