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>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user