2025-03-31 14:09:09 +00:00
|
|
|
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
|
|
|
// let url_Backend_dwinzo = `http://192.168.0.102:5000`;
|
2025-03-26 13:00:33 +00:00
|
|
|
type Side = "top" | "bottom" | "left" | "right";
|
|
|
|
|
2025-03-27 12:34:16 +00:00
|
|
|
export const panelData = async (
|
|
|
|
organization: string,
|
2025-03-28 13:43:20 +00:00
|
|
|
zoneId: string,
|
2025-03-27 12:34:16 +00:00
|
|
|
panelOrder: Side[]
|
|
|
|
) => {
|
|
|
|
try {
|
2025-03-28 13:43:20 +00:00
|
|
|
const response = await fetch(`${url_Backend_dwinzo}/api/v2/panel/save`, {
|
2025-03-27 12:34:16 +00:00
|
|
|
method: "POST",
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
},
|
2025-03-28 13:43:20 +00:00
|
|
|
body: JSON.stringify({ organization, zoneId, panelOrder }),
|
2025-03-27 12:34:16 +00:00
|
|
|
});
|
2025-03-26 13:00:33 +00:00
|
|
|
|
2025-03-27 12:34:16 +00:00
|
|
|
if (!response.ok) {
|
|
|
|
throw new Error("Failed to add panelOrder for Zone");
|
|
|
|
}
|
2025-03-26 13:00:33 +00:00
|
|
|
|
2025-03-27 12:34:16 +00:00
|
|
|
const result = await response.json();
|
|
|
|
return result;
|
|
|
|
} catch (error) {
|
|
|
|
if (error instanceof Error) {
|
|
|
|
throw new Error(error.message);
|
|
|
|
} else {
|
|
|
|
throw new Error("An unknown error occurred");
|
2025-03-26 13:00:33 +00:00
|
|
|
}
|
2025-03-27 12:34:16 +00:00
|
|
|
}
|
|
|
|
};
|