diff --git a/src/components/infrastructure/tollHouse/Form/Edit/EditController.jsx b/src/components/infrastructure/tollHouse/Form/Edit/EditController.jsx index 58b108b..eb30008 100644 --- a/src/components/infrastructure/tollHouse/Form/Edit/EditController.jsx +++ b/src/components/infrastructure/tollHouse/Form/Edit/EditController.jsx @@ -42,12 +42,12 @@ const EditController = ({ rowId, mutate, setOpenEditDialog }) => { machines_light: tollHouseItemDetails?.machines_light || "", machines_sheavy: tollHouseItemDetails?.machines_sheavy || "", machines_heavy: tollHouseItemDetails?.machines_heavy || "", - overview_files_1: tollHouseItemDetails?.files[0]?.path || null, - overview_files_2: tollHouseItemDetails?.files[1]?.path || null, - overview_files_3: tollHouseItemDetails?.files[2]?.path || null, - overview_files_4: tollHouseItemDetails?.files[3]?.path || null, - overview_files_5: tollHouseItemDetails?.files[4]?.path || null, - area: tollHouseItemDetails?.area?.coordinates.map(([lat, lon]) => ({ lat, lon })) || [ + overview_files_1: tollHouseItemDetails?.files?.[0]?.path || null, + overview_files_2: tollHouseItemDetails?.files?.[1]?.path || null, + overview_files_3: tollHouseItemDetails?.files?.[2]?.path || null, + overview_files_4: tollHouseItemDetails?.files?.[3]?.path || null, + overview_files_5: tollHouseItemDetails?.files?.[4]?.path || null, + area: tollHouseItemDetails?.area?.coordinates?.map(([lon, lat]) => ({ lat, lon }))?.slice(0, -1) || [ { lat: "", lon: "" }, { lat: "", lon: "" }, { lat: "", lon: "" }, @@ -87,10 +87,13 @@ const EditController = ({ rowId, mutate, setOpenEditDialog }) => { formData.append("lng", result.start_point.lng); formData.append("area[type]", "polygon"); result.area.map((point, pointIndex) => { - formData.append(`area[coordinates][${pointIndex}][0]`, point.lat); - formData.append(`area[coordinates][${pointIndex}][1]`, point.lon); + formData.append(`area[coordinates][${pointIndex}][0]`, point.lon); + formData.append(`area[coordinates][${pointIndex}][1]`, point.lat); }); + const repeat_first = result.area.length; + formData.append(`area[coordinates][${repeat_first}][0]`, result.area[0].lon); + formData.append(`area[coordinates][${repeat_first}][1]`, result.area[0].lat); await requestServer(`${UPDATE_TOLL_HOUSE_ITEM}/${rowId}`, "post", { data: formData, notificationSuccess: true,