diff --git a/src/components/dashboard/azmayesh/AzmayeshList.jsx b/src/components/dashboard/azmayesh/AzmayeshList.jsx
index 5e6d68c..a93940c 100644
--- a/src/components/dashboard/azmayesh/AzmayeshList.jsx
+++ b/src/components/dashboard/azmayesh/AzmayeshList.jsx
@@ -8,6 +8,7 @@ import { GET_AZMAYESH_LIST } from "@/core/utils/routes";
import ShowLocation from "./ShowLocation";
import moment from "jalali-moment";
import RowActions from "./RowActions";
+import ShowSampleOfAzmayesh from "./RowActions/ShowSampleOfAzmayesh";
const AzmayeshList = () => {
const columns = useMemo(
@@ -19,6 +20,16 @@ const AzmayeshList = () => {
enableColumnFilter: false,
datatype: "text",
filterMode: "notEquals",
+ grow: false,
+ size: 100
+ },
+ {
+ accessorKey: "province_name",
+ header: "استان",
+ id: "province_name",
+ enableColumnFilter: false,
+ datatype: "text",
+ filterMode: "notEquals",
},
{
accessorKey: "azmayesh_type_name",
@@ -28,6 +39,14 @@ const AzmayeshList = () => {
datatype: "text",
filterMode: "notEquals",
},
+ {
+ accessorKey: "contract_subitem_id",
+ header: "کد یکتا پروژه",
+ id: "contract_subitem_id",
+ enableColumnFilter: false,
+ datatype: "text",
+ filterMode: "equals",
+ },
{
accessorKey: "project_name",
header: "پروژه",
@@ -37,13 +56,24 @@ const AzmayeshList = () => {
filterMode: "equals",
},
{
- accessorKey: "lat",
+ accessorKey: "location",
header: "نمایش مختصات",
- id: "lat",
+ id: "location",
enableColumnFilter: false,
datatype: "text",
enableSorting: false,
filterMode: "equals",
+ grow: false,
+ size: 100,
+ muiTableBodyCellProps: {
+ sx: {
+ borderLeft: "1px solid #e1e1e1",
+ py: 0,
+ "&:first-of-type": {
+ borderLeft: "unset",
+ },
+ },
+ },
Cell: ({ row }) => ,
},
{
@@ -101,6 +131,8 @@ const AzmayeshList = () => {
enableColumnFilter: false,
datatype: "date",
filterMode: "equals",
+ grow: false,
+ size: 100,
Cell: ({ renderedCellValue }) => (
{renderedCellValue ? moment(renderedCellValue).locale("fa").format("YYYY/MM/DD") : "-"}
@@ -114,6 +146,8 @@ const AzmayeshList = () => {
enableColumnFilter: false,
datatype: "date",
filterMode: "equals",
+ grow: false,
+ size: 100,
Cell: ({ renderedCellValue }) => (
{renderedCellValue ? moment(renderedCellValue).locale("fa").format("YYYY/MM/DD") : "-"}
@@ -127,12 +161,35 @@ const AzmayeshList = () => {
enableColumnFilter: false,
datatype: "date",
filterMode: "equals",
+ grow: false,
+ size: 100,
Cell: ({ renderedCellValue }) => (
{renderedCellValue ? moment(renderedCellValue).locale("fa").format("HH:mm | YYYY/MM/DD") : "-"}
),
},
+ {
+ accessorKey: "samples",
+ header: "نمونه ها",
+ id: "samples",
+ enableColumnFilter: false,
+ datatype: "text",
+ enableSorting: false,
+ filterMode: "equals",
+ grow: false,
+ size: 100,
+ muiTableBodyCellProps: {
+ sx: {
+ borderLeft: "1px solid #e1e1e1",
+ py: 0,
+ "&:first-of-type": {
+ borderLeft: "unset",
+ },
+ },
+ },
+ Cell: ({ row }) => ,
+ },
],
[]
);
diff --git a/src/components/dashboard/azmayesh/Forms/CandUAzmayesh/CandUChooseLocation.jsx b/src/components/dashboard/azmayesh/Forms/CandUAzmayesh/CandUChooseLocation.jsx
index 469b1f5..030eac8 100644
--- a/src/components/dashboard/azmayesh/Forms/CandUAzmayesh/CandUChooseLocation.jsx
+++ b/src/components/dashboard/azmayesh/Forms/CandUAzmayesh/CandUChooseLocation.jsx
@@ -1,11 +1,12 @@
"use client";
import { Marker, useMapEvents } from "react-leaflet";
-import { useEffect, useRef } from "react";
+import { useEffect, useRef, useState } from "react";
import L from "leaflet";
import AzmayeshIcon from "@/assets/images/examine_marker.png";
import AzmayeshActiveIcon from "@/assets/images/examine_marker_active.png";
import {
+ Alert,
Box,
Button,
FormControl,
@@ -14,6 +15,7 @@ import {
OutlinedInput,
Stack,
Tooltip,
+ Zoom,
useMediaQuery,
} from "@mui/material";
import NewReleasesIcon from "@mui/icons-material/NewReleases";
@@ -21,9 +23,12 @@ import VerifiedIcon from "@mui/icons-material/Verified";
import EditIcon from "@mui/icons-material/Edit";
import { useTheme } from "@emotion/react";
+const MAX_ZOOM_FOR_MARKER = 13
+
const CandUChooseLocation = ({ mapBoxData, setMapBoxData }) => {
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
+ const [enableSend, setEnableSend] = useState(false);
const mapAzmayeshMarker = useRef();
const defaultIconSize = [35, 35];
@@ -38,6 +43,7 @@ const CandUChooseLocation = ({ mapBoxData, setMapBoxData }) => {
const map = useMapEvents({
move(e) {
+ setEnableSend(e.target.getZoom() > MAX_ZOOM_FOR_MARKER)
if (!mapBoxData) {
mapAzmayeshMarker.current.setLatLng(e.target.getCenter());
}
@@ -52,22 +58,25 @@ const CandUChooseLocation = ({ mapBoxData, setMapBoxData }) => {
mapAzmayeshMarker.current.setIcon(createCustomIcon(defaultIconSize, AzmayeshIcon.src));
}
},
+ zoom(e) {
+ setEnableSend(e.target.getZoom() > MAX_ZOOM_FOR_MARKER)
+ }
});
useEffect(() => {
- if (mapAzmayeshMarker.current) {
- const newIcon = mapBoxData
- ? createCustomIcon([45, 45], AzmayeshActiveIcon.src)
- : createCustomIcon(defaultIconSize, AzmayeshIcon.src);
- mapAzmayeshMarker.current.setIcon(newIcon);
- }
+ if (!mapAzmayeshMarker.current) return;
if (mapBoxData) {
+ mapAzmayeshMarker.current.setIcon(createCustomIcon([45, 45], AzmayeshActiveIcon.src));
mapAzmayeshMarker.current.setLatLng(mapBoxData);
- map.flyTo(mapBoxData, 14);
+ map.setView(mapBoxData, 14);
+ } else {
+ mapAzmayeshMarker.current.setIcon(createCustomIcon(defaultIconSize, AzmayeshIcon.src));
}
- }, [mapBoxData]);
+ }, [mapBoxData, mapAzmayeshMarker.current]);
+
const handleMarkerClick = () => {
+ if (!enableSend) return
if (!mapBoxData) {
setMapBoxData({
lat: mapAzmayeshMarker.current.getLatLng().lat,
@@ -86,93 +95,113 @@ const CandUChooseLocation = ({ mapBoxData, setMapBoxData }) => {
position={map.getCenter()}
ref={mapAzmayeshMarker}
eventHandlers={{ click: handleMarkerClick }}
- icon={createCustomIcon(defaultIconSize, AzmayeshIcon.src)}
/>
-
-
-
-
-
- طول جغرافیایی
-
-
- {mapBoxData ? (
-
- ) : (
-
- )}
-
- }
- label="طول جغرافیایی"
- />
-
-
-
-
-
- عرض جغرافیایی
-
-
- {mapBoxData ? (
-
- ) : (
-
- )}
-
- }
- label="عرض جغرافیایی"
- />
-
-
- }
- onClick={handleEditLocation}
- >
- ویرایش مختصات
-
-
-
+
+ برای ثبت محل آزمایش، لطفاً نقشه را بیشتر زوم کنید.
+
+
+
+
+
+
+
+
+ طول جغرافیایی
+
+
+ {mapBoxData ? (
+
+ ) : (
+
+ )}
+
+ }
+ label="طول جغرافیایی"
+ />
+
+
+
+
+
+ عرض جغرافیایی
+
+
+ {mapBoxData ? (
+
+ ) : (
+
+ )}
+
+ }
+ label="عرض جغرافیایی"
+ />
+
+
+ }
+ onClick={handleEditLocation}
+ >
+ ویرایش مختصات
+
+
+
+
>
);
};
diff --git a/src/components/dashboard/azmayesh/Forms/CandUAzmayesh/CandUGeneralInfo.jsx b/src/components/dashboard/azmayesh/Forms/CandUAzmayesh/CandUGeneralInfo.jsx
index 24f4493..359e5b9 100644
--- a/src/components/dashboard/azmayesh/Forms/CandUAzmayesh/CandUGeneralInfo.jsx
+++ b/src/components/dashboard/azmayesh/Forms/CandUAzmayesh/CandUGeneralInfo.jsx
@@ -66,6 +66,11 @@ const CandUGeneralInfo = ({ control, register, setValue, errors }) => {
label="نوع آزمایش"
/>
)}
+ renderOption={(props, option) => (
+
+ {option.name}
+
+ )}
/>
)}
@@ -122,6 +127,23 @@ const CandUGeneralInfo = ({ control, register, setValue, errors }) => {
)}
/>
+
+
+ کد یکتا پروژه
+
+
+ {errors.contract_subitem_id ? errors.contract_subitem_id.message : null}
+
+
+
پروژه
@@ -252,6 +274,7 @@ const CandUGeneralInfo = ({ control, register, setValue, errors }) => {
onChange={(newValue) => {
onChange(newValue);
}}
+ closeOnSelect
slotProps={{
textField: {
size: "small",
@@ -305,6 +328,7 @@ const CandUGeneralInfo = ({ control, register, setValue, errors }) => {
onChange={(newValue) => {
onChange(newValue);
}}
+ closeOnSelect
slotProps={{
textField: {
size: "small",
diff --git a/src/components/dashboard/azmayesh/Forms/CandUAzmayesh/FormAndRequest.jsx b/src/components/dashboard/azmayesh/Forms/CandUAzmayesh/FormAndRequest.jsx
index f74dd22..358451d 100644
--- a/src/components/dashboard/azmayesh/Forms/CandUAzmayesh/FormAndRequest.jsx
+++ b/src/components/dashboard/azmayesh/Forms/CandUAzmayesh/FormAndRequest.jsx
@@ -33,6 +33,7 @@ function TabPanel(props) {
const validationSchema = object({
azmayesh_type_id: string().required("نوع آزمایش را مشخص کنید!"),
province_id: string().required("استان را وارد کنید!"),
+ contract_subitem_id: string().required("کد یکتا پروژه را وارد کنید!"),
project_name: string().required("عنوان پروژه را وارد کنید!"),
employer: string().required("کارفرما را وارد کنید!"),
consultant: string().required("مشاور را وارد کنید!"),
@@ -72,6 +73,7 @@ const CandUAzmayesh = ({ setOpen, mutate, updateInfo, rowId }) => {
azmayesh_type_name: updateInfo ? updateInfo.azmayesh_type_name : "",
province_id: updateInfo ? updateInfo.province_id : "",
province_name: updateInfo ? updateInfo.province_name : "",
+ contract_subitem_id: updateInfo ? updateInfo.contract_subitem_id : "",
project_name: updateInfo ? updateInfo.project_name : "",
employer: updateInfo ? updateInfo.employer : "",
consultant: updateInfo ? updateInfo.consultant : "",
@@ -99,6 +101,7 @@ const CandUAzmayesh = ({ setOpen, mutate, updateInfo, rowId }) => {
formData.append("azmayesh_type_name", data.azmayesh_type_name);
formData.append("province_id", data.province_id);
formData.append("province_name", data.province_name);
+ formData.append("contract_subitem_id", data.contract_subitem_id);
formData.append("project_name", data.project_name);
formData.append("employer", data.employer);
formData.append("consultant", data.consultant);
@@ -109,14 +112,15 @@ const CandUAzmayesh = ({ setOpen, mutate, updateInfo, rowId }) => {
formData.append("request_date", moment(new Date(data.request_date)).format("YYYY-MM-DD"));
formData.append("report_date", moment(new Date(data.report_date)).format("YYYY-MM-DD"));
- requestServer(updateInfo ? `${UPDATE_AZMAYESH}/${rowId}` : CREATE_AZMAYESH, "post", {
- data: formData,
- })
- .then(() => {
- mutate();
- handleClose();
- })
- .catch(() => {});
+ try {
+ const url = updateInfo ? `${UPDATE_AZMAYESH}/${rowId}` : CREATE_AZMAYESH;
+ await requestServer(url, "post", {
+ data: formData,
+ });
+ mutate();
+ handleClose();
+ } catch (error) {
+ }
};
return (
@@ -187,8 +191,8 @@ const CandUAzmayesh = ({ setOpen, mutate, updateInfo, rowId }) => {
? "در حال ویرایش آزمایش"
: "ویرایش آزمایش"
: isSubmitting
- ? "در حال ثبت آزمایش"
- : "ثبت آزمایش"}
+ ? "در حال ثبت آزمایش"
+ : "ثبت آزمایش"}
)}
diff --git a/src/components/dashboard/azmayesh/RowActions/ShowSampleOfAzmayesh/ShowSampleList.jsx b/src/components/dashboard/azmayesh/RowActions/ShowSampleOfAzmayesh/ShowSampleList.jsx
index 2c11f67..e55d9ab 100644
--- a/src/components/dashboard/azmayesh/RowActions/ShowSampleOfAzmayesh/ShowSampleList.jsx
+++ b/src/components/dashboard/azmayesh/RowActions/ShowSampleOfAzmayesh/ShowSampleList.jsx
@@ -24,10 +24,12 @@ const ShowSampleList = ({ sampleInfo, rowData }) => {
id: "id",
enableColumnFilter: false,
datatype: "text",
+ grow: false,
+ size: 100,
},
...sampleInfo.map((item) => ({
accessorKey: item.id.toString(),
- header: item.name,
+ header: item.unit ? `${item.name} (${item.unit})` : item.name,
id: item.id.toString(),
enableColumnFilter: false,
datatype: "text",
@@ -38,6 +40,8 @@ const ShowSampleList = ({ sampleInfo, rowData }) => {
id: "updated_at",
enableColumnFilter: false,
datatype: "date",
+ grow: false,
+ size: 100,
Cell: ({ renderedCellValue }) => (
{renderedCellValue ? moment(renderedCellValue).locale("fa").format("HH:mm | YYYY/MM/DD") : "-"}
diff --git a/src/components/dashboard/azmayesh/RowActions/ShowSampleOfAzmayesh/index.jsx b/src/components/dashboard/azmayesh/RowActions/ShowSampleOfAzmayesh/index.jsx
index 1677d82..a369fc9 100644
--- a/src/components/dashboard/azmayesh/RowActions/ShowSampleOfAzmayesh/index.jsx
+++ b/src/components/dashboard/azmayesh/RowActions/ShowSampleOfAzmayesh/index.jsx
@@ -1,4 +1,4 @@
-import { Button, Dialog, DialogActions, DialogContent, IconButton, Tooltip } from "@mui/material";
+import { Box, Button, Dialog, DialogActions, DialogContent, IconButton, Tooltip } from "@mui/material";
import AssignmentIcon from "@mui/icons-material/Assignment";
import { useState } from "react";
import ShowSampleList from "./ShowSampleList";
@@ -14,13 +14,13 @@ const ShowSampleOfAzmayesh = ({ rowData }) => {
.then((response) => {
setSampleInfo(response.data.data);
})
- .catch(() => {})
+ .catch(() => { })
.finally(() => {
setOpenShowSampleDialog(true);
});
};
return (
- <>
+
{
-
);
};
export default ShowSampleOfAzmayesh;
diff --git a/src/components/dashboard/azmayesh/RowActions/index.jsx b/src/components/dashboard/azmayesh/RowActions/index.jsx
index 19447cb..7f6440d 100644
--- a/src/components/dashboard/azmayesh/RowActions/index.jsx
+++ b/src/components/dashboard/azmayesh/RowActions/index.jsx
@@ -7,7 +7,6 @@ const RowActions = ({ row, mutate }) => {
return (
-
);
diff --git a/src/core/components/FormMaker/InputType.jsx b/src/core/components/FormMaker/InputType.jsx
index 0f36eb8..c87dedf 100644
--- a/src/core/components/FormMaker/InputType.jsx
+++ b/src/core/components/FormMaker/InputType.jsx
@@ -9,13 +9,16 @@ const InputType = ({ itemInfo, defaultValues, setDefaultValues }) => {
[itemInfo.id]: value,
}));
};
+ console.log(itemInfo);
+
+ const label = itemInfo.unit ? `${itemInfo.name} (${itemInfo.unit})` : itemInfo.name
return (
- {itemInfo.name}
+ {label}
{
[itemInfo.id]: newValue,
}));
};
-
+ const label = itemInfo.unit ? `${itemInfo.name} (${itemInfo.unit})` : itemInfo.name
return (
- {itemInfo.name}
+ {label}