diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx
index a67cac4..104561d 100644
--- a/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx
+++ b/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx
@@ -126,6 +126,7 @@ const CreateFormContent = ({ setOpen, SubmitDamage, defaultData }) => {
police_file_date: defaultData.police_file_date,
police_serial: defaultData.police_serial,
start_point: defaultData.start_point,
+ is_map_point: defaultData.is_map_point,
items_damage: defaultData.items_damage,
};
diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/DamageInfo.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/DamageInfo.jsx
index 1cec8c1..e312bd0 100644
--- a/src/components/dashboard/damages/operator/Actions/create/Forms/DamageInfo.jsx
+++ b/src/components/dashboard/damages/operator/Actions/create/Forms/DamageInfo.jsx
@@ -1,5 +1,5 @@
import { Controller, useWatch } from "react-hook-form";
-import { Grid, Stack, TextField, ToggleButton, ToggleButtonGroup } from "@mui/material";
+import { Box, Chip, Divider, Grid, Stack, TextField, ToggleButton, ToggleButtonGroup } from "@mui/material";
import MuiDatePicker from "@/core/components/MuiDatePicker";
import MuiTimePicker from "@/core/components/MuiTimePicker";
import SelectBox from "@/core/components/SelectBox";
@@ -8,10 +8,12 @@ import ImageUpload from "./ImageUpload";
import MapInfoOneMarker from "@/core/components/MapInfoOneMarker";
import PersianTextField from "@/core/components/PersianTextField";
import LogesticController from "./LogesticController";
+import LocationInputs from "./LocationInputs";
const DamageInfo = ({ control, setValue, errors }) => {
const StartPoint = useWatch({ control, name: "start_point" });
const IsForeign = useWatch({ control, name: "isForeign" });
+ const is_map_point = useWatch({ control, name: "is_map_point" });
return (
@@ -243,13 +245,41 @@ const DamageInfo = ({ control, setValue, errors }) => {
/>
-
-
+
+
+
+ (
+ {
+ if (newAlignment !== null) {
+ field.onChange(newAlignment)
+ }
+ }}
+ >
+ انتخاب روی نقشه
+ وارد کردن مختصات
+
+ )}
/>
+ {is_map_point == "1" ? (
+
+
+
+ ) : (
+
+ )}
);
diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/LocationInputs.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/LocationInputs.jsx
new file mode 100644
index 0000000..eb4e798
--- /dev/null
+++ b/src/components/dashboard/damages/operator/Actions/create/Forms/LocationInputs.jsx
@@ -0,0 +1,64 @@
+import LtrTextField from "@/core/components/LtrTextField";
+import { useState } from "react";
+import { useWatch } from "react-hook-form";
+
+const LocationInputs = ({ control, setValue, errors }) => {
+ const StartPoint = useWatch({ control, name: "start_point" });
+ const [coords, setCoords] = useState(StartPoint ? `${StartPoint.lat},${StartPoint.lng}` : '');
+ const [error, setError] = useState(false);
+
+ return (
+ {
+ const value = e.target.value.trim();
+ setCoords(value);
+
+ if (value === "") {
+ setValue("start_point", null);
+ setError(false);
+ return;
+ }
+
+ const parts = value.split(",").map((p) => p.trim());
+ if (parts.length !== 2) {
+ setError(true);
+ return;
+ }
+
+ const lat = Number(parts[0]);
+ const lng = Number(parts[1]);
+
+ if (
+ !isNaN(lat) &&
+ !isNaN(lng) &&
+ lat >= 25 &&
+ lat <= 40 &&
+ lng >= 44 &&
+ lng <= 64
+ ) {
+ setValue("start_point", { lat: lat, lng: lng });
+ setError(false);
+ } else {
+ setValue("start_point", null);
+ setError(true);
+ }
+ }}
+ InputLabelProps={{ shrink: true }}
+ />
+ )
+}
+export default LocationInputs
\ No newline at end of file
diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx
index 6537566..e7a28ba 100644
--- a/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx
+++ b/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx
@@ -55,7 +55,7 @@ const OperatorCreateForm = ({ open, setOpen, mutate }) => {
mutate();
setOpen(false);
})
- .catch(() => {});
+ .catch(() => { });
};
const defaultData = {
isForeign: "0",
@@ -83,6 +83,7 @@ const OperatorCreateForm = ({ open, setOpen, mutate }) => {
police_file_date: "",
police_serial: "",
start_point: "",
+ is_map_point: "1",
items_damage: [],
};
return (
diff --git a/src/components/dashboard/damages/operator/Form/EditForm/EditController.jsx b/src/components/dashboard/damages/operator/Form/EditForm/EditController.jsx
index 2d34b82..4f764d9 100644
--- a/src/components/dashboard/damages/operator/Form/EditForm/EditController.jsx
+++ b/src/components/dashboard/damages/operator/Form/EditForm/EditController.jsx
@@ -56,6 +56,7 @@ const EditController = ({ rowId, mutate, setOpenEditDialog }) => {
is_province: !hasCreateProvincePermission,
city_id: damageItemDetails?.city_id || null,
start_point: { lat: damageItemDetails?.lat || "", lng: damageItemDetails?.lng || "" },
+ is_map_point: "1",
};
const HandleSubmit = async (result) => {
const PlateNumber = `${result.plate_part1}-${result.plate_part2}-${result.plate_part3}-${result.plate_part4}`;
@@ -105,7 +106,7 @@ const EditController = ({ rowId, mutate, setOpenEditDialog }) => {
mutate();
setOpenEditDialog(false);
})
- .catch(() => {});
+ .catch(() => { });
};
return (
<>