Merge branch 'develop' of https://gitlab.com/witel3/loan-facilities-expert into feature/debug_formdata
This commit is contained in:
@@ -7,7 +7,12 @@ import { GET_MACHINARY_OFFICE } from "@/core/data/apiRoutes";
|
||||
import { useTranslations } from "next-intl";
|
||||
import TableRowActions from "./TableRowActions";
|
||||
import { format } from "date-fns-jalali";
|
||||
|
||||
import {
|
||||
LocalizationProvider,
|
||||
MobileDateTimePicker,
|
||||
} from "@mui/x-date-pickers";
|
||||
import { AdapterDateFnsJalali } from "@mui/x-date-pickers/AdapterDateFnsJalali";
|
||||
import moment from "moment";
|
||||
function DashboardMachinaryOfficeComponent() {
|
||||
const t = useTranslations();
|
||||
const columns = useMemo(
|
||||
@@ -82,39 +87,55 @@ function DashboardMachinaryOfficeComponent() {
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => format(new Date(row.created_at), "yyyy/mm/dd"),
|
||||
accessorFn: (row) =>
|
||||
format(new Date(row.created_at), "HH:mm | yyyy/mm/dd"),
|
||||
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>
|
||||
),
|
||||
datatype: "date",
|
||||
filterFn: "lessThan",
|
||||
columnFilterModeOptions: ["lessThan", "greaterThan"],
|
||||
Cell: ({ renderedCellValue }) => {
|
||||
return (
|
||||
<Typography variant="body2" style={{ minWidth: "200px" }}>
|
||||
{renderedCellValue}
|
||||
</Typography>
|
||||
);
|
||||
},
|
||||
Header: ({ column }) => <em>{column.columnDef.header}</em>,
|
||||
Filter: ({ column }) => {
|
||||
return (
|
||||
<LocalizationProvider dateAdapter={AdapterDateFnsJalali}>
|
||||
<MobileDateTimePicker
|
||||
onChange={(newValue) => {
|
||||
const date = new Date(newValue);
|
||||
const formattedDate = moment(date)
|
||||
.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={moment(column.getFilterValue())
|
||||
.locale("fa")
|
||||
.format("yyyy/mm/dd HH:mm")}
|
||||
/>
|
||||
</LocalizationProvider>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => format(new Date(row.updated_at), "yyyy/mm/dd"),
|
||||
accessorFn: (row) =>
|
||||
format(new Date(row.updated_at), "HH:mm | yyyy/mm/dd"),
|
||||
id: "updated_at",
|
||||
header: t("MachinaryOffice.updated_at"),
|
||||
enableColumnFilter: true,
|
||||
enableColumnFilter: false,
|
||||
datatype: "numeric",
|
||||
filterFn: "equals",
|
||||
columnFilterModeOptions: [
|
||||
"equals",
|
||||
"notEquals",
|
||||
"contains",
|
||||
"lessThan",
|
||||
"greaterThan",
|
||||
"between",
|
||||
],
|
||||
Cell: ({ renderedCellValue }) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
@@ -154,9 +175,9 @@ function DashboardMachinaryOfficeComponent() {
|
||||
accessorFn: (row) => row.state_name,
|
||||
id: "state_id",
|
||||
header: t("MachinaryOffice.state_name"),
|
||||
enableColumnFilter: true,
|
||||
enableColumnFilter: false,
|
||||
datatype: "numeric",
|
||||
filterFn: "equals",
|
||||
// filterFn: "equals",
|
||||
// filterSelectOptions: [
|
||||
// ],
|
||||
// filterVariant: "select",
|
||||
|
||||
@@ -7,12 +7,16 @@ 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 {
|
||||
LocalizationProvider,
|
||||
MobileDateTimePicker,
|
||||
} 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(
|
||||
() => [
|
||||
{
|
||||
@@ -86,7 +90,7 @@ function DashboardPassengerOfficeComponent() {
|
||||
},
|
||||
{
|
||||
accessorFn: (row) =>
|
||||
format(new Date(row.created_at), "yyyy/mm/dd HH:mm"),
|
||||
format(new Date(row.created_at), "HH:mm | yyyy/mm/dd"),
|
||||
id: "created_at",
|
||||
header: t("PassengerOffice.created_at"),
|
||||
enableColumnFilter: true,
|
||||
@@ -94,28 +98,22 @@ function DashboardPassengerOfficeComponent() {
|
||||
filterFn: "lessThan",
|
||||
columnFilterModeOptions: ["lessThan", "greaterThan"],
|
||||
Cell: ({ renderedCellValue }) => {
|
||||
return <Typography variant="body2">{renderedCellValue}</Typography>;
|
||||
return (
|
||||
<Typography variant="body2" style={{ minWidth: "200px" }}>
|
||||
{renderedCellValue}
|
||||
</Typography>
|
||||
);
|
||||
},
|
||||
Header: ({ column }) => <em>{column.columnDef.header}</em>,
|
||||
Filter: ({ column }) => {
|
||||
return (
|
||||
<LocalizationProvider dateAdapter={AdapterDateFnsJalali}>
|
||||
<DateTimePicker
|
||||
<MobileDateTimePicker
|
||||
onChange={(newValue) => {
|
||||
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={{
|
||||
@@ -125,27 +123,21 @@ function DashboardPassengerOfficeComponent() {
|
||||
variant: "standard",
|
||||
},
|
||||
}}
|
||||
value={column.getFilterValue()}
|
||||
value={moment(column.getFilterValue())
|
||||
.locale("fa")
|
||||
.format("yyyy/mm/dd HH:mm")}
|
||||
/>
|
||||
</LocalizationProvider>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => format(new Date(row.updated_at), "yyyy/mm/dd"),
|
||||
accessorFn: (row) =>
|
||||
format(new Date(row.updated_at), "HH:mm | yyyy/mm/dd"),
|
||||
id: "updated_at",
|
||||
header: t("PassengerOffice.updated_at"),
|
||||
enableColumnFilter: true,
|
||||
enableColumnFilter: false,
|
||||
datatype: "numeric",
|
||||
filterFn: "equals",
|
||||
columnFilterModeOptions: [
|
||||
"equals",
|
||||
"notEquals",
|
||||
"contains",
|
||||
"lessThan",
|
||||
"greaterThan",
|
||||
"between",
|
||||
],
|
||||
Cell: ({ renderedCellValue }) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
@@ -185,9 +177,9 @@ function DashboardPassengerOfficeComponent() {
|
||||
accessorFn: (row) => row.state_name,
|
||||
id: "state_id",
|
||||
header: t("PassengerOffice.state_name"),
|
||||
enableColumnFilter: true,
|
||||
enableColumnFilter: false,
|
||||
datatype: "numeric",
|
||||
filterFn: "equals",
|
||||
// filterFn: "equals",
|
||||
// filterSelectOptions: [
|
||||
// ],
|
||||
// filterVariant: "select",
|
||||
|
||||
@@ -9,16 +9,10 @@ import {
|
||||
} from "@mui/material";
|
||||
import { useTranslations } from "next-intl";
|
||||
|
||||
const ConfirmForm = ({
|
||||
open,
|
||||
handleClose,
|
||||
handleDelete,
|
||||
rowId,
|
||||
confirmData,
|
||||
}) => {
|
||||
const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => {
|
||||
const t = useTranslations();
|
||||
const handleConfirm = () => {
|
||||
handleDelete();
|
||||
handleClose();
|
||||
confirmData(CONFIRM_TRANSPORTATION_ASSISTANCE, rowId);
|
||||
};
|
||||
return (
|
||||
|
||||
@@ -6,23 +6,63 @@ import {
|
||||
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, handleDelete, rowId, rejectData }) => {
|
||||
const RejectForm = ({ open, handleClose, rowId, rejectData }) => {
|
||||
const [description, setDescription] = useState("");
|
||||
const t = useTranslations();
|
||||
const handleRejectRequest = () => {
|
||||
handleDelete();
|
||||
rejectData(REJECT_TRANSPORTATION_ASSISTANCE, rowId);
|
||||
|
||||
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_TRANSPORTATION_ASSISTANCE, 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={handleRejectRequest} color="primary">
|
||||
<Button onClick={formik.handleSubmit} color="primary">
|
||||
{t("RejectDialog.button-reject")}
|
||||
</Button>
|
||||
<Button onClick={handleClose} color="secondary" autoFocus>
|
||||
|
||||
@@ -14,34 +14,39 @@ const TableRowActions = ({ row }) => {
|
||||
handleOpenRejectDialog,
|
||||
handleCloseConfirmDialog,
|
||||
handleCloseRejectDialog,
|
||||
handleConfirmDialog,
|
||||
handleRejectDialog,
|
||||
rowId,
|
||||
confirmData,
|
||||
rejectData,
|
||||
} = useContext(DataTableContext);
|
||||
return (
|
||||
<Box sx={{ display: "flex", flexWrap: "nowrap", gap: "8px" }}>
|
||||
<IconButton color="primary" onClick={() => handleOpenConfirmDialog(row)}>
|
||||
<IconButton
|
||||
color="primary"
|
||||
onClick={() => {
|
||||
handleOpenConfirmDialog(row);
|
||||
}}
|
||||
>
|
||||
<ThumbUpAltIcon />
|
||||
</IconButton>
|
||||
<ConfirmForm
|
||||
rowId={rowId}
|
||||
open={openConfirmDialog}
|
||||
handleClose={handleCloseConfirmDialog}
|
||||
handleDelete={handleConfirmDialog}
|
||||
confirmData={confirmData}
|
||||
/>
|
||||
{openConfirmDialog && (
|
||||
<ConfirmForm
|
||||
rowId={rowId}
|
||||
open={openConfirmDialog}
|
||||
handleClose={handleCloseConfirmDialog}
|
||||
confirmData={confirmData}
|
||||
/>
|
||||
)}
|
||||
<IconButton color="primary" onClick={() => handleOpenRejectDialog(row)}>
|
||||
<ThumbDownIcon />
|
||||
</IconButton>
|
||||
<RejectForm
|
||||
rowId={rowId}
|
||||
open={openRejectDialog}
|
||||
handleClose={handleCloseRejectDialog}
|
||||
handleDelete={handleRejectDialog}
|
||||
rejectData={rejectData}
|
||||
/>
|
||||
{openRejectDialog && (
|
||||
<RejectForm
|
||||
rowId={rowId}
|
||||
open={openRejectDialog}
|
||||
handleClose={handleCloseRejectDialog}
|
||||
rejectData={rejectData}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -7,7 +7,12 @@ import { GET_TRANSPORTATION_ASSISTANCE } from "@/core/data/apiRoutes";
|
||||
import { useTranslations } from "next-intl";
|
||||
import TableRowActions from "./TableRowActions";
|
||||
import { format } from "date-fns-jalali";
|
||||
|
||||
import {
|
||||
LocalizationProvider,
|
||||
MobileDateTimePicker,
|
||||
} from "@mui/x-date-pickers";
|
||||
import { AdapterDateFnsJalali } from "@mui/x-date-pickers/AdapterDateFnsJalali";
|
||||
import moment from "moment";
|
||||
function DashboardTransportationAssistanceComponent() {
|
||||
const t = useTranslations();
|
||||
const columns = useMemo(
|
||||
@@ -83,39 +88,53 @@ function DashboardTransportationAssistanceComponent() {
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => format(new Date(row.created_at), "yyyy/mm/dd"),
|
||||
accessorFn: (row) =>
|
||||
format(new Date(row.created_at), "HH:mm | yyyy/mm/dd"),
|
||||
id: "created_at",
|
||||
header: t("TransportationAssistance.created_at"),
|
||||
enableColumnFilter: true,
|
||||
datatype: "numeric",
|
||||
filterFn: "equals",
|
||||
columnFilterModeOptions: [
|
||||
"equals",
|
||||
"notEquals",
|
||||
"contains",
|
||||
"lessThan",
|
||||
"greaterThan",
|
||||
"between",
|
||||
],
|
||||
datatype: "date",
|
||||
filterFn: "lessThan",
|
||||
columnFilterModeOptions: ["lessThan", "greaterThan"],
|
||||
Cell: ({ renderedCellValue }) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
<Typography variant="body2" style={{ minWidth: "200px" }}>
|
||||
{renderedCellValue}
|
||||
</Typography>
|
||||
),
|
||||
Header: ({ column }) => <em>{column.columnDef.header}</em>,
|
||||
Filter: ({ column }) => {
|
||||
return (
|
||||
<LocalizationProvider dateAdapter={AdapterDateFnsJalali}>
|
||||
<MobileDateTimePicker
|
||||
onChange={(newValue) => {
|
||||
const date = new Date(newValue);
|
||||
const formattedDate = moment(date)
|
||||
.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={moment(column.getFilterValue())
|
||||
.locale("fa")
|
||||
.format("yyyy/mm/dd HH:mm")}
|
||||
/>
|
||||
</LocalizationProvider>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => format(new Date(row.updated_at), "yyyy/mm/dd"),
|
||||
accessorFn: (row) =>
|
||||
format(new Date(row.updated_at), "HH:mm | yyyy/mm/dd"),
|
||||
id: "updated_at",
|
||||
header: t("TransportationAssistance.updated_at"),
|
||||
enableColumnFilter: true,
|
||||
enableColumnFilter: false,
|
||||
datatype: "numeric",
|
||||
filterFn: "equals",
|
||||
columnFilterModeOptions: [
|
||||
"equals",
|
||||
"notEquals",
|
||||
"contains",
|
||||
"lessThan",
|
||||
"greaterThan",
|
||||
"between",
|
||||
],
|
||||
Cell: ({ renderedCellValue }) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
@@ -155,9 +174,9 @@ function DashboardTransportationAssistanceComponent() {
|
||||
accessorFn: (row) => row.state_name,
|
||||
id: "state_id",
|
||||
header: t("TransportationAssistance.state_name"),
|
||||
enableColumnFilter: true,
|
||||
enableColumnFilter: false,
|
||||
datatype: "numeric",
|
||||
filterFn: "equals",
|
||||
// filterFn: "equals",
|
||||
// filterSelectOptions: [
|
||||
// ],
|
||||
// filterVariant: "select",
|
||||
|
||||
@@ -3,7 +3,7 @@ import useLanguage from "@/lib/app/hooks/useLanguage";
|
||||
import { Typography } from "@mui/material";
|
||||
import axios from "axios";
|
||||
import MaterialReactTable from "material-react-table";
|
||||
import moment from "moment";
|
||||
import moment from "moment-jalaali";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useContext, useEffect, useMemo, useState } from "react";
|
||||
import useSWR from "swr";
|
||||
@@ -12,6 +12,7 @@ const DataTable = (props) => {
|
||||
const { reloadDataTable, setReloadDataTable } = useContext(
|
||||
ReloadDataTableContext
|
||||
);
|
||||
|
||||
const fetcher = (...args) => {
|
||||
return axios
|
||||
.get(args, {
|
||||
@@ -43,8 +44,9 @@ const DataTable = (props) => {
|
||||
const [sorting, setSorting] = useState([]);
|
||||
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 });
|
||||
const [rowCount, setRowCount] = useState(0);
|
||||
console.log(moment());
|
||||
const [updateTime, setupdateTime] = useState(
|
||||
moment().locale(languageApp).format("LL (HH:mm:ss)")
|
||||
moment().format("HH:mm | jYYYY/jM/jD")
|
||||
);
|
||||
|
||||
const tableLocalization = useMemo(
|
||||
@@ -97,7 +99,7 @@ const DataTable = (props) => {
|
||||
}, [reloadDataTable, setReloadDataTable]);
|
||||
|
||||
useEffect(() => {
|
||||
setupdateTime(moment().locale(languageApp).format("LL (HH:mm:ss)"));
|
||||
setupdateTime(moment().format("HH:mm | jYYYY/jM/jD"));
|
||||
}, [isValidating, languageApp]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -25,13 +25,13 @@ export const REJECT_PASSENGER_OFFICE =
|
||||
|
||||
//transportation assistance
|
||||
export const GET_TRANSPORTATION_ASSISTANCE =
|
||||
BASE_URL + "/dashboard/transportation_asisstants/show";
|
||||
BASE_URL + "/dashboard/transportation_assistant/show";
|
||||
|
||||
export const CONFIRM_TRANSPORTATION_ASSISTANCE =
|
||||
BASE_URL + "/dashboard/transportation_asisstants/confirm";
|
||||
BASE_URL + "/dashboard/transportation_assistant/confirm";
|
||||
|
||||
export const REJECT_TRANSPORTATION_ASSISTANCE =
|
||||
BASE_URL + "/dashboard/transportation_asisstants/reject";
|
||||
BASE_URL + "/dashboard/transportation_assistant/reject";
|
||||
//transportation assistance
|
||||
//machinary office
|
||||
export const GET_MACHINARY_OFFICE =
|
||||
|
||||
@@ -4,7 +4,7 @@ import theme from "./theme";
|
||||
const themeRtl = createTheme({
|
||||
direction: "rtl",
|
||||
typography: {
|
||||
fontFamily: `IRANSans, sans-serif`,
|
||||
fontFamily: `IRANSansFaNum, sans-serif`,
|
||||
},
|
||||
...theme,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user