merge conflict
This commit is contained in:
@@ -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 (
|
||||
<Dialog open={open} onClose={handleClose}>
|
||||
<DialogTitle>{t("ConfirmDialog.confirm")}</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContentText>{t("ConfirmDialog.context")}</DialogContentText>
|
||||
<TextField
|
||||
name="description"
|
||||
multiline
|
||||
rows={8}
|
||||
placeholder={t("RejectDialog.description")}
|
||||
value={description}
|
||||
onChange={handleDescriptionChange}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
sx={{ mt: 1 }}
|
||||
/>
|
||||
<TextField
|
||||
name="proposed_amount"
|
||||
label={t("MachinaryOffice.proposed_amount")}
|
||||
type="number"
|
||||
variant="outlined"
|
||||
value={proposedAmount}
|
||||
onChange={handleAmountChange}
|
||||
onBlur={formik.handleBlur("proposed_amount")}
|
||||
error={
|
||||
formik.touched.proposed_amount &&
|
||||
Boolean(formik.errors.proposed_amount)
|
||||
}
|
||||
helperText={
|
||||
formik.touched.proposed_amount && formik.errors.proposed_amount
|
||||
}
|
||||
sx={{ mt: 1 }}
|
||||
fullWidth
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={formik.handleSubmit} color="primary">
|
||||
{t("ConfirmDialog.button-confirm")}
|
||||
</Button>
|
||||
<Button onClick={handleClose} color="secondary" autoFocus>
|
||||
{t("ConfirmDialog.button-cancel")}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
export default ConfirmForm;
|
||||
@@ -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 (
|
||||
<Dialog open={open} onClose={handleClose}>
|
||||
<DialogTitle>{t("RejectDialog.reject")}</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContentText>{t("RejectDialog.context")}</DialogContentText>
|
||||
<TextField
|
||||
name="description"
|
||||
multiline
|
||||
rows={8}
|
||||
placeholder={t("RejectDialog.description")}
|
||||
value={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 }}
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={formik.handleSubmit} color="primary">
|
||||
{t("RejectDialog.button-reject")}
|
||||
</Button>
|
||||
<Button onClick={handleClose} color="secondary" autoFocus>
|
||||
{t("RejectDialog.button-cancel")}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
export default RejectForm;
|
||||
@@ -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 (
|
||||
<Box sx={{ display: "flex", flexWrap: "nowrap", gap: "8px" }}>
|
||||
<IconButton
|
||||
color="primary"
|
||||
onClick={() => {
|
||||
handleOpenConfirmDialog(row);
|
||||
}}
|
||||
>
|
||||
<ThumbUpAltIcon />
|
||||
</IconButton>
|
||||
{openConfirmDialog && (
|
||||
<ConfirmForm
|
||||
rowId={rowId}
|
||||
open={openConfirmDialog}
|
||||
handleClose={handleCloseConfirmDialog}
|
||||
confirmData={confirmData}
|
||||
/>
|
||||
)}
|
||||
<IconButton color="primary" onClick={() => handleOpenRejectDialog(row)}>
|
||||
<ThumbDownIcon />
|
||||
</IconButton>
|
||||
{openRejectDialog && (
|
||||
<RejectForm
|
||||
rowId={rowId}
|
||||
open={openRejectDialog}
|
||||
handleClose={handleCloseRejectDialog}
|
||||
rejectData={rejectData}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableRowActions;
|
||||
13
src/components/dashboard/machinary-office/TableTolbar.jsx
Normal file
13
src/components/dashboard/machinary-office/TableTolbar.jsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import { Stack, Tooltip } from "@mui/material";
|
||||
import { useTranslations } from "next-intl";
|
||||
|
||||
function TableToolbar() {
|
||||
const t = useTranslations();
|
||||
return (
|
||||
<Stack direction={"row"} spacing={2}>
|
||||
<Tooltip title={t("add")} arrow placement="right"></Tooltip>
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
|
||||
export default TableToolbar;
|
||||
177
src/components/dashboard/machinary-office/index.jsx
Normal file
177
src/components/dashboard/machinary-office/index.jsx
Normal file
@@ -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 }) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
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 }) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
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 }) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
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 }) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
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 }) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
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 }) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
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 }) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
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 }) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
},
|
||||
],
|
||||
[]
|
||||
);
|
||||
return (
|
||||
<DashboardLayouts>
|
||||
<Box sx={{ px: 3 }}>
|
||||
<DataTableStructure
|
||||
tableUrl={GET_MACHINARY_OFFICE}
|
||||
columns={columns}
|
||||
selectableRow={false}
|
||||
enableCustomToolbar={true}
|
||||
// CustomToolbar={<TableToolbar />}
|
||||
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 }) => <TableRowActions row={row} />}
|
||||
/>
|
||||
</Box>
|
||||
</DashboardLayouts>
|
||||
);
|
||||
}
|
||||
|
||||
export default DashboardMachinaryOfficeComponent;
|
||||
@@ -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 (
|
||||
<Dialog open={open} onClose={handleClose}>
|
||||
<DialogTitle>{t("ConfirmDialog.confirm")}</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContentText>{t("ConfirmDialog.context")}</DialogContentText>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={handleConfirm} color="primary">
|
||||
{t("ConfirmDialog.button-confirm")}
|
||||
</Button>
|
||||
<Button onClick={handleClose} color="secondary" autoFocus>
|
||||
{t("ConfirmDialog.button-cancel")}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
export default ConfirmForm;
|
||||
@@ -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 (
|
||||
<Dialog open={open} onClose={handleClose}>
|
||||
<DialogTitle>{t("RejectDialog.reject")}</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContentText>{t("RejectDialog.context")}</DialogContentText>
|
||||
<TextField
|
||||
name="description"
|
||||
multiline
|
||||
rows={8}
|
||||
placeholder={t("RejectDialog.description")}
|
||||
value={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 }}
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={formik.handleSubmit} color="primary">
|
||||
{t("RejectDialog.button-reject")}
|
||||
</Button>
|
||||
<Button onClick={handleClose} color="secondary" autoFocus>
|
||||
{t("RejectDialog.button-cancel")}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
export default RejectForm;
|
||||
@@ -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 (
|
||||
<Box sx={{ display: "flex", flexWrap: "nowrap", gap: "8px" }}>
|
||||
<IconButton
|
||||
color="primary"
|
||||
onClick={() => {
|
||||
handleOpenConfirmDialog(row);
|
||||
}}
|
||||
>
|
||||
<ThumbUpAltIcon />
|
||||
</IconButton>
|
||||
{openConfirmDialog && (
|
||||
<ConfirmForm
|
||||
rowId={rowId}
|
||||
open={openConfirmDialog}
|
||||
handleClose={handleCloseConfirmDialog}
|
||||
confirmData={confirmData}
|
||||
/>
|
||||
)}
|
||||
<IconButton color="primary" onClick={() => handleOpenRejectDialog(row)}>
|
||||
<ThumbDownIcon />
|
||||
</IconButton>
|
||||
{openRejectDialog && (
|
||||
<RejectForm
|
||||
rowId={rowId}
|
||||
open={openRejectDialog}
|
||||
handleClose={handleCloseRejectDialog}
|
||||
rejectData={rejectData}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableRowActions;
|
||||
13
src/components/dashboard/passenger-office/TableTollbar.jsx
Normal file
13
src/components/dashboard/passenger-office/TableTollbar.jsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import { Stack, Tooltip } from "@mui/material";
|
||||
import { useTranslations } from "next-intl";
|
||||
|
||||
function TableToolbar() {
|
||||
const t = useTranslations();
|
||||
return (
|
||||
<Stack direction={"row"} spacing={2}>
|
||||
<Tooltip title={t("add")} arrow placement="right"></Tooltip>
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
|
||||
export default TableToolbar;
|
||||
177
src/components/dashboard/passenger-office/index.jsx
Normal file
177
src/components/dashboard/passenger-office/index.jsx
Normal file
@@ -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 }) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
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 }) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
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 }) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
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 }) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
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 }) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
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 }) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
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 }) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
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 }) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
},
|
||||
],
|
||||
[]
|
||||
);
|
||||
return (
|
||||
<DashboardLayouts>
|
||||
<Box sx={{ px: 3 }}>
|
||||
<DataTableStructure
|
||||
tableUrl={GET_PASSENGER_OFFICE}
|
||||
columns={columns}
|
||||
selectableRow={false}
|
||||
enableCustomToolbar={true}
|
||||
// CustomToolbar={<TableToolbar />}
|
||||
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 }) => <TableRowActions row={row} />}
|
||||
/>
|
||||
</Box>
|
||||
</DashboardLayouts>
|
||||
);
|
||||
}
|
||||
|
||||
export default DashboardPassengerOfficeComponent;
|
||||
@@ -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);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -28,7 +28,7 @@ const LoadingHardPage = ({ children, loading }) => {
|
||||
>
|
||||
<Fade in={true}>
|
||||
<LoadingImage
|
||||
src={"/images/logo.svg"}
|
||||
src={"/images/loading_logo.svg"}
|
||||
alt="loading marhaba"
|
||||
priority
|
||||
width={100}
|
||||
|
||||
@@ -7,7 +7,7 @@ const Message = ({ text, actions }) => {
|
||||
<FullPageLayout sx={{ p: 1 }}>
|
||||
<CenterLayout spacing={3}>
|
||||
<StyledImage
|
||||
src={"/images/logo.svg"}
|
||||
src={"/images/loading_logo.svg"}
|
||||
alt="loading loan facilities"
|
||||
width={100}
|
||||
height={100}
|
||||
|
||||
@@ -8,6 +8,28 @@ export const GET_USER_TOKEN = BASE_URL + "/dashboard/login";
|
||||
export const CHANGE_PASSWORD = BASE_URL + "/dashboard/profile/change_password";
|
||||
//end change password
|
||||
|
||||
//user data
|
||||
//user data
|
||||
export const GET_USER_ROUTE = BASE_URL + "/dashboard/profile/info";
|
||||
//user data
|
||||
//user data
|
||||
|
||||
//passenger office
|
||||
export const GET_PASSENGER_OFFICE =
|
||||
BASE_URL + "/dashboard/passenger_office_chief/show";
|
||||
|
||||
export const CONFIRM_PASSENGER_OFFICE =
|
||||
BASE_URL + "/dashboard/passenger_office_chief/confirm";
|
||||
|
||||
export const REJECT_PASSENGER_OFFICE =
|
||||
BASE_URL + "/dashboard/passenger_office_chief/reject";
|
||||
//passenger office
|
||||
|
||||
//machinary office
|
||||
export const GET_MACHINARY_OFFICE =
|
||||
BASE_URL + "/dashboard/machinery_expert/show";
|
||||
|
||||
export const CONFIRM_MACHINARY_OFFICE =
|
||||
BASE_URL + "/dashboard/machinery_expert/confirm";
|
||||
|
||||
export const REJECT_MACHINARY_OFFICE =
|
||||
BASE_URL + "/dashboard/machinery_expert/reject";
|
||||
//passenger office
|
||||
|
||||
@@ -1,46 +1,31 @@
|
||||
import { useMediaQuery } from "@mui/material";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
import { useState, useReducer, useCallback, useContext } from "react";
|
||||
import axios from "axios";
|
||||
import ImageResizer from "@/core/components/ImageConvertor";
|
||||
import useUser from "./useUser";
|
||||
import { useCallback, useContext, useReducer, useState } from "react";
|
||||
import { ReloadDataTableContext } from "../contexts/ReloadDatatableContext";
|
||||
import useUser from "./useUser";
|
||||
import Notifications from "@/core/components/notifications";
|
||||
import useDirection from "./useDirection";
|
||||
import { useTranslations } from "next-intl";
|
||||
|
||||
const initialValues = {
|
||||
url: "",
|
||||
rowID: "",
|
||||
values: {},
|
||||
image: {
|
||||
key: "",
|
||||
value: {},
|
||||
},
|
||||
};
|
||||
|
||||
const reducer = (state, action) => {
|
||||
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;
|
||||
};
|
||||
|
||||
23
src/pages/dashboard/machinary-office/index.jsx
Normal file
23
src/pages/dashboard/machinary-office/index.jsx
Normal file
@@ -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 (
|
||||
<WithAuthMiddleware>
|
||||
<TitlePage text="Dashboard.machinary_office_page" />
|
||||
<DashboardMachinaryOfficeComponent />
|
||||
</WithAuthMiddleware>
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServerSideProps({ req, locale }) {
|
||||
const { isBot } = parse(req.headers["user-agent"]);
|
||||
return {
|
||||
props: {
|
||||
messages: (await import(`&/locales/${locale}/app.json`)).default,
|
||||
isBot,
|
||||
},
|
||||
};
|
||||
}
|
||||
23
src/pages/dashboard/passenger-office/index.jsx
Normal file
23
src/pages/dashboard/passenger-office/index.jsx
Normal file
@@ -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 (
|
||||
<WithAuthMiddleware>
|
||||
<TitlePage text="Dashboard.passenger_office_page" />
|
||||
<DashboardPassengerOfficeComponent />
|
||||
</WithAuthMiddleware>
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServerSideProps({ req, locale }) {
|
||||
const { isBot } = parse(req.headers["user-agent"]);
|
||||
return {
|
||||
props: {
|
||||
messages: (await import(`&/locales/${locale}/app.json`)).default,
|
||||
isBot,
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user