diff --git a/public/images/loading_logo.svg b/public/images/loading_logo.svg
new file mode 100644
index 0000000..48fde43
--- /dev/null
+++ b/public/images/loading_logo.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json
index 4450c55..98bb15d 100644
--- a/public/locales/fa/app.json
+++ b/public/locales/fa/app.json
@@ -6,6 +6,7 @@
"login": "ورود",
"login_expert": "ورود کارشناس",
"expert": "کارشناس",
+ "last_updated_at": "اخرین بروز رسانی",
"header": {
"open_profile": "پروفایل",
"edit_profile": "ویرایش پروفایل",
@@ -46,13 +47,11 @@
},
"Dashboard": {
"dashboard_page": "داشبورد",
-<<<<<<< HEAD
"passenger_boss": "رئیس مسافر",
- "change_password": "تغییر رمز عبور"
-=======
"change_password": "تغییر رمز عبور",
+ "passenger_office_page": "اداره مسافر",
+ "machinary_office_page": "ماشین آلات",
"edit_profile": "ویرایش پروفایل"
->>>>>>> 135f6d1e2f3495abe68e3ca758870023dcd85d76
},
"MuiDatePicker": {
"date_picker_birthday": "تاریخ"
@@ -92,5 +91,41 @@
"warning_static_text": "خطا سرور",
"success_static_text": "عملیات شما با موفقیت انجام شد",
"pending": "در حال انجام..."
+ },
+ "PassengerOffice": {
+ "name": "نام",
+ "national_id": "کد ملی",
+ "phone_number": "موبایل",
+ "created_at": "تاریخ درخواست",
+ "updated_at": "تاریخ بروزرسانی",
+ "navgan_id": "کد ناوگان",
+ "vehicle_type": "نوع ماشین",
+ "state_name": "وضعیت درخواست"
+ },
+ "MachinaryOffice": {
+ "name": "نام",
+ "national_id": "کد ملی",
+ "phone_number": "موبایل",
+ "created_at": "تاریخ درخواست",
+ "updated_at": "تاریخ بروزرسانی",
+ "navgan_id": "کد ناوگان",
+ "vehicle_type": "نوع ماشین",
+ "state_name": "وضعیت درخواست",
+ "proposed_amount": "مقدار پیشنهادی"
+ },
+ "ConfirmDialog": {
+ "confirm": "تایید",
+ "context": "آیا از تایید این آیتم اطمینان دارید",
+ "button-confirm": "تایید",
+ "button-cancel": "بستن",
+ "amount_error": "وارد کردن مقدار پیشنهادی الزامیست"
+ },
+ "RejectDialog": {
+ "reject": "عدم تایید",
+ "context": "آیا از عدم تایید این آیتم اطمینان دارید",
+ "button-reject": "عدم تایید",
+ "button-cancel": "بستن",
+ "description": "توضیحات",
+ "description_error": "وارد کردن توضیحات الزامی است!"
}
}
diff --git a/public/locales/fa/datatable.js b/public/locales/fa/datatable.js
index e42208f..819a84b 100644
--- a/public/locales/fa/datatable.js
+++ b/public/locales/fa/datatable.js
@@ -1,92 +1,92 @@
export const FA_DATATABLE_LOCALIZATION = {
- actions: "Actions",
- and: "and",
- cancel: "Cancel",
- changeFilterMode: "Change filter mode",
- changeSearchMode: "Change search mode",
- clearFilter: "Clear filter",
- clearSearch: "Clear search",
- clearSort: "Clear sort",
- clickToCopy: "Click to copy",
- collapse: "Collapse",
- collapseAll: "Collapse all",
- columnActions: "Column Actions",
- copiedToClipboard: "Copied to clipboard",
- dropToGroupBy: "Drop to group by {column}",
- edit: "Edit",
- expand: "Expand",
- expandAll: "Expand all",
- filterArrIncludes: "Includes",
- filterArrIncludesAll: "Includes all",
- filterArrIncludesSome: "Includes",
- filterBetween: "Between",
- filterBetweenInclusive: "Between Inclusive",
- filterByColumn: "Filter by {column}",
- filterContains: "Contains",
- filterEmpty: "Empty",
- filterEndsWith: "Ends With",
- filterEquals: "Equals",
- filterEqualsString: "Equals",
- filterFuzzy: "Fuzzy",
- filterGreaterThan: "Greater Than",
- filterGreaterThanOrEqualTo: "Greater Than Or Equal To",
- filterInNumberRange: "Between",
- filterIncludesString: "Contains",
- filterIncludesStringSensitive: "Contains",
- filterLessThan: "Less Than",
- filterLessThanOrEqualTo: "Less Than Or Equal To",
- filterMode: "Filter Mode: {filterType}",
- filterNotEmpty: "Not Empty",
- filterNotEquals: "Not Equals",
- filterStartsWith: "Starts With",
- filterWeakEquals: "Equals",
- filteringByColumn: "Filtering by {column} - {filterType} {filterValue}",
- goToFirstPage: "Go to first page",
- goToLastPage: "Go to last page",
- goToNextPage: "Go to next page",
- goToPreviousPage: "Go to previous page",
- grab: "Grab",
- groupByColumn: "Group by {column}",
- groupedBy: "Grouped by ",
- hideAll: "Hide all",
- hideColumn: "Hide {column} column",
- max: "Max",
- min: "Min",
- move: "Move",
- noRecordsToDisplay: "No records to display",
- noResultsFound: "No results found",
- of: "of",
- or: "or",
- pinToLeft: "Pin to left",
- pinToRight: "Pin to right",
- resetColumnSize: "Reset column size",
- resetOrder: "Reset order",
- rowActions: "Row Actions",
+ actions: "عملیات",
+ and: "و",
+ cancel: "لغو",
+ changeFilterMode: "تغییر حالت فیلتر",
+ changeSearchMode: "تغییر حالت جستجو",
+ clearFilter: "پاک کردن فیلتر",
+ clearSearch: "پاک کردن جستجو",
+ clearSort: "پاک کردن مرتب سازی",
+ clickToCopy: "کلیک برای کپی",
+ collapse: "جمع شدن",
+ collapseAll: "جمع شدن همه",
+ columnActions: "عملیات ستون",
+ copiedToClipboard: "کپی شد",
+ dropToGroupBy: "رها کردن برای گروه بندی بر اساس {column}",
+ edit: "ویرایش",
+ expand: "باز شدن",
+ expandAll: "باز شدن همه",
+ filterArrIncludes: "شامل",
+ filterArrIncludesAll: "شامل همه",
+ filterArrIncludesSome: "شامل",
+ filterBetween: "میان",
+ filterBetweenInclusive: "میان با احتساب هر دو",
+ filterByColumn: "فیلتر بر اساس {column}",
+ filterContains: "شامل",
+ filterEmpty: "خالی",
+ filterEndsWith: "به پایان میرسد با",
+ filterEquals: "برابر",
+ filterEqualsString: "برابر",
+ filterFuzzy: "نزدیک",
+ filterGreaterThan: "بزرگتر از",
+ filterGreaterThanOrEqualTo: "بزرگتر یا مساوی",
+ filterInNumberRange: "میان",
+ filterIncludesString: "شامل",
+ filterIncludesStringSensitive: "شامل",
+ filterLessThan: "کوچکتر از",
+ filterLessThanOrEqualTo: "کوچکتر یا مساوی",
+ filterMode: "حالت فیلتر: {filterType}",
+ filterNotEmpty: "غیر خالی",
+ filterNotEquals: "نا برابر",
+ filterStartsWith: "شروع میشود با",
+ filterWeakEquals: "برابر",
+ filteringByColumn: "فیلتر بر اساس {column} - {filterType} {filterValue}",
+ goToFirstPage: "رفتن به صفحه اول",
+ goToLastPage: "رفتن به صفحه آخر",
+ goToNextPage: "رفتن به صفحه بعدی",
+ goToPreviousPage: "رفتن به صفحه قبلی",
+ grab: "گرفتن",
+ groupByColumn: "گروه بندی بر اساس {column}",
+ groupedBy: "گروه بندی شده بر اساس",
+ hideAll: "پنهان کردن همه",
+ hideColumn: "پنهان کردن ستون {column}",
+ max: "حداکثر",
+ min: "حداقل",
+ move: "انتقال",
+ noRecordsToDisplay: "هیچ رکوردی برای نمایش وجود ندارد",
+ noResultsFound: "نتیجهای یافت نشد",
+ of: "از",
+ or: "یا",
+ pinToLeft: "چسباندن به سمت چپ",
+ pinToRight: "چسباندن به سمت راست",
+ resetColumnSize: "بازنشانی اندازه ستون",
+ resetOrder: "بازنشانی ترتیب",
+ rowActions: "عملیات ردیف",
rowNumber: "#",
- rowNumbers: "Row Numbers",
- rowsPerPage: "Rows per page",
- save: "Save",
- search: "Search",
+ rowNumbers: "شماره ردیف",
+ rowsPerPage: "ردیف در هر صفحه",
+ save: "ذخیره",
+ search: "جستجو",
selectedCountOfRowCountRowsSelected:
- "{selectedCount} of {rowCount} row(s) selected",
- select: "Select",
- showAll: "Show all",
- showAllColumns: "Show all columns",
- showHideColumns: "Show/Hide columns",
- showHideFilters: "Show/Hide filters",
- showHideSearch: "Show/Hide search",
- sortByColumnAsc: "Sort by {column} ascending",
- sortByColumnDesc: "Sort by {column} descending",
- sortedByColumnAsc: "Sorted by {column} ascending",
- sortedByColumnDesc: "Sorted by {column} descending",
- thenBy: ", then by ",
- toggleDensity: "Toggle density",
- toggleFullScreen: "Toggle full screen",
- toggleSelectAll: "Toggle select all",
- toggleSelectRow: "Toggle select row",
- toggleVisibility: "Toggle visibility",
- ungroupByColumn: "Ungroup by {column}",
- unpin: "Unpin",
- unpinAll: "Unpin all",
- unsorted: "Unsorted",
+ "{selectedCount} از {rowCount} ردیف انتخاب شده",
+ select: "انتخاب",
+ showAll: "نمایش همه",
+ showAllColumns: "نمایش همه ستونها",
+ showHideColumns: "نمایش/مخفی کردن ستونها",
+ showHideFilters: "نمایش/مخفی کردن فیلترها",
+ showHideSearch: "نمایش/مخفی کردن جستجو",
+ sortByColumnAsc: "مرتب سازی بر اساس {column} صعودی",
+ sortByColumnDesc: "مرتب سازی بر اساس {column} نزولی",
+ sortedByColumnAsc: "مرتب شده بر اساس {column} صعودی",
+ sortedByColumnDesc: "مرتب شده بر اساس {column} نزولی",
+ thenBy: "، سپس بر اساس ",
+ toggleDensity: "تغییر تراکم",
+ toggleFullScreen: "تغییر حالت تمام صفحه",
+ toggleSelectAll: "انتخاب/عدم انتخاب همه",
+ toggleSelectRow: "انتخاب/عدم انتخاب ردیف",
+ toggleVisibility: "تغییر پیدا/پنهان",
+ ungroupByColumn: "لغو گروه بندی بر اساس {column}",
+ unpin: "رها کردن",
+ unpinAll: "رها کردن همه",
+ unsorted: "بدون مرتب سازی",
};
diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx
new file mode 100644
index 0000000..754abce
--- /dev/null
+++ b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx
@@ -0,0 +1,94 @@
+import { CONFIRM_MACHINARY_OFFICE } from "@/core/data/apiRoutes";
+import {
+ Dialog,
+ DialogTitle,
+ DialogContent,
+ DialogContentText,
+ DialogActions,
+ Button,
+ TextField,
+} from "@mui/material";
+import { useTranslations } from "next-intl";
+import { useState } from "react";
+import { useFormik } from "formik";
+import * as Yup from "yup";
+
+const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => {
+ const t = useTranslations();
+ const [proposedAmount, setProposedAmount] = useState("");
+ const [description, setDescription] = useState("");
+
+ //formik
+ const validationSchema = Yup.object().shape({
+ proposed_amount: Yup.string().required(t("ConfirmDialog.amount_error")),
+ });
+ const formik = useFormik({
+ initialValues: {
+ proposed_amount: "",
+ description: "",
+ },
+ validationSchema,
+ onSubmit: () => {
+ const formData = new FormData();
+ formData.append("proposed_amount", proposedAmount);
+ if (description != "") formData.append("expert_description", description);
+ handleClose();
+ confirmData(CONFIRM_MACHINARY_OFFICE, rowId, formData);
+ },
+ });
+
+ const handleDescriptionChange = (event) => {
+ setDescription(event.target.value);
+ };
+ const handleAmountChange = (event) => {
+ setProposedAmount(event.target.value);
+ formik.handleChange(event);
+ };
+
+ return (
+
+ );
+};
+export default ConfirmForm;
diff --git a/src/components/dashboard/machinary-office/Form/RejectForm.jsx b/src/components/dashboard/machinary-office/Form/RejectForm.jsx
new file mode 100644
index 0000000..723f9a6
--- /dev/null
+++ b/src/components/dashboard/machinary-office/Form/RejectForm.jsx
@@ -0,0 +1,76 @@
+import { REJECT_MACHINARY_OFFICE } from "@/core/data/apiRoutes";
+import {
+ Dialog,
+ DialogTitle,
+ DialogContent,
+ DialogContentText,
+ DialogActions,
+ Button,
+ TextField,
+} from "@mui/material";
+import { useTranslations } from "next-intl";
+import { useFormik } from "formik";
+import * as Yup from "yup";
+import { useState } from "react";
+
+const RejectForm = ({ open, handleClose, rowId, rejectData }) => {
+ const t = useTranslations();
+ const [description, setDescription] = useState("");
+
+ const validationSchema = Yup.object().shape({
+ description: Yup.string().required(t("RejectDialog.description_error")),
+ });
+
+ const formik = useFormik({
+ initialValues: {
+ description: "",
+ },
+ validationSchema,
+ onSubmit: () => {
+ const formData = new FormData();
+ formData.append("expert_description", description);
+ handleClose();
+ rejectData(REJECT_MACHINARY_OFFICE, rowId, formData);
+ },
+ });
+
+ const handleDescriptionChange = (event) => {
+ setDescription(event.target.value);
+ formik.handleChange(event);
+ };
+
+ return (
+
+ );
+};
+
+export default RejectForm;
diff --git a/src/components/dashboard/machinary-office/TableRowActions.jsx b/src/components/dashboard/machinary-office/TableRowActions.jsx
new file mode 100644
index 0000000..e9e815e
--- /dev/null
+++ b/src/components/dashboard/machinary-office/TableRowActions.jsx
@@ -0,0 +1,54 @@
+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,
+ rowId,
+ confirmData,
+ rejectData,
+ } = useContext(DataTableContext);
+ return (
+
+ {
+ handleOpenConfirmDialog(row);
+ }}
+ >
+
+
+ {openConfirmDialog && (
+
+ )}
+ handleOpenRejectDialog(row)}>
+
+
+ {openRejectDialog && (
+
+ )}
+
+ );
+};
+
+export default TableRowActions;
diff --git a/src/components/dashboard/machinary-office/TableTolbar.jsx b/src/components/dashboard/machinary-office/TableTolbar.jsx
new file mode 100644
index 0000000..3f06d3b
--- /dev/null
+++ b/src/components/dashboard/machinary-office/TableTolbar.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/machinary-office/index.jsx b/src/components/dashboard/machinary-office/index.jsx
new file mode 100644
index 0000000..bcd3eb4
--- /dev/null
+++ b/src/components/dashboard/machinary-office/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_MACHINARY_OFFICE } from "@/core/data/apiRoutes";
+import { useTranslations } from "next-intl";
+import TableRowActions from "./TableRowActions";
+
+function DashboardMachinaryOfficeComponent() {
+ const t = useTranslations();
+ const columns = useMemo(
+ () => [
+ {
+ accessorFn: (row) => row.name,
+ id: "name",
+ header: t("MachinaryOffice.name"),
+ enableColumnFilter: true,
+ datatype: "text",
+ filterFn: "contains",
+ columnFilterModeOptions: ["contains", "equals", "notEquals"],
+ Cell: ({ renderedCellValue }) => (
+ {renderedCellValue}
+ ),
+ },
+ {
+ accessorFn: (row) => row.national_id,
+ id: "national_id",
+ header: t("MachinaryOffice.national_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("MachinaryOffice.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("MachinaryOffice.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("MachinaryOffice.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("MachinaryOffice.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("MachinaryOffice.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("MachinaryOffice.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 DashboardMachinaryOfficeComponent;
diff --git a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx
new file mode 100644
index 0000000..43c6bb3
--- /dev/null
+++ b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx
@@ -0,0 +1,35 @@
+import { CONFIRM_PASSENGER_OFFICE } from "@/core/data/apiRoutes";
+import {
+ Dialog,
+ DialogTitle,
+ DialogContent,
+ DialogContentText,
+ DialogActions,
+ Button,
+} from "@mui/material";
+import { useTranslations } from "next-intl";
+
+const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => {
+ const t = useTranslations();
+ const handleConfirm = () => {
+ handleClose();
+ confirmData(CONFIRM_PASSENGER_OFFICE, rowId);
+ };
+ return (
+
+ );
+};
+export default ConfirmForm;
diff --git a/src/components/dashboard/passenger-office/Form/RejectForm.jsx b/src/components/dashboard/passenger-office/Form/RejectForm.jsx
new file mode 100644
index 0000000..149c480
--- /dev/null
+++ b/src/components/dashboard/passenger-office/Form/RejectForm.jsx
@@ -0,0 +1,76 @@
+import { REJECT_PASSENGER_OFFICE } from "@/core/data/apiRoutes";
+import {
+ Dialog,
+ DialogTitle,
+ DialogContent,
+ DialogContentText,
+ DialogActions,
+ Button,
+ TextField,
+} from "@mui/material";
+import { useTranslations } from "next-intl";
+import { useFormik } from "formik";
+import * as Yup from "yup";
+import { useState } from "react";
+
+const RejectForm = ({ open, handleClose, rowId, rejectData }) => {
+ const t = useTranslations();
+ const [description, setDescription] = useState("");
+
+ const validationSchema = Yup.object().shape({
+ description: Yup.string().required(t("RejectDialog.description_error")),
+ });
+
+ const formik = useFormik({
+ initialValues: {
+ description: "",
+ },
+ validationSchema,
+ onSubmit: () => {
+ const formData = new FormData();
+ formData.append("expert_description", description);
+ handleClose();
+ rejectData(REJECT_PASSENGER_OFFICE, rowId, formData);
+ },
+ });
+
+ const handleDescriptionChange = (event) => {
+ setDescription(event.target.value);
+ formik.handleChange(event);
+ };
+
+ return (
+
+ );
+};
+
+export default RejectForm;
diff --git a/src/components/dashboard/passenger-office/TableRowActions.jsx b/src/components/dashboard/passenger-office/TableRowActions.jsx
new file mode 100644
index 0000000..e9e815e
--- /dev/null
+++ b/src/components/dashboard/passenger-office/TableRowActions.jsx
@@ -0,0 +1,54 @@
+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,
+ rowId,
+ confirmData,
+ rejectData,
+ } = useContext(DataTableContext);
+ return (
+
+ {
+ handleOpenConfirmDialog(row);
+ }}
+ >
+
+
+ {openConfirmDialog && (
+
+ )}
+ handleOpenRejectDialog(row)}>
+
+
+ {openRejectDialog && (
+
+ )}
+
+ );
+};
+
+export default TableRowActions;
diff --git a/src/components/dashboard/passenger-office/TableTollbar.jsx b/src/components/dashboard/passenger-office/TableTollbar.jsx
new file mode 100644
index 0000000..3f06d3b
--- /dev/null
+++ b/src/components/dashboard/passenger-office/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/passenger-office/index.jsx b/src/components/dashboard/passenger-office/index.jsx
new file mode 100644
index 0000000..9313a5b
--- /dev/null
+++ b/src/components/dashboard/passenger-office/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_PASSENGER_OFFICE } from "@/core/data/apiRoutes";
+import { useTranslations } from "next-intl";
+import TableRowActions from "./TableRowActions";
+
+function DashboardPassengerOfficeComponent() {
+ const t = useTranslations();
+ const columns = useMemo(
+ () => [
+ {
+ accessorFn: (row) => row.name,
+ id: "name",
+ header: t("PassengerOffice.name"),
+ enableColumnFilter: true,
+ datatype: "text",
+ filterFn: "contains",
+ columnFilterModeOptions: ["contains", "equals", "notEquals"],
+ Cell: ({ renderedCellValue }) => (
+ {renderedCellValue}
+ ),
+ },
+ {
+ accessorFn: (row) => row.national_id,
+ id: "national_id",
+ header: t("PassengerOffice.national_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("PassengerOffice.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("PassengerOffice.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("PassengerOffice.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("PassengerOffice.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("PassengerOffice.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("PassengerOffice.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 DashboardPassengerOfficeComponent;
diff --git a/src/components/login-expert/index.jsx b/src/components/login-expert/index.jsx
index bcc3b1a..4d6af4a 100644
--- a/src/components/login-expert/index.jsx
+++ b/src/components/login-expert/index.jsx
@@ -41,12 +41,10 @@ const LoginComponent = () => {
password: values.password,
})
.then(function (response) {
- console.log(response);
setToken(response.data.token);
})
.catch(function (error) {
// Notifications(directionApp, error.response, t);
- console.log(error);
props.setSubmitting(false);
});
};
diff --git a/src/core/components/DatatableStructure.jsx b/src/core/components/DatatableStructure.jsx
index e13ed16..e033a09 100644
--- a/src/core/components/DatatableStructure.jsx
+++ b/src/core/components/DatatableStructure.jsx
@@ -1,4 +1,4 @@
-import { DataTableProvider } from "@/lib/app/contexts/DatatableContext";
+import { DataTableProvider } from "@/lib/app/contexts/DataTableContext";
import DataTable from "./Datatable";
import { ReloadDataTableProvider } from "@/lib/app/contexts/ReloadDatatableContext";
diff --git a/src/core/components/ImageConvertor.jsx b/src/core/components/ImageConvertor.jsx
index e69de29..667182e 100644
--- a/src/core/components/ImageConvertor.jsx
+++ b/src/core/components/ImageConvertor.jsx
@@ -0,0 +1,22 @@
+import ImageResize from "image-resize";
+
+const ImageResizer = async (image) => {
+ const imageResize = new ImageResize({
+ quality: 1,
+ format: "jpg",
+ outputType: "base64",
+ width: 400,
+ });
+
+ const get = await imageResize.get(image);
+ const resize = await imageResize.resize(get).then();
+ const output = await imageResize.output(resize).then();
+
+ const avatar = await (await import("image-to-file-converter"))
+ .base64ToFile(output)
+ .then();
+
+ return avatar;
+};
+
+export default ImageResizer;
diff --git a/src/core/components/LoadingHardPage.jsx b/src/core/components/LoadingHardPage.jsx
index 5da632d..5a86af8 100644
--- a/src/core/components/LoadingHardPage.jsx
+++ b/src/core/components/LoadingHardPage.jsx
@@ -28,7 +28,7 @@ const LoadingHardPage = ({ children, loading }) => {
>
{
{
switch (action.type) {
- case "ADD_DATA":
+ case "CONFIRM_DATA":
return {
...state,
url: action.url,
- values: action.values,
- image: action.image,
- rowID: "",
- };
- case "EDIT_DATA":
- return {
- ...state,
- url: action.url,
- values: action.values,
rowID: action.rowID,
- image: action.image,
};
- case "DELETE_DATA":
+ case "REJECT_DATA":
return {
...state,
url: action.url,
rowID: action.rowID,
values: {},
- image: {},
};
default:
return state;
@@ -50,118 +35,77 @@ const reducer = (state, action) => {
const useDataTable = () => {
const { setReloadDataTable } = useContext(ReloadDataTableContext);
const [state, dispatch] = useReducer(reducer, initialValues);
- const [drawerContent, setDrawerContent] = useState(null);
- const [openDeleteDialog, setOpenDeleteDialog] = useState(false);
+ const [openConfirmDialog, setOpenConfirmDialog] = useState(false);
+ const [openRejectDialog, setOpenRejectDialog] = useState(false);
const [rowId, setRowId] = useState(null);
- const theme = useTheme();
+ const { directionApp } = useDirection();
+ const t = useTranslations();
+
const { token } = useUser();
- const drawerDirection = useMediaQuery(theme.breakpoints.up("sm"))
- ? "right"
- : "bottom";
- const [sweepableDrawer, setSweepableDrawer] = useState({
- bottom: false,
- right: false,
- });
-
- const addData = useCallback(async (url, values, image) => {
- dispatch({ type: "ADD_DATA", url: url, values: values, image: image });
- if (image != null) {
- var resizedAvatar = await ImageResizer(image.value);
- formData.append(image.key, resizedAvatar);
- axios.post(url, formData, {
- headers: {
- authorization: `Bearer ${token}`,
- "Content-Type": "multipart/form-data",
- },
- });
- }
- axios
- .post(url, values, {
- headers: {
- authorization: `Bearer ${token}`,
- },
- })
- .then(() => {})
- .catch(() => {});
- }, []);
-
- const deleteData = useCallback(async (url, rowID) => {
- dispatch({ type: "DELETE_DATA", url: url, rowID: rowID });
- axios
- .delete(`${url}/${rowID}`, {
- headers: {
- authorization: `Bearer ${token}`,
- },
- })
- .then(() => {
- setReloadDataTable(true);
- })
- .catch(() => {});
- }, []);
-
- const editData = useCallback(async (url, values, rowID, image) => {
- dispatch({
- type: "EDIT_DATA",
- url: url,
- values: values,
- rowID: rowID,
- image: image,
- });
- if (image != null) {
- var resizedAvatar = await ImageResizer(image.value);
- formData.append(image.key, resizedAvatar);
- axios.post(`${url}/${rowID}`, formData, {
- headers: {
- authorization: `Bearer ${token}`,
- "Content-Type": "multipart/form-data",
- },
- });
- }
+ const confirmData = useCallback(async (url, rowID, values) => {
+ dispatch({ type: "CONFIRM_DATA", url: url, rowID: rowID, values: values });
axios
.post(`${url}/${rowID}`, values, {
- headers: {
- authorization: `Bearer ${token}`,
- },
+ headers: { authorization: `Bearer ${token}` },
})
- .then(() => {})
- .catch(() => {});
+ .then((response) => {
+ setReloadDataTable(true);
+ Notifications(directionApp, response, t);
+ })
+ .catch((error) => {
+ Notifications(directionApp, error.response, t);
+ });
}, []);
- const toggleDrawer = (open) => {
- open == false &&
- setTimeout(() => {
- setDrawerContent(null);
- }, theme.transitions.duration.leavingScreen);
- setSweepableDrawer({ ...sweepableDrawer, [drawerDirection]: open });
- };
- const handleOpenDeleteDialog = (row) => {
+ const rejectData = useCallback(async (url, rowID, values) => {
+ dispatch({ type: "REJECT_DATA", url: url, rowID: rowID, values: values });
+ axios
+ .post(`${url}/${rowID}`, values, {
+ headers: { authorization: `Bearer ${token}` },
+ })
+ .then((response) => {
+ setReloadDataTable(true);
+ Notifications(directionApp, response, t);
+ })
+ .catch((error) => {
+ console.log(error);
+ Notifications(directionApp, error.response, t);
+ });
+ }, []);
+
+ //Confirm Data
+ const handleOpenConfirmDialog = (row) => {
setRowId(row.getValue("id"));
- setOpenDeleteDialog(true);
+ setOpenConfirmDialog(true);
};
- const handleCloseDeleteDialog = () => {
- setOpenDeleteDialog(false);
+ const handleCloseConfirmDialog = () => {
+ setOpenConfirmDialog(false);
+ };
+ //End Confirm Data
+
+ // Reject Data
+ const handleOpenRejectDialog = (row) => {
+ setRowId(row.getValue("id"));
+ setOpenRejectDialog(true);
};
- const handleDeleteDialog = () => {
- setOpenDeleteDialog(false);
+ const handleCloseRejectDialog = () => {
+ setOpenRejectDialog(false);
};
+ // End Reject Data
const contextValue = {
- toggleDrawer,
- drawerDirection,
- sweepableDrawer,
- setSweepableDrawer,
- setDrawerContent,
- drawerContent,
- openDeleteDialog,
- handleOpenDeleteDialog,
- handleCloseDeleteDialog,
- handleDeleteDialog,
+ handleOpenConfirmDialog,
+ handleCloseConfirmDialog,
+ handleOpenRejectDialog,
+ handleCloseRejectDialog,
rowId,
- deleteData,
- addData,
+ openConfirmDialog,
+ openRejectDialog,
+ rejectData,
+ confirmData,
};
return contextValue;
};
diff --git a/src/pages/dashboard/machinary-office/index.jsx b/src/pages/dashboard/machinary-office/index.jsx
new file mode 100644
index 0000000..0bb3553
--- /dev/null
+++ b/src/pages/dashboard/machinary-office/index.jsx
@@ -0,0 +1,23 @@
+import DashboardMachinaryOfficeComponent from "@/components/dashboard/machinary-office";
+import TitlePage from "@/core/components/TitlePage";
+import WithAuthMiddleware from "@/middlewares/WithAuth";
+import { parse } from "next-useragent";
+
+export default function PassengerOffice() {
+ 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,
+ },
+ };
+}
diff --git a/src/pages/dashboard/passenger-office/index.jsx b/src/pages/dashboard/passenger-office/index.jsx
new file mode 100644
index 0000000..36e2a95
--- /dev/null
+++ b/src/pages/dashboard/passenger-office/index.jsx
@@ -0,0 +1,23 @@
+import DashboardPassengerOfficeComponent from "@/components/dashboard/passenger-office";
+import TitlePage from "@/core/components/TitlePage";
+import WithAuthMiddleware from "@/middlewares/WithAuth";
+import { parse } from "next-useragent";
+
+export default function PassengerOffice() {
+ 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,
+ },
+ };
+}