From 9caf417101f03227f8b529cb3016f397c9c5648f Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Sun, 16 Jul 2023 14:37:24 +0330 Subject: [PATCH 1/9] transportation assistance design --- public/locales/fa/app.json | 10 + .../Form/ConfirmForm.jsx | 41 ++++ .../Form/RejectForm.jsx | 35 ++++ .../TableRowActions.jsx | 49 +++++ .../TableTollbar.jsx | 13 ++ .../transportation-assistance/index.jsx | 177 ++++++++++++++++++ src/core/data/apiRoutes.js | 11 ++ .../transportation-assistance/index.jsx | 23 +++ 8 files changed, 359 insertions(+) create mode 100644 src/components/dashboard/transportation-assistance/Form/ConfirmForm.jsx create mode 100644 src/components/dashboard/transportation-assistance/Form/RejectForm.jsx create mode 100644 src/components/dashboard/transportation-assistance/TableRowActions.jsx create mode 100644 src/components/dashboard/transportation-assistance/TableTollbar.jsx create mode 100644 src/components/dashboard/transportation-assistance/index.jsx create mode 100644 src/pages/dashboard/transportation-assistance/index.jsx diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 1a505df..d5d2da8 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -101,6 +101,16 @@ "vehicle_type": "نوع ماشین", "state_name": "وضعیت درخواست" }, + "TransportationAssistance": { + "name": "نام", + "id": "کد ملی", + "phone_number": "موبایل", + "created_at": "تاریخ درخواست", + "updated_at": "تاریخ بروزرسانی", + "navgan_id": "کد ناوگان", + "vehicle_type": "نوع ماشین", + "state_name": "وضعیت درخواست" + }, "MachinaryOffice": { "name": "نام", "id": "کد ملی", diff --git a/src/components/dashboard/transportation-assistance/Form/ConfirmForm.jsx b/src/components/dashboard/transportation-assistance/Form/ConfirmForm.jsx new file mode 100644 index 0000000..132b850 --- /dev/null +++ b/src/components/dashboard/transportation-assistance/Form/ConfirmForm.jsx @@ -0,0 +1,41 @@ +import { CONFIRM_TRANSPORTATION_ASSISTANCE } from "@/core/data/apiRoutes"; +import { + Dialog, + DialogTitle, + DialogContent, + DialogContentText, + DialogActions, + Button, +} from "@mui/material"; +import { useTranslations } from "next-intl"; + +const ConfirmForm = ({ + open, + handleClose, + handleDelete, + rowId, + confirmData, +}) => { + const t = useTranslations(); + const handleConfirm = () => { + handleDelete(); + confirmData(CONFIRM_TRANSPORTATION_ASSISTANCE, rowId); + }; + return ( + + {t("ConfirmDialog.confirm")} + + {t("ConfirmDialog.context")} + + + + + + + ); +}; +export default ConfirmForm; diff --git a/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx b/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx new file mode 100644 index 0000000..5abd534 --- /dev/null +++ b/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx @@ -0,0 +1,35 @@ +import { REJECT_TRANSPORTATION_ASSISTANCE } from "@/core/data/apiRoutes"; +import { + Dialog, + DialogTitle, + DialogContent, + DialogContentText, + DialogActions, + Button, +} from "@mui/material"; +import { useTranslations } from "next-intl"; + +const RejectForm = ({ open, handleClose, handleDelete, rowId, rejectData }) => { + const t = useTranslations(); + const handleRejectRequest = () => { + handleDelete(); + rejectData(REJECT_TRANSPORTATION_ASSISTANCE, rowId); + }; + return ( + + {t("RejectDialog.reject")} + + {t("RejectDialog.context")} + + + + + + + ); +}; +export default RejectForm; diff --git a/src/components/dashboard/transportation-assistance/TableRowActions.jsx b/src/components/dashboard/transportation-assistance/TableRowActions.jsx new file mode 100644 index 0000000..f5ec46b --- /dev/null +++ b/src/components/dashboard/transportation-assistance/TableRowActions.jsx @@ -0,0 +1,49 @@ +import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; +import ThumbDownIcon from "@mui/icons-material/ThumbDown"; +import { Box, IconButton } from "@mui/material"; +import { useContext } from "react"; +import { DataTableContext } from "@/lib/app/contexts/DataTableContext"; +import ConfirmForm from "./Form/ConfirmForm"; +import RejectForm from "./Form/RejectForm"; + +const TableRowActions = ({ row }) => { + const { + openConfirmDialog, + openRejectDialog, + handleOpenConfirmDialog, + handleOpenRejectDialog, + handleCloseConfirmDialog, + handleCloseRejectDialog, + handleConfirmDialog, + handleRejectDialog, + rowId, + confirmData, + rejectData, + } = useContext(DataTableContext); + return ( + + handleOpenConfirmDialog(row)}> + + + + handleOpenRejectDialog(row)}> + + + + + ); +}; + +export default TableRowActions; diff --git a/src/components/dashboard/transportation-assistance/TableTollbar.jsx b/src/components/dashboard/transportation-assistance/TableTollbar.jsx new file mode 100644 index 0000000..3f06d3b --- /dev/null +++ b/src/components/dashboard/transportation-assistance/TableTollbar.jsx @@ -0,0 +1,13 @@ +import { Stack, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; + +function TableToolbar() { + const t = useTranslations(); + return ( + + + + ); +} + +export default TableToolbar; diff --git a/src/components/dashboard/transportation-assistance/index.jsx b/src/components/dashboard/transportation-assistance/index.jsx new file mode 100644 index 0000000..6dd3ccf --- /dev/null +++ b/src/components/dashboard/transportation-assistance/index.jsx @@ -0,0 +1,177 @@ +import DataTableStructure from "@/core/components/DatatableStructure"; +import DashboardLayouts from "@/layouts/dashboardLayouts"; +import { Box, Typography } from "@mui/material"; +import { useMemo } from "react"; +// import TableToolbar from "./TableTollbar"; +import { GET_TRANSPORTATION_ASSISTANCE } from "@/core/data/apiRoutes"; +import { useTranslations } from "next-intl"; +import TableRowActions from "./TableRowActions"; + +function DashboardTransportationAssistanceComponent() { + const t = useTranslations(); + const columns = useMemo( + () => [ + { + accessorFn: (row) => row.name, + id: "name", + header: t("TransportationAssistance.name"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.id, + id: "id", + header: t("TransportationAssistance.id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.phone_number, + id: "phone_number", + header: t("TransportationAssistance.phone_number"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.created_at, + id: "created_at", + header: t("TransportationAssistance.created_at"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.updated_at, + id: "updated_at", + header: t("TransportationAssistance.updated_at"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.navgan_id, + id: "navgan_id", + header: t("TransportationAssistance.navgan_id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.vehicle_type, + id: "vehicle_type", + header: t("TransportationAssistance.vehicle_type"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.state_name, + id: "state_id", + header: t("TransportationAssistance.state_name"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + filterSelectOptions: [ + { text: "Active", value: "0" }, + { text: "Deactive", value: "1" }, + ], + filterVariant: "select", + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + ], + [] + ); + return ( + + + } + enableLastUpdate={true} + enablePinning={true} + enableDensityToggle={true} + enableColumnFilters={true} + enableHiding={true} + enableFullScreenToggle={false} + enableGlobalFilter={false} + enableColumnResizing={false} // if you want true this you shold change renderRowActions props ** see https://www.material-react-table.com/docs/guides/row-actions + enableRowActions={true} + renderRowActions={({ row }) => } + /> + + + ); +} + +export default DashboardTransportationAssistanceComponent; diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index 5c73fcf..702c9c9 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -22,3 +22,14 @@ export const CONFIRM_PASSENGER_OFFICE = export const REJECT_PASSENGER_OFFICE = BASE_URL + "/dashboard/passenger_office_chief/reject"; //passenger office + +//transportation assistance +export const GET_TRANSPORTATION_ASSISTANCE = + BASE_URL + "/dashboard/transportation_asisstants/show"; + +export const CONFIRM_TRANSPORTATION_ASSISTANCE = + BASE_URL + "/dashboard/transportation_asisstants/confirm"; + +export const REJECT_TRANSPORTATION_ASSISTANCE = + BASE_URL + "/dashboard/transportation_asisstants/reject"; +//transportation assistance diff --git a/src/pages/dashboard/transportation-assistance/index.jsx b/src/pages/dashboard/transportation-assistance/index.jsx new file mode 100644 index 0000000..9c089ad --- /dev/null +++ b/src/pages/dashboard/transportation-assistance/index.jsx @@ -0,0 +1,23 @@ +import DashboardTransportationAssistanceComponent from "@/components/dashboard/transportation-assistance"; +import TitlePage from "@/core/components/TitlePage"; +import WithAuthMiddleware from "@/middlewares/WithAuth"; +import { parse } from "next-useragent"; + +export default function TransportationAssistance() { + return ( + + + + + ); +} + +export async function getServerSideProps({ req, locale }) { + const { isBot } = parse(req.headers["user-agent"]); + return { + props: { + messages: (await import(`&/locales/${locale}/app.json`)).default, + isBot, + }, + }; +} From 1139ba0636af684be3e79092c06bf9daf8346ac9 Mon Sep 17 00:00:00 2001 From: Yasiu1376 Date: Sun, 16 Jul 2023 17:04:29 +0330 Subject: [PATCH 2/9] debug api routes --- src/core/data/apiRoutes.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index 0f57675..42a6029 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -23,7 +23,6 @@ export const REJECT_PASSENGER_OFFICE = BASE_URL + "/dashboard/passenger_office_chief/reject"; //passenger office -<<<<<<< HEAD //transportation assistance export const GET_TRANSPORTATION_ASSISTANCE = BASE_URL + "/dashboard/transportation_asisstants/show"; @@ -34,7 +33,6 @@ export const CONFIRM_TRANSPORTATION_ASSISTANCE = export const REJECT_TRANSPORTATION_ASSISTANCE = BASE_URL + "/dashboard/transportation_asisstants/reject"; //transportation assistance -======= //machinary office export const GET_MACHINARY_OFFICE = BASE_URL + "/dashboard/machinery_expert/show"; @@ -45,4 +43,3 @@ export const CONFIRM_MACHINARY_OFFICE = export const REJECT_MACHINARY_OFFICE = BASE_URL + "/dashboard/machinery_expert/reject"; //passenger office ->>>>>>> a683c4029fdd3b3cae26a4cc7823835ad7e687b1 From c5b8cd964f37366dfca5f5f190964769dee22b08 Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Mon, 17 Jul 2023 11:59:19 +0330 Subject: [PATCH 3/9] debug datatable --- public/locales/fa/app.json | 5 +- .../dashboard/machinary-office/index.jsx | 32 +++++-- .../dashboard/passenger-office/index.jsx | 89 ++++++++++++++----- .../transportation-assistance/index.jsx | 39 +++++--- 4 files changed, 127 insertions(+), 38 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 8170a99..b6bd06f 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -93,6 +93,7 @@ }, "PassengerOffice": { "name": "نام", + "id": "کد یکتا", "national_id": "کد ملی", "phone_number": "موبایل", "created_at": "تاریخ درخواست", @@ -103,7 +104,8 @@ }, "TransportationAssistance": { "name": "نام", - "id": "کد ملی", + "id": "کد یکتا", + "national_id": "کد ملی", "phone_number": "موبایل", "created_at": "تاریخ درخواست", "updated_at": "تاریخ بروزرسانی", @@ -113,6 +115,7 @@ }, "MachinaryOffice": { "name": "نام", + "id": "کد یکتا", "national_id": "کد ملی", "phone_number": "موبایل", "created_at": "تاریخ درخواست", diff --git a/src/components/dashboard/machinary-office/index.jsx b/src/components/dashboard/machinary-office/index.jsx index bcd3eb4..2a8feeb 100644 --- a/src/components/dashboard/machinary-office/index.jsx +++ b/src/components/dashboard/machinary-office/index.jsx @@ -6,11 +6,31 @@ import { useMemo } from "react"; import { GET_MACHINARY_OFFICE } from "@/core/data/apiRoutes"; import { useTranslations } from "next-intl"; import TableRowActions from "./TableRowActions"; +import { format } from "date-fns-jalali"; function DashboardMachinaryOfficeComponent() { const t = useTranslations(); const columns = useMemo( () => [ + { + accessorFn: (row) => row.id, + id: "id", + header: t("PassengerOffice.id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, { accessorFn: (row) => row.name, id: "name", @@ -62,7 +82,7 @@ function DashboardMachinaryOfficeComponent() { ), }, { - accessorFn: (row) => row.created_at, + accessorFn: (row) => format(new Date(row.created_at), "yyyy/mm/dd"), id: "created_at", header: t("MachinaryOffice.created_at"), enableColumnFilter: true, @@ -81,7 +101,7 @@ function DashboardMachinaryOfficeComponent() { ), }, { - accessorFn: (row) => row.updated_at, + accessorFn: (row) => format(new Date(row.updated_at), "yyyy/mm/dd"), id: "updated_at", header: t("MachinaryOffice.updated_at"), enableColumnFilter: true, @@ -137,11 +157,9 @@ function DashboardMachinaryOfficeComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - filterSelectOptions: [ - { text: "Active", value: "0" }, - { text: "Deactive", value: "1" }, - ], - filterVariant: "select", + // filterSelectOptions: [ + // ], + // filterVariant: "select", Cell: ({ renderedCellValue }) => ( {renderedCellValue} ), diff --git a/src/components/dashboard/passenger-office/index.jsx b/src/components/dashboard/passenger-office/index.jsx index 9313a5b..429c16e 100644 --- a/src/components/dashboard/passenger-office/index.jsx +++ b/src/components/dashboard/passenger-office/index.jsx @@ -6,11 +6,34 @@ import { useMemo } from "react"; import { GET_PASSENGER_OFFICE } from "@/core/data/apiRoutes"; import { useTranslations } from "next-intl"; import TableRowActions from "./TableRowActions"; +import { format } from "date-fns-jalali"; +import { DateTimePicker, LocalizationProvider } from "@mui/x-date-pickers"; +import { AdapterDateFnsJalali } from "@mui/x-date-pickers/AdapterDateFnsJalali"; +import moment from "moment"; function DashboardPassengerOfficeComponent() { const t = useTranslations(); const columns = useMemo( () => [ + { + accessorFn: (row) => row.id, + id: "id", + header: t("PassengerOffice.id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, { accessorFn: (row) => row.name, id: "name", @@ -62,26 +85,54 @@ function DashboardPassengerOfficeComponent() { ), }, { - accessorFn: (row) => row.created_at, + accessorFn: (row) => + format(new Date(row.created_at), "yyyy/mm/dd HH:mm"), id: "created_at", header: t("PassengerOffice.created_at"), enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), + datatype: "date", + filterFn: "lessThan", + columnFilterModeOptions: ["lessThan", "greaterThan"], + Cell: ({ renderedCellValue }) => { + return {renderedCellValue}; + }, + Header: ({ column }) => {column.columnDef.header}, + Filter: ({ column }) => { + return ( + + { + console.log({ newValue }); + const date = new Date(newValue); + console.log({ date }); + const formattedDate = moment(date) + .locale("en") + .format("YYYY-MM-DD HH:mm"); + console.log(formattedDate); + // const formattedDate = format(date, "YYYY-MM-DD HH:mm"); + // console.log( + // "moment", + // moment(formattedDate) + // .locale("en") + // .format("YYYY-MM-DD HH:mm") + // ); + column.setFilterValue(formattedDate); + }} + slotProps={{ + textField: { + helperText: `Filter Mode: ${column.columnDef._filterFn}`, + sx: { minWidth: "120px" }, + variant: "standard", + }, + }} + value={column.getFilterValue()} + /> + + ); + }, }, { - accessorFn: (row) => row.updated_at, + accessorFn: (row) => format(new Date(row.updated_at), "yyyy/mm/dd"), id: "updated_at", header: t("PassengerOffice.updated_at"), enableColumnFilter: true, @@ -137,11 +188,9 @@ function DashboardPassengerOfficeComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - filterSelectOptions: [ - { text: "Active", value: "0" }, - { text: "Deactive", value: "1" }, - ], - filterVariant: "select", + // filterSelectOptions: [ + // ], + // filterVariant: "select", Cell: ({ renderedCellValue }) => ( {renderedCellValue} ), diff --git a/src/components/dashboard/transportation-assistance/index.jsx b/src/components/dashboard/transportation-assistance/index.jsx index 6dd3ccf..8a24978 100644 --- a/src/components/dashboard/transportation-assistance/index.jsx +++ b/src/components/dashboard/transportation-assistance/index.jsx @@ -6,11 +6,31 @@ import { useMemo } from "react"; import { GET_TRANSPORTATION_ASSISTANCE } from "@/core/data/apiRoutes"; import { useTranslations } from "next-intl"; import TableRowActions from "./TableRowActions"; +import { format } from "date-fns-jalali"; function DashboardTransportationAssistanceComponent() { const t = useTranslations(); const columns = useMemo( () => [ + { + accessorFn: (row) => row.id, + id: "id", + header: t("TransportationAssistance.id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, { accessorFn: (row) => row.name, id: "name", @@ -23,10 +43,11 @@ function DashboardTransportationAssistanceComponent() { {renderedCellValue} ), }, + { - accessorFn: (row) => row.id, - id: "id", - header: t("TransportationAssistance.id"), + accessorFn: (row) => row.national_id, + id: "national_id", + header: t("TransportationAssistance.national_id"), enableColumnFilter: true, datatype: "numeric", filterFn: "equals", @@ -62,7 +83,7 @@ function DashboardTransportationAssistanceComponent() { ), }, { - accessorFn: (row) => row.created_at, + accessorFn: (row) => format(new Date(row.created_at), "yyyy/mm/dd"), id: "created_at", header: t("TransportationAssistance.created_at"), enableColumnFilter: true, @@ -81,7 +102,7 @@ function DashboardTransportationAssistanceComponent() { ), }, { - accessorFn: (row) => row.updated_at, + accessorFn: (row) => format(new Date(row.updated_at), "yyyy/mm/dd"), id: "updated_at", header: t("TransportationAssistance.updated_at"), enableColumnFilter: true, @@ -137,11 +158,9 @@ function DashboardTransportationAssistanceComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - filterSelectOptions: [ - { text: "Active", value: "0" }, - { text: "Deactive", value: "1" }, - ], - filterVariant: "select", + // filterSelectOptions: [ + // ], + // filterVariant: "select", Cell: ({ renderedCellValue }) => ( {renderedCellValue} ), From fa8e0ba1e755188ffc503ef0db5ac2206d50dbce Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Mon, 17 Jul 2023 14:27:47 +0330 Subject: [PATCH 4/9] prevent proposed amount to get negetive values --- .../dashboard/machinary-office/Form/ConfirmForm.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx index 754abce..4e7ac76 100644 --- a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx @@ -41,7 +41,9 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { setDescription(event.target.value); }; const handleAmountChange = (event) => { - setProposedAmount(event.target.value); + if (/^\d*$/.test(event.target.value)) { + setProposedAmount(event.target.value); + } formik.handleChange(event); }; @@ -65,6 +67,11 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { name="proposed_amount" label={t("MachinaryOffice.proposed_amount")} type="number" + inputProps={{ + min: 0, + inputMode: "numeric", + pattern: "[0-9]*", + }} variant="outlined" value={proposedAmount} onChange={handleAmountChange} From db19c29f896cd4cddde1545773014e0eddbfea6e Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Tue, 18 Jul 2023 09:49:09 +0330 Subject: [PATCH 5/9] description in cinfirm form --- public/locales/fa/app.json | 3 +- .../passenger-office/Form/ConfirmForm.jsx | 37 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index b6bd06f..b553d3b 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -130,7 +130,8 @@ "context": "آیا از تایید این آیتم اطمینان دارید", "button-confirm": "تایید", "button-cancel": "بستن", - "amount_error": "وارد کردن مقدار پیشنهادی الزامیست" + "amount_error": "وارد کردن مقدار پیشنهادی الزامیست", + "description_error": "وارد کردن توضیحات الزامی است!" }, "RejectDialog": { "reject": "عدم تایید", diff --git a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx index 43c6bb3..08bbde6 100644 --- a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx @@ -6,11 +6,36 @@ import { DialogContentText, DialogActions, Button, + TextField, } from "@mui/material"; +import { useFormik } from "formik"; import { useTranslations } from "next-intl"; +import { useState } from "react"; const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { const t = useTranslations(); + const [description, setDescription] = useState(""); + + const formik = useFormik({ + initialValues: { + description: "", + fileData: null, + }, + onSubmit: () => { + const formData = new FormData(); + if (description !== "") + formData.append("expert_description", description); + // if (fileData !== null) formData.append("file", fileData); + handleClose(); + confirmData(CONFIRM_PASSENGER_OFFICE, rowId, formData); + }, + }); + + const handleDescriptionChange = (event) => { + setDescription(event.target.value); + formik.handleChange(event); + }; + const handleConfirm = () => { handleClose(); confirmData(CONFIRM_PASSENGER_OFFICE, rowId); @@ -20,6 +45,18 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { {t("ConfirmDialog.confirm")} {t("ConfirmDialog.context")} + + + {/* */} + + + {formik.errors.fileData && formik.errors.fileData} + {formik.values.fileData && + `Selected file: ${formik.values.fileData.name}`} + + - - {/* */} {formik.errors.fileData && formik.errors.fileData} - {formik.values.fileData && - `Selected file: ${formik.values.fileData.name}`} -