Feature/fixe bugs
This commit is contained in:
@@ -42,6 +42,7 @@ const AzmayeshList = () => {
|
||||
id: "lat",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
enableSorting: false,
|
||||
filterFn: "equals",
|
||||
Cell: ({ row }) => <ShowLocation lat={row.original.lat} lng={row.original.lng} />,
|
||||
},
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
import {
|
||||
Button, Collapse,
|
||||
DialogActions,
|
||||
DialogContent, Grid,
|
||||
Stack, TextField
|
||||
} from "@mui/material";
|
||||
import { Button, Collapse, DialogActions, DialogContent, Grid, Stack, TextField } from "@mui/material";
|
||||
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||
import {useFormik} from "formik";
|
||||
import { useFormik } from "formik";
|
||||
import moment from "jalali-moment";
|
||||
import * as Yup from "yup";
|
||||
import {useState} from "react";
|
||||
import { useState } from "react";
|
||||
import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail";
|
||||
import DetailMap from "@/core/components/ApplicantRequestDetail/DetailMap";
|
||||
import FlyToPolyline from "@/core/components/ApplicantRequestDetail/FlyToPolyline";
|
||||
import {MapContainer} from "react-leaflet";
|
||||
import { MapContainer } from "react-leaflet";
|
||||
import dynamic from "next/dynamic";
|
||||
import MapLoading from "@/core/components/MapLayer/Loading";
|
||||
const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
|
||||
@@ -37,55 +32,51 @@ const fakeData = {
|
||||
address: "کرج - فلان جا - جنب پاساژ - نزدیک اونجا - اونور خیابون - زیر رو گذر - روی زیر گذر",
|
||||
file_mosavab: "file",
|
||||
polyline: [
|
||||
[35.6892, 51.3890],
|
||||
[35.6892, 51.389],
|
||||
[35.7074, 51.3929],
|
||||
],
|
||||
};
|
||||
|
||||
const CarDetailsContent = ({setOpenCarDialog}) => {
|
||||
const [openCarDetailContent, setOpenCarDetailContent] = useState(false)
|
||||
const CarDetailsContent = ({ setOpenCarDialog }) => {
|
||||
const [openCarDetailContent, setOpenCarDetailContent] = useState(false);
|
||||
const initialValues = {
|
||||
start_date: "",
|
||||
end_date: "",
|
||||
vehicle_code: "",
|
||||
}
|
||||
};
|
||||
|
||||
const validationSchema = Yup.object().shape({
|
||||
start_date: Yup.string().required("تاریخ شروع الزامیست!!!"),
|
||||
end_date: Yup.string().test(
|
||||
"is-greater",
|
||||
"تاریخ اتمام نمیتواند کمتر از تاریخ شروع باشد",
|
||||
function (value) {
|
||||
const {start_date} = this.parent; // Access other field values
|
||||
end_date: Yup.string()
|
||||
.test("is-greater", "تاریخ اتمام نمیتواند کمتر از تاریخ شروع باشد", function (value) {
|
||||
const { start_date } = this.parent; // Access other field values
|
||||
if (!value || !start_date) return true; // Skip validation if either field is empty
|
||||
return moment(value, "YYYY/MM/DD").isSameOrAfter(
|
||||
moment(start_date, "YYYY/MM/DD")
|
||||
);
|
||||
}
|
||||
).required("تاریخ اتمام الزامیست!!!"),
|
||||
return moment(value, "YYYY/MM/DD").isSameOrAfter(moment(start_date, "YYYY/MM/DD"));
|
||||
})
|
||||
.required("تاریخ اتمام الزامیست!!!"),
|
||||
vehicle_code: Yup.mixed()
|
||||
.test("is-number", "کد خودرو باید عدد باشد!!!", (value) => !isNaN(value))
|
||||
.test("positive", "کد خودرو باید مثبت باشد!!!", (value) => value >= 0)
|
||||
.required("کد خودرو الزامیست!!!"),
|
||||
})
|
||||
});
|
||||
|
||||
const handleSubmit = async (values, props) => {
|
||||
props.setSubmitting(true);
|
||||
setOpenCarDetailContent(true)
|
||||
console.log(values)
|
||||
}
|
||||
setOpenCarDetailContent(true);
|
||||
console.log(values);
|
||||
};
|
||||
|
||||
const formik = useFormik({
|
||||
initialValues,
|
||||
validationSchema,
|
||||
onSubmit: handleSubmit,
|
||||
});
|
||||
console.log(formik.errors)
|
||||
console.log(formik.errors);
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<Stack spacing={2} sx={{my: 2}}>
|
||||
<Stack direction={"row"} spacing={2} sx={{my: 2}}>
|
||||
<Stack spacing={2} sx={{ my: 2 }}>
|
||||
<Stack direction={"row"} spacing={2} sx={{ my: 2 }}>
|
||||
<MuiDatePicker
|
||||
formik={formik}
|
||||
value={formik.values.start_date}
|
||||
@@ -131,15 +122,18 @@ const CarDetailsContent = ({setOpenCarDialog}) => {
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<Button variant={"contained"} color={"primary"}
|
||||
onClick={formik.handleSubmit}>
|
||||
<Button variant={"contained"} color={"primary"} onClick={formik.handleSubmit}>
|
||||
نمایش اطلاعات
|
||||
</Button>
|
||||
</Stack>
|
||||
</Stack>
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={12} sm={4}>
|
||||
<Stack direction="column" sx={{height : "100%", justifyContent: "start", alignItems: "center"}} spacing={5}>
|
||||
<Stack
|
||||
direction="column"
|
||||
sx={{ height: "100%", justifyContent: "start", alignItems: "center" }}
|
||||
spacing={5}
|
||||
>
|
||||
<TextField
|
||||
name="vehicle_code"
|
||||
label={"مصرف سوخت خودرو"}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
"use client";
|
||||
import PageTitle from "@/core/components/PageTitle";
|
||||
import {Dialog, DialogTitle, IconButton, Stack, Tooltip} from "@mui/material";
|
||||
import {useState} from "react";
|
||||
import { Dialog, DialogTitle, IconButton, Stack, Tooltip } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import DriveEtaIcon from "@mui/icons-material/DriveEta";
|
||||
import CarDetailsContent from "@/components/dashboard/carDetails/CarDetailsContent";
|
||||
|
||||
const TestPage = () => {
|
||||
const [openCarDialog, setOpenCarDialog] = useState(false)
|
||||
const [openCarDialog, setOpenCarDialog] = useState(false);
|
||||
return (
|
||||
<Stack spacing={1}>
|
||||
<PageTitle title={"نمایش اطلاعات خودرو"} />
|
||||
@@ -22,20 +22,19 @@ const TestPage = () => {
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
onClose={()=>setOpenCarDialog(false)}
|
||||
onClose={() => setOpenCarDialog(false)}
|
||||
fullWidth
|
||||
open={openCarDialog}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
transition: "all .3s",
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
boxShadow:
|
||||
"rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
},
|
||||
}}
|
||||
maxWidth={"lg"}
|
||||
>
|
||||
<DialogTitle>
|
||||
نمایش اطلاعات خودرو
|
||||
</DialogTitle>
|
||||
<DialogTitle>نمایش اطلاعات خودرو</DialogTitle>
|
||||
<CarDetailsContent setOpenCarDialog={setOpenCarDialog} />
|
||||
</Dialog>
|
||||
</>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ExpandLess, ExpandMore, Link } from "@mui/icons-material";
|
||||
import { Button, Divider, ListItemIcon, ListItemText, Menu, MenuItem } from "@mui/material";
|
||||
import { Button, Divider, ListItemIcon, ListItemText, Menu, MenuItem, Stack } from "@mui/material";
|
||||
import NextLink from "next/link";
|
||||
import { useState } from "react";
|
||||
|
||||
@@ -15,7 +15,7 @@ const HeaderMenu = ({ menu }) => {
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack sx={{ mr: 0.5 }}>
|
||||
<Button
|
||||
color="inherit"
|
||||
aria-haspopup="true"
|
||||
@@ -38,7 +38,7 @@ const HeaderMenu = ({ menu }) => {
|
||||
index < menu.subMenu.length - 1 && <Divider key={`divider-${index}`} />,
|
||||
])}
|
||||
</Menu>
|
||||
</>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"use client";
|
||||
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
|
||||
import MenuIcon from "@mui/icons-material/Menu";
|
||||
import { Box, Drawer, IconButton, Stack, styled, Toolbar, Typography } from "@mui/material";
|
||||
import { Box, Drawer, IconButton, Stack, styled, Toolbar, Typography, useMediaQuery, useTheme } from "@mui/material";
|
||||
import MuiAppBar from "@mui/material/AppBar";
|
||||
import { useState } from "react";
|
||||
import { useState, useEffect } from "react";
|
||||
import HeaderMenu from "./HeaderMenu";
|
||||
import moment from "jalali-moment";
|
||||
import { headerMenu } from "@/core/utils/headerMenu";
|
||||
@@ -56,7 +56,14 @@ const DrawerHeader = styled("div")(({ theme }) => ({
|
||||
}));
|
||||
|
||||
const HeaderWithSidebar = ({ children }) => {
|
||||
const [open, setOpen] = useState(true);
|
||||
const theme = useTheme();
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down("md")); // Detect mobile/tablet screen
|
||||
const [open, setOpen] = useState(!isMobile); // Initial state based on screen size
|
||||
|
||||
useEffect(() => {
|
||||
setOpen(!isMobile); // Toggle state when screen size changes
|
||||
}, [isMobile]);
|
||||
|
||||
const now = moment().locale("fa").format("YYYY/MM/DD");
|
||||
|
||||
const handleDrawerOpen = () => {
|
||||
@@ -65,6 +72,7 @@ const HeaderWithSidebar = ({ children }) => {
|
||||
const handleDrawerClose = () => {
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
@@ -85,7 +93,18 @@ const HeaderWithSidebar = ({ children }) => {
|
||||
>
|
||||
<MenuIcon />
|
||||
</IconButton>
|
||||
<Box sx={{ flexGrow: 1, display: { xs: "none", md: "flex" } }}>
|
||||
<Box
|
||||
sx={{
|
||||
flexGrow: 1,
|
||||
display: "flex",
|
||||
overflowX: "auto",
|
||||
whiteSpace: "nowrap",
|
||||
scrollbarWidth: "none",
|
||||
"&::-webkit-scrollbar": {
|
||||
display: "none",
|
||||
},
|
||||
}}
|
||||
>
|
||||
{headerMenu.map((menu) => (
|
||||
<HeaderMenu key={menu.title} menu={menu} />
|
||||
))}
|
||||
@@ -132,4 +151,5 @@ const HeaderWithSidebar = ({ children }) => {
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default HeaderWithSidebar;
|
||||
|
||||
Reference in New Issue
Block a user