route edit fixed with drag and drop tool
This commit is contained in:
@ -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) => {
|
||||
|
Reference in New Issue
Block a user