add main changes of edit control

This commit is contained in:
2025-12-07 15:52:07 +03:30
parent 4e6a85124a
commit c37a1010fd

View File

@@ -42,17 +42,20 @@ 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 })) || [
{ lat: "", lon: "" },
{ lat: "", lon: "" },
{ 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: "" },
{ lat: "", lon: "" },
],
};
const HandleSubmit = async (result) => {
const fields = [
@@ -87,10 +90,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,