route edit fixed with drag and drop tool

This commit is contained in:
2025-04-21 15:34:11 +03:00
parent 9e34a71e14
commit 463c593a0e
5 changed files with 123 additions and 70 deletions

View File

@ -17,6 +17,7 @@ import {
stationFields,
vehicleFields,
} from "./types";
import { useEffect } from "react";
export const RouteEdit = () => {
const {
@ -24,10 +25,23 @@ export const RouteEdit = () => {
register,
control,
formState: { errors },
refineCore: { queryResult },
setValue,
watch,
} = useForm({});
const { id: routeId } = useParams<{ id: string }>();
useEffect(() => {
if (queryResult?.data?.data && Array.isArray(queryResult.data.data.path)) {
const formattedPath = queryResult.data.data.path
.map((coords) => coords.join(" "))
.join("\n");
setValue("path", formattedPath);
}
}, [queryResult?.data?.data, setValue]);
const { autocompleteProps: carrierAutocompleteProps } = useAutocomplete({
resource: "carrier",
onSearch: (value) => [
@ -134,7 +148,6 @@ export const RouteEdit = () => {
{...register("path", {
required: "Это поле является обязательным",
setValueAs: (value: string) => {
// Преобразование строки в массив координат
try {
const lines = value.trim().split("\n");
return lines.map((line) => {