Refactor API service functions for improved error handling and code consistency
- Updated signUpApi, deleteZonesApi, getZonesApi, setZonesApi, and other API functions to enhance error logging with echo.error statements. - Reformatted function parameters for better readability. - Removed unnecessary comments and console logs. - Ensured consistent error messages across all API functions. - Improved code structure for better maintainability.
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import {
|
||||
useDroppedObjectsStore,
|
||||
} from "../../../../store/visualization/useDroppedObjectsStore";
|
||||
import { useDroppedObjectsStore } from "../../../../store/visualization/useDroppedObjectsStore";
|
||||
import useModuleStore from "../../../../store/useModuleStore";
|
||||
import { determinePosition } from "../../functions/determinePosition";
|
||||
import { getActiveProperties } from "../../functions/getActiveProperties";
|
||||
@@ -132,8 +130,9 @@ const DroppedObjects: React.FC = () => {
|
||||
visualizationSocket.emit("v2:viz-float:delete", deleteFloatingWidget);
|
||||
}
|
||||
deleteObject(zoneName, id);
|
||||
|
||||
} catch (error) {}
|
||||
} catch (error) {
|
||||
echo.error("Failed to delete widget");
|
||||
}
|
||||
}
|
||||
|
||||
const handlePointerDown = (event: React.PointerEvent, index: number) => {
|
||||
@@ -308,6 +307,7 @@ const DroppedObjects: React.FC = () => {
|
||||
updateObjectPosition(zoneName, draggingIndex.index, boundedPosition);
|
||||
}
|
||||
} catch (error) {
|
||||
echo.error("Failed to add widget");
|
||||
console.log(error);
|
||||
} finally {
|
||||
setDraggingIndex(null);
|
||||
@@ -380,7 +380,6 @@ const DroppedObjects: React.FC = () => {
|
||||
setCurrentPosition(newPosition);
|
||||
// Update position immediately without animation frame
|
||||
updateObjectPosition(zoneName, draggingIndex.index, newPosition);
|
||||
|
||||
};
|
||||
|
||||
const handlePointerUp = async (event: React.PointerEvent<HTMLDivElement>) => {
|
||||
@@ -446,6 +445,7 @@ const DroppedObjects: React.FC = () => {
|
||||
|
||||
updateObjectPosition(zoneName, draggingIndex.index, boundedPosition);
|
||||
} catch (error) {
|
||||
echo.error("Failed to add widget");
|
||||
console.log(error);
|
||||
} finally {
|
||||
// Clean up regardless of success or failure
|
||||
|
||||
Reference in New Issue
Block a user