Merge branch 'release/v1.7.5'
This commit is contained in:
@@ -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"
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
|
||||
@@ -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 (
|
||||
<Stack>
|
||||
@@ -243,13 +245,41 @@ const DamageInfo = ({ control, setValue, errors }) => {
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Stack sx={{ mt: 2 }}>
|
||||
<MapInfoOneMarker
|
||||
setValue={setValue}
|
||||
StartPoint={StartPoint}
|
||||
errors={errors}
|
||||
title={"برای ثبت محل تصادف، لطفاً نقشه را بیشتر زوم کنید."}
|
||||
<Stack sx={{ mt: 2 }} spacing={3} alignItems={"center"}>
|
||||
<Divider sx={{ width: "100%" }}>
|
||||
<Chip label="انتخاب محل تصادف" />
|
||||
</Divider>
|
||||
<Controller
|
||||
name="is_map_point"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<ToggleButtonGroup
|
||||
value={field.value}
|
||||
exclusive
|
||||
size="small"
|
||||
onChange={(event, newAlignment) => {
|
||||
if (newAlignment !== null) {
|
||||
field.onChange(newAlignment);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<ToggleButton value="1">انتخاب روی نقشه</ToggleButton>
|
||||
<ToggleButton value="2">وارد کردن مختصات</ToggleButton>
|
||||
</ToggleButtonGroup>
|
||||
)}
|
||||
/>
|
||||
{is_map_point == "1" ? (
|
||||
<Box sx={{ width: "100%" }}>
|
||||
<MapInfoOneMarker
|
||||
setValue={setValue}
|
||||
StartPoint={StartPoint}
|
||||
errors={errors}
|
||||
title={"برای ثبت محل تصادف، لطفاً نقشه را بیشتر زوم کنید."}
|
||||
/>
|
||||
</Box>
|
||||
) : (
|
||||
<LocationInputs control={control} setValue={setValue} errors={errors} />
|
||||
)}
|
||||
</Stack>
|
||||
</Stack>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
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 (
|
||||
<LtrTextField
|
||||
autoComplete="off"
|
||||
size="small"
|
||||
label="عرض و طول جغرافیایی (Latitude, Longitude)"
|
||||
placeholder="مثال: 35.7219, 51.3347"
|
||||
fullWidth
|
||||
helperText={
|
||||
error
|
||||
? "فرمت یا محدوده مقادیر معتبر نیست (ابتدا عرض جغرافیایی + , + انتها طول جغرافیایی)"
|
||||
: errors.start_point
|
||||
? errors.start_point.message
|
||||
: "ابتدا عرض جغرافیایی + , + انتها طول جغرافیایی"
|
||||
}
|
||||
error={error || errors.start_point}
|
||||
value={coords}
|
||||
onChange={(e) => {
|
||||
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;
|
||||
@@ -83,6 +83,7 @@ const OperatorCreateForm = ({ open, setOpen, mutate }) => {
|
||||
police_file_date: "",
|
||||
police_serial: "",
|
||||
start_point: "",
|
||||
is_map_point: "1",
|
||||
items_damage: [],
|
||||
};
|
||||
return (
|
||||
|
||||
@@ -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}`;
|
||||
|
||||
Reference in New Issue
Block a user