- {value === index && (
-
- {children}
-
- )}
+
+ {value === index && {children}}
);
}
-const CreateDialog = ({open, setOpen}) => {
+const CreateDialog = ({ open, setOpen, mutate }) => {
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
const [tabState, setTabState] = useState(0);
@@ -55,7 +48,7 @@ const CreateDialog = ({open, setOpen}) => {
if (tabState === 0) {
handleClose();
} else {
- setTabState(tabState - 1)
+ setTabState(tabState - 1);
}
};
@@ -72,7 +65,7 @@ const CreateDialog = ({open, setOpen}) => {
request_date: string().required("تاریخ درخواست را وارد کنید!"),
report_date: string().required("تاریخ گزارش را وارد کنید!"),
});
- const requestServer = useRequest({auth: true});
+ const requestServer = useRequest({ auth: true });
const defaultValues = {
azmayesh_type_id: "",
@@ -95,11 +88,10 @@ const CreateDialog = ({open, setOpen}) => {
register,
handleSubmit,
setValue,
- formState: {isSubmitting, errors, touchedFields},
- } = useForm({defaultValues, resolver: yupResolver(validationSchema), mode: "onBlur"});
+ formState: { isSubmitting, errors, touchedFields },
+ } = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "onBlur" });
const onSubmit = async (data) => {
- console.log("data", data);
const formData = new FormData();
formData.append("lat", mapBoxData.lat);
formData.append("lng", mapBoxData.lng);
@@ -117,68 +109,85 @@ const CreateDialog = ({open, setOpen}) => {
formData.append("request_date", moment(data.request_date).format("YYYY-MM-DD"));
formData.append("report_date", moment(data.report_date).format("YYYY-MM-DD"));
- for (var pair of formData.entries()) {
- console.log(pair[0] + ', ' + pair[1]);
- }
-
- requestServer(POST_TEST, "post", {
+ requestServer(POST_AZMAYESH, "post", {
data: formData,
})
.then(() => {
+ mutate();
handleClose();
})
- .catch(() => {
- });
+ .catch(() => {});
};
return (
diff --git a/src/components/dashboard/test/Actions/create/index.jsx b/src/components/dashboard/azmayesh/Actions/Create/index.jsx
similarity index 64%
rename from src/components/dashboard/test/Actions/create/index.jsx
rename to src/components/dashboard/azmayesh/Actions/Create/index.jsx
index 9d59d00..88de5f6 100644
--- a/src/components/dashboard/test/Actions/create/index.jsx
+++ b/src/components/dashboard/azmayesh/Actions/Create/index.jsx
@@ -1,12 +1,12 @@
"use client";
-import {Button, IconButton, useMediaQuery} from "@mui/material";
-import {useTheme} from "@emotion/react";
-import {useState} from "react";
-import {AddCircle} from "@mui/icons-material";
+import { Button, IconButton, useMediaQuery } from "@mui/material";
+import { useTheme } from "@emotion/react";
+import { useState } from "react";
+import { AddCircle } from "@mui/icons-material";
import CreateDialog from "./CreateDialog";
-const TestCreate = () => {
+const AzmayeshCreate = ({ mutate }) => {
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
const [open, setOpen] = useState(false);
@@ -19,15 +19,15 @@ const TestCreate = () => {
<>
{isMobile ? (
-
+
) : (
-
} onClick={handleOpen}>
+ } onClick={handleOpen}>
ثبت آزمایش
)}
- {open &&
}
+ {open && }
>
);
};
-export default TestCreate;
+export default AzmayeshCreate;
diff --git a/src/components/dashboard/test/TestList.jsx b/src/components/dashboard/azmayesh/AzmayeshList.jsx
similarity index 81%
rename from src/components/dashboard/test/TestList.jsx
rename to src/components/dashboard/azmayesh/AzmayeshList.jsx
index 2c735f4..f9b30c5 100644
--- a/src/components/dashboard/test/TestList.jsx
+++ b/src/components/dashboard/azmayesh/AzmayeshList.jsx
@@ -1,14 +1,14 @@
"use client";
-import {useMemo} from "react";
-import {Box, Typography} from "@mui/material";
+import { useMemo } from "react";
+import { Box, Typography } from "@mui/material";
import DataTableWithAuth from "@/core/components/DataTableWithAuth";
import Toolbar from "./Toolbar";
-import {GET_AZMAYESH_LIST} from "@/core/utils/routes";
+import { GET_AZMAYESH_LIST } from "@/core/utils/routes";
import moment from "jalali-moment";
import ShowLocation from "./ShowLocation";
-const TestList = () => {
+const AzmayeshList = () => {
const columns = useMemo(
() => [
{
@@ -42,7 +42,7 @@ const TestList = () => {
enableColumnFilter: false,
datatype: "text",
filterFn: "equals",
- Cell: ({row}) => (),
+ Cell: ({ row }) => ,
},
{
accessorKey: "employer",
@@ -99,8 +99,11 @@ const TestList = () => {
enableColumnFilter: false,
datatype: "date",
filterFn: "equals",
- Cell: ({renderedCellValue}) => ({moment(renderedCellValue).locale("fa").format("YYYY/MM/DD")}),
+ Cell: ({ renderedCellValue }) => (
+
+ {moment(renderedCellValue).locale("fa").format("YYYY/MM/DD")}
+
+ ),
},
{
accessorKey: "report_date",
@@ -109,8 +112,11 @@ const TestList = () => {
enableColumnFilter: false,
datatype: "date",
filterFn: "equals",
- Cell: ({renderedCellValue}) => ({moment(renderedCellValue).locale("fa").format("YYYY/MM/DD")}),
+ Cell: ({ renderedCellValue }) => (
+
+ {moment(renderedCellValue).locale("fa").format("YYYY/MM/DD")}
+
+ ),
},
],
[]
@@ -118,7 +124,7 @@ const TestList = () => {
return (
<>
-
+
{
>
);
};
-export default TestList;
+export default AzmayeshList;
diff --git a/src/components/dashboard/test/ShowLocation/ShowLocationMarker.jsx b/src/components/dashboard/azmayesh/ShowLocation/ShowLocationMarker.jsx
similarity index 60%
rename from src/components/dashboard/test/ShowLocation/ShowLocationMarker.jsx
rename to src/components/dashboard/azmayesh/ShowLocation/ShowLocationMarker.jsx
index 6b65250..20b44cb 100644
--- a/src/components/dashboard/test/ShowLocation/ShowLocationMarker.jsx
+++ b/src/components/dashboard/azmayesh/ShowLocation/ShowLocationMarker.jsx
@@ -1,55 +1,54 @@
"use client";
-import {Marker, useMap} from "react-leaflet";
-import {useEffect, useRef} from "react";
+import { Marker, useMap } from "react-leaflet";
+import { useEffect } from "react";
import L from "leaflet";
-import TestActiveIcon from "@/assets/images/examine_marker_active.png";
-import {Box, FormControl, InputAdornment, InputLabel, OutlinedInput, Stack, useMediaQuery} from "@mui/material";
-import VerifiedIcon from '@mui/icons-material/Verified';
-import {useTheme} from "@emotion/react";
+import AzmayeshActiveIcon from "@/assets/images/examine_marker_active.png";
+import { Box, FormControl, InputAdornment, InputLabel, OutlinedInput, Stack, useMediaQuery } from "@mui/material";
+import VerifiedIcon from "@mui/icons-material/Verified";
+import { useTheme } from "@emotion/react";
-const ShowLocationMarker = ({lat, lng}) => {
+const ShowLocationMarker = ({ lat, lng }) => {
const map = useMap();
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
- const mapTestMarker = useRef();
const defaultIconSize = [35, 35];
const createCustomIcon = (size, iconUrl) => {
return L.icon({
iconUrl: iconUrl,
iconSize: size,
iconAnchor: [size[0] / 2, size[1]],
- popupAnchor: [0, -size[1]]
+ popupAnchor: [0, -size[1]],
});
};
useEffect(() => {
- map.flyTo({lat: lat, lng: lng}, 14);
+ map.flyTo({ lat: lat, lng: lng }, 14);
}, []);
-
return (
<>
-
-
+
+
-
+
طول جغرافیایی
{
size="small"
readOnly
sx={{
- '& .MuiOutlinedInput-notchedOutline': {
+ "& .MuiOutlinedInput-notchedOutline": {
borderColor: "success.main",
},
- color: "success.main"
+ color: "success.main",
}}
value={lat}
endAdornment={
-
+
}
label="طول جغرافیایی"
/>
-
+
عرض جغرافیایی
{
size="small"
readOnly
sx={{
- '& .MuiOutlinedInput-notchedOutline': {
+ "& .MuiOutlinedInput-notchedOutline": {
borderColor: "success.main",
},
- color: "success.main"
+ color: "success.main",
}}
value={lng}
endAdornment={
-
+
}
label="عرض جغرافیایی"
@@ -102,4 +101,4 @@ const ShowLocationMarker = ({lat, lng}) => {
);
};
-export default ShowLocationMarker;
\ No newline at end of file
+export default ShowLocationMarker;
diff --git a/src/components/dashboard/test/ShowLocation/index.jsx b/src/components/dashboard/azmayesh/ShowLocation/index.jsx
similarity index 76%
rename from src/components/dashboard/test/ShowLocation/index.jsx
rename to src/components/dashboard/azmayesh/ShowLocation/index.jsx
index 557a780..c260da7 100644
--- a/src/components/dashboard/test/ShowLocation/index.jsx
+++ b/src/components/dashboard/azmayesh/ShowLocation/index.jsx
@@ -1,18 +1,18 @@
"use client";
import ExploreIcon from "@mui/icons-material/Explore";
-import {Box, Button, Dialog, DialogActions, DialogContent, IconButton} from "@mui/material";
-import {useState} from "react";
+import { Box, Button, Dialog, DialogActions, DialogContent, IconButton } from "@mui/material";
+import { useState } from "react";
import dynamic from "next/dynamic";
import MapLoading from "@/core/components/MapLayer/Loading";
import ShowLocationMarker from "./ShowLocationMarker";
const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
- loading: () => ,
+ loading: () => ,
ssr: false,
});
-const ShowLocation = ({lat, lng}) => {
+const ShowLocation = ({ lat, lng }) => {
const [openShowLocationModal, setOpenShowLocationModal] = useState(false);
const handleOpenShowLocationModal = () => {
@@ -24,17 +24,19 @@ const ShowLocation = ({lat, lng}) => {
};
return (
-
-
+
+
+
+