From 4680547d26f01456795032609256f76695359268 Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Mon, 8 Sep 2025 11:39:48 +0330 Subject: [PATCH 1/3] add location input --- .../create/Forms/CreateFormContent.jsx | 1 + .../Actions/create/Forms/DamageInfo.jsx | 44 +++++++++++-- .../Actions/create/Forms/LocationInputs.jsx | 64 +++++++++++++++++++ .../operator/Actions/create/Forms/index.jsx | 3 +- .../operator/Form/EditForm/EditController.jsx | 3 +- 5 files changed, 106 insertions(+), 9 deletions(-) create mode 100644 src/components/dashboard/damages/operator/Actions/create/Forms/LocationInputs.jsx 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 ( <> From 4d1cee088976cb52e5f85e513802bba0920059a0 Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Mon, 8 Sep 2025 11:41:05 +0330 Subject: [PATCH 2/3] formating --- .../Actions/create/Forms/DamageInfo.jsx | 4 +-- .../Actions/create/Forms/LocationInputs.jsx | 25 +++++++------------ .../operator/Actions/create/Forms/index.jsx | 2 +- .../operator/Form/EditForm/EditController.jsx | 2 +- 4 files changed, 13 insertions(+), 20 deletions(-) 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 e312bd0..3a021d0 100644 --- a/src/components/dashboard/damages/operator/Actions/create/Forms/DamageInfo.jsx +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/DamageInfo.jsx @@ -245,7 +245,7 @@ const DamageInfo = ({ control, setValue, errors }) => { /> - + @@ -259,7 +259,7 @@ const DamageInfo = ({ control, setValue, errors }) => { size="small" onChange={(event, newAlignment) => { if (newAlignment !== null) { - field.onChange(newAlignment) + field.onChange(newAlignment); } }} > diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/LocationInputs.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/LocationInputs.jsx index eb4e798..056e534 100644 --- a/src/components/dashboard/damages/operator/Actions/create/Forms/LocationInputs.jsx +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/LocationInputs.jsx @@ -4,7 +4,7 @@ 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 [coords, setCoords] = useState(StartPoint ? `${StartPoint.lat},${StartPoint.lng}` : ""); const [error, setError] = useState(false); return ( @@ -17,13 +17,13 @@ const LocationInputs = ({ control, setValue, errors }) => { helperText={ error ? "فرمت یا محدوده مقادیر معتبر نیست (ابتدا عرض جغرافیایی + , + انتها طول جغرافیایی)" - : errors.start_point ? - errors.start_point.message - : "ابتدا عرض جغرافیایی + , + انتها طول جغرافیایی" + : errors.start_point + ? errors.start_point.message + : "ابتدا عرض جغرافیایی + , + انتها طول جغرافیایی" } error={error || errors.start_point} value={coords} - onChange={e => { + onChange={(e) => { const value = e.target.value.trim(); setCoords(value); @@ -42,14 +42,7 @@ const LocationInputs = ({ control, setValue, errors }) => { const lat = Number(parts[0]); const lng = Number(parts[1]); - if ( - !isNaN(lat) && - !isNaN(lng) && - lat >= 25 && - lat <= 40 && - lng >= 44 && - lng <= 64 - ) { + if (!isNaN(lat) && !isNaN(lng) && lat >= 25 && lat <= 40 && lng >= 44 && lng <= 64) { setValue("start_point", { lat: lat, lng: lng }); setError(false); } else { @@ -59,6 +52,6 @@ const LocationInputs = ({ control, setValue, errors }) => { }} InputLabelProps={{ shrink: true }} /> - ) -} -export default LocationInputs \ No newline at end of file + ); +}; +export default LocationInputs; 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 e7a28ba..06197ca 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", diff --git a/src/components/dashboard/damages/operator/Form/EditForm/EditController.jsx b/src/components/dashboard/damages/operator/Form/EditForm/EditController.jsx index 4f764d9..4c6fcbd 100644 --- a/src/components/dashboard/damages/operator/Form/EditForm/EditController.jsx +++ b/src/components/dashboard/damages/operator/Form/EditForm/EditController.jsx @@ -106,7 +106,7 @@ const EditController = ({ rowId, mutate, setOpenEditDialog }) => { mutate(); setOpenEditDialog(false); }) - .catch(() => { }); + .catch(() => {}); }; return ( <> From 8a315c7cce6857c04268594c31c9bbcd1d04e550 Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Mon, 8 Sep 2025 11:42:09 +0330 Subject: [PATCH 3/3] change version to 1.7.5 --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 7c7adbf..7db04c4 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ HOST="rms.witel.ir" -NEXT_PUBLIC_VERSION="1.7.4" +NEXT_PUBLIC_VERSION="1.7.5" NEXT_PUBLIC_API_URL="https://rms.witel.ir" NEXT_PUBLIC_MAPTILE_ENDPOINT="https://rmsmap.rmto.ir/141map" \ No newline at end of file