Refactor camera zone coordinate saving to use single query parameter per zone in CameraMap.jsx

This commit is contained in:
Sergey Krashevich 2023-06-26 18:57:12 +03:00
parent 56b8e4a0e0
commit 0af3d875db
No known key found for this signature in database
GPG Key ID: 625171324E7D3856

View File

@ -202,7 +202,7 @@ ${Object.keys(zonePoints)
const handleSaveZones = useCallback(async () => {
try {
const queryParameters = Object.keys(zonePoints)
.map((zoneName, index) => `cameras.${camera}.zones.${zoneName}.coordinates.${index}=${polylinePointsToPolyline(zonePoints[zoneName])}`)
.map((zoneName) => `cameras.${camera}.zones.${zoneName}.coordinates=${polylinePointsToPolyline(zonePoints[zoneName])}`)
.join('&');
const endpoint = `config/set?${queryParameters}`;
const response = await axios.put(endpoint);