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:
Nalvazhuthi
2025-05-08 15:19:21 +05:30
parent 1ce08821ff
commit 307d2eabee
105 changed files with 3758 additions and 3032 deletions

View File

@@ -1,23 +1,26 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
export const getAssetImages = async (cursor?: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v3/AssetDatas?limit=10${cursor ? `&cursor=${cursor}` : ""}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v3/AssetDatas?limit=10${
cursor ? `&cursor=${cursor}` : ""
}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to fetch assets");
}
return await response.json();
} catch (error: any) {
throw new Error(error.message);
if (!response.ok) {
throw new Error("Failed to fetch assets");
}
return await response.json();
} catch (error: any) {
echo.error("Failed to get asset image");
throw new Error(error.message);
}
};

View File

@@ -1,25 +1,29 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
export const getAssetModel = async (modelId: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/AssetFile/${modelId}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/AssetFile/${modelId}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to fetch model");
}
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");
}
if (!response.ok) {
throw new Error("Failed to fetch model");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get asset model");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,7 +1,8 @@
let BackEnd_url = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
export const getCategoryAsset = async (categoryName: any) => {
try {
const response = await fetch(`${BackEnd_url}/api/v2/getCategoryAssets/${categoryName}`,
const response = await fetch(
`${BackEnd_url}/api/v2/getCategoryAssets/${categoryName}`,
{
method: "GET",
headers: {
@@ -13,6 +14,7 @@ export const getCategoryAsset = async (categoryName: any) => {
const result = await response.json();
return result;
} catch (error: any) {
echo.error("Failed to get category asset");
throw new Error(error.message);
}
};

View File

@@ -1,26 +1,34 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteFloorItem = async (organization: string, modelUuid: string, modelName: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deletefloorItem`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, modelUuid, modelName }),
});
export const deleteFloorItem = async (
organization: string,
modelUuid: string,
modelName: string
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/deletefloorItem`,
{
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, modelUuid, modelName }),
}
);
if (!response.ok) {
throw new Error("Failed to delete Floor Item");
}
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");
}
if (!response.ok) {
throw new Error("Failed to delete Floor Item");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete floor item");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,27 +1,30 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getFloorAssets = async (organization: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/floorAssets/${organization}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/floorAssets/${organization}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to get assets");
}
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");
}
if (!response.ok) {
throw new Error("Failed to get assets");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get floor asset");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,36 +1,46 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const setFloorItemApi = async (
organization: string,
modelUuid?: string,
modelName?: string,
modelfileID?: string,
position?: Object,
rotation?: Object,
isLocked?: boolean,
isVisible?: boolean,
organization: string,
modelUuid?: string,
modelName?: string,
modelfileID?: string,
position?: Object,
rotation?: Object,
isLocked?: boolean,
isVisible?: boolean
) => {
try {
const body: any = { organization, modelUuid, modelName, position, rotation, modelfileID, isLocked, isVisible };
try {
const body: any = {
organization,
modelUuid,
modelName,
position,
rotation,
modelfileID,
isLocked,
isVisible,
};
const response = await fetch(`${url_Backend_dwinzo}/api/v2/setasset`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
const response = await fetch(`${url_Backend_dwinzo}/api/v2/setasset`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
if (!response.ok) {
throw new Error("Failed to set or update Floor Item");
}
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");
}
if (!response.ok) {
throw new Error("Failed to set or update Floor Item");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to set floor items");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,26 +1,34 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteWallItem = async (organization: string, modelUuid: string, modelName: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deleteWallItem`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, modelUuid, modelName }),
});
export const deleteWallItem = async (
organization: string,
modelUuid: string,
modelName: string
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/deleteWallItem`,
{
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, modelUuid, modelName }),
}
);
if (!response.ok) {
throw new Error("Failed to delete Wall Item");
}
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");
}
if (!response.ok) {
throw new Error("Failed to delete Wall Item");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete wall items");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,25 +1,29 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getWallItems = async (organization: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/findWallItems/${organization}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/findWallItems/${organization}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to get Wall Items");
}
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");
}
if (!response.ok) {
throw new Error("Failed to get Wall Items");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get wall items");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,36 +1,47 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const setWallItem = async (
organization: string,
modelUuid: string,
modelName: string,
type: string,
csgposition: Object,
csgscale: Object,
position: Object,
quaternion: Object,
scale: Object
organization: string,
modelUuid: string,
modelName: string,
type: string,
csgposition: Object,
csgscale: Object,
position: Object,
quaternion: Object,
scale: Object
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setWallItems`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, modelUuid, modelName, position, type, csgposition, csgscale, quaternion, scale }),
});
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setWallItems`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
organization,
modelUuid,
modelName,
position,
type,
csgposition,
csgscale,
quaternion,
scale,
}),
});
if (!response.ok) {
throw new Error("Failed to set or update Wall Item");
}
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");
}
if (!response.ok) {
throw new Error("Failed to set or update Wall Item");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to set wall items");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,16 +1,19 @@
import { setCamera } from './setCameraApi';
import * as THREE from 'three';
import { setCamera } from "./setCameraApi";
import * as THREE from "three";
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getCamera = async (organization: string, userId: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/getCamera/${organization}/${userId}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/getCamera/${organization}/${userId}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to get Camera position and target");
@@ -23,10 +26,11 @@ export const getCamera = async (organization: string, userId: string) => {
return result;
}
} catch (error) {
echo.error("Failed to get camera");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};
};

View File

@@ -1,26 +1,39 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const setCamera = async (organization: string, userId: string, position: Object, target: Object, rotation: Object) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setCamera`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, userId, position, target, rotation }),
});
export const setCamera = async (
organization: string,
userId: string,
position: Object,
target: Object,
rotation: Object
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setCamera`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
organization,
userId,
position,
target,
rotation,
}),
});
if (!response.ok) {
throw new Error("Failed to set Camera Position and Target");
}
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");
}
if (!response.ok) {
throw new Error("Failed to set Camera Position and Target");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to set camera");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,32 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export default async function getActiveUsersData(organization: string) {
const apiUrl = `${url_Backend_dwinzo}/api/v1/activeCameras/${organization}`;
const apiUrl = `${url_Backend_dwinzo}/api/v1/activeCameras/${organization}`;
try {
const response = await fetch(apiUrl, {
method: "GET",
headers: {
"Content-Type": "application/json"
}
});
try {
const response = await fetch(apiUrl, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
if (!response.ok) {
throw new Error(`Error: ${response.status} - ${response.statusText}`);
}
if (!response.ok) {
throw new Error("Failed to get active cameras ");
}
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");
}
if (!response.ok) {
throw new Error(`Error: ${response.status} - ${response.statusText}`);
}
};
if (!response.ok) {
throw new Error("Failed to get active cameras ");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get active users");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
}

View File

@@ -1,32 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export default async function fetchShareUsers(organization: string) {
const apiUrl = `${url_Backend_dwinzo}/api/v1/findshareUsers?organization=${organization}`;
const apiUrl = `${url_Backend_dwinzo}/api/v1/findshareUsers?organization=${organization}`;
try {
const response = await fetch(apiUrl, {
method: "GET",
headers: {
"Content-Type": "application/json"
}
});
try {
const response = await fetch(apiUrl, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
if (!response.ok) {
throw new Error(`Error: ${response.status} - ${response.statusText}`);
}
if (!response.ok) {
throw new Error("Failed to get users ");
}
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");
}
if (!response.ok) {
throw new Error(`Error: ${response.status} - ${response.statusText}`);
}
};
if (!response.ok) {
throw new Error("Failed to get users ");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get user API");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
}

View File

@@ -1,26 +1,31 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export default async function giveCollabAccess(email: string, isShare: boolean, organization: string) {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/shareUser`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ email, isShare, organization }),
});
export default async function giveCollabAccess(
email: string,
isShare: boolean,
organization: string
) {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/shareUser`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ email, isShare, organization }),
});
if (!response.ok) {
throw new Error("Failed to set Camera Position and Target");
}
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");
}
if (!response.ok) {
throw new Error("Failed to set Camera Position and Target");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to give collab access");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
}

View File

@@ -34,6 +34,7 @@ export const findEnvironment = async (organization: string, userId: string) => {
return result;
}
} catch (error) {
echo.error("Failed to find env");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -36,6 +36,7 @@ export const setEnvironment = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to set env");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -1,26 +1,27 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteLayer = async (organization: string, layer: number) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deleteLayer`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, layer }),
});
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deleteLayer`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, layer }),
});
if (!response.ok) {
throw new Error("Failed to delete line");
}
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");
}
if (!response.ok) {
throw new Error("Failed to delete line");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete line");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,26 +1,27 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteLineApi = async (organization: string, line: Object) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deleteLine`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, line }),
});
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deleteLine`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, line }),
});
if (!response.ok) {
throw new Error("Failed to delete line");
}
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");
}
if (!response.ok) {
throw new Error("Failed to delete line");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete line");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,26 +1,27 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deletePointApi = async (organization: string, uuid: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deletePoint`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, uuid }),
});
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deletePoint`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, uuid }),
});
if (!response.ok) {
throw new Error("Failed to delete point");
}
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");
}
if (!response.ok) {
throw new Error("Failed to delete point");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete point");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,25 +1,29 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getLines = async (organization: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/findLines/${organization}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/findLines/${organization}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to get Lines");
}
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");
}
if (!response.ok) {
throw new Error("Failed to get Lines");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get Lines");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,26 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const setLine = async (organization: string, layer: number, line: Object, type: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setLine`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, layer, line, type }),
});
export const setLine = async (
organization: string,
layer: number,
line: Object,
type: string
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setLine`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, layer, line, type }),
});
if (!response.ok) {
throw new Error("Failed to set line");
}
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");
}
if (!response.ok) {
throw new Error("Failed to set line");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to set line");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,26 +1,31 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const updatePoint = async (organization: string, position: Object, uuid: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/updatePoint`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, position, uuid }),
});
export const updatePoint = async (
organization: string,
position: Object,
uuid: string
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/updatePoint`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, position, uuid }),
});
if (!response.ok) {
throw new Error("Failed to update point");
}
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");
}
if (!response.ok) {
throw new Error("Failed to update point");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to update point");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,22 +1,27 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const signInApi = async (email: string, password: Object, organization: Object) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/login`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ email, password, organization }),
});
export const signInApi = async (
email: string,
password: Object,
organization: Object
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/login`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ email, password, organization }),
});
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
return { error: error.message };
} else {
return { error: "An unknown error occurred" };
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to sign-in");
if (error instanceof Error) {
return { error: error.message };
} else {
return { error: "An unknown error occurred" };
}
};
}
};

View File

@@ -1,26 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const signUpApi = async (userName: string, email: string, password: Object, organization: Object) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/signup`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ userName, email, password, organization }),
});
export const signUpApi = async (
userName: string,
email: string,
password: Object,
organization: Object
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/signup`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ userName, email, password, organization }),
});
if (!response.ok) {
throw new Error("Failed to signUpApi");
}
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");
}
if (!response.ok) {
throw new Error("Failed to signUpApi");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to sign-up");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,27 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteZonesApi = async (userId: string, organization: string, zoneId: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setLine`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ userId, organization, zoneId }),
});
export const deleteZonesApi = async (
userId: string,
organization: string,
zoneId: string
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setLine`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ userId, organization, zoneId }),
});
if (!response.ok) {
throw new Error("Failed to delete zone");
}
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");
}
if (!response.ok) {
throw new Error("Failed to delete zone");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete zone");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -2,25 +2,29 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
// let url_Backend_dwinzo = `http://192.168.0.102:5000`;
export const getZonesApi = async (organization: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/findZones/${organization}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/findZones/${organization}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
// if (!response.ok) {
// throw new Error("Failed to get Zones");
// }
// if (!response.ok) {
// throw new Error("Failed to get Zones");
// }
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");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get zone data");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
};
}
};

View File

@@ -1,26 +1,31 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const setZonesApi = async (userId: string, organization: string, zoneData: any) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setLine`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ userId, organization, zoneData }),
});
export const setZonesApi = async (
userId: string,
organization: string,
zoneData: any
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setLine`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ userId, organization, zoneData }),
});
if (!response.ok) {
throw new Error("Failed to set zone");
}
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");
}
if (!response.ok) {
throw new Error("Failed to set zone");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to zone data");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -16,6 +16,7 @@ export const getAssetDetails = async (filename: string) => {
const result = await response.json();
return result;
} catch (error: any) {
echo.error("Failed to fetch assetg details");
// console.error("Error fetching category:", error.message);
throw new Error(error.message);
}

View File

@@ -10,6 +10,7 @@ export const fetchAssets = async () => {
// console.log('last10Assets: ', last10Assets);
return result;
} catch (error) {
echo.error("Failed to fetch assets");
console.log("error: ", error);
// throw new Error(error.message);
}

View File

@@ -19,6 +19,7 @@ export const getSortedAssets = async (category: any, orders: any) => {
return result; // Return the result to be used later
} catch (error: any) {
echo.error("Failed to fetching category");
console.error("Error fetching category:", error.message);
throw new Error(error.message);
}

View File

@@ -1,26 +1,30 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const upsertProductOrEventApi = async (body: any) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/UpsertProductOrEvent`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/UpsertProductOrEvent`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
}
);
if (!response.ok) {
throw new Error("Failed to add product or event");
}
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");
}
if (!response.ok) {
throw new Error("Failed to add product or event");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to upsert product Or eventApi");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,26 +1,30 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteEventDataApi = async (body: any) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/EventDataDelete`, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/EventDataDelete`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
}
);
if (!response.ok) {
throw new Error("Failed to delete event data");
}
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");
}
if (!response.ok) {
throw new Error("Failed to delete event data");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete event data API");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,25 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteProductApi = async (productId: string, organization: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/productDataDelete?productId=${productId}&organization=${organization}`, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
});
export const deleteProductApi = async (
productId: string,
organization: string
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/productDataDelete?productId=${productId}&organization=${organization}`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to delete product data");
}
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");
}
if (!response.ok) {
throw new Error("Failed to delete product data");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete product API");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,25 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getProductApi = async (productId: string, organization: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/productDatas?productId=${productId}&organization=${organization}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
export const getProductApi = async (
productId: string,
organization: string
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/productDatas?productId=${productId}&organization=${organization}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to fetch product data");
}
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");
}
if (!response.ok) {
throw new Error("Failed to fetch product data");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get product asset");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,25 +1,29 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getAllProductsApi = async ( organization: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/AllProducts/${organization}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
export const getAllProductsApi = async (organization: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/AllProducts/${organization}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to fetch all products data");
}
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");
}
if (!response.ok) {
throw new Error("Failed to fetch all products data");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get all product API");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,26 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const renameProductApi = async (body: { productName: string, productId: string, organization: string }) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/productRename`, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
export const renameProductApi = async (body: {
productName: string;
productId: string;
organization: string;
}) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/productRename`, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
if (!response.ok) {
throw new Error("Failed to rename product");
}
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");
}
if (!response.ok) {
throw new Error("Failed to rename product");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to rename product Api");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -6,16 +6,13 @@ export const adding3dWidgets = async (
widget: {}
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/3dwidget/save`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, zoneId, widget }),
}
);
const response = await fetch(`${url_Backend_dwinzo}/api/v2/3dwidget/save`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, zoneId, widget }),
});
if (!response.ok) {
throw new Error("Failed to add 3dwidget in the zone");
@@ -24,6 +21,7 @@ export const adding3dWidgets = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to add 3d widget");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -6,9 +6,6 @@ export const addingFloatingWidgets = async (
organization: string,
widget: {}
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/floatwidget/save`,
@@ -28,6 +25,7 @@ export const addingFloatingWidgets = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to add floating");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -21,6 +21,7 @@ export const addingWidgets = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to add widget");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -21,6 +21,7 @@ export const clearPanel = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to clean pannel");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -6,10 +6,6 @@ export const delete3dWidgetApi = async (
organization: string,
id: string
) => {
console.log("zoneId: ", zoneId);
console.log("organization: ", organization);
console.log("id: ", id);
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/widget3D/delete`,
@@ -29,6 +25,7 @@ export const delete3dWidgetApi = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete 3d widget");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -5,8 +5,6 @@ export const deleteFloatingWidgetApi = async (
floatWidgetID: string,
organization: string
) => {
console.log('organization: ', organization);
console.log('floatWidgetID: ', floatWidgetID);
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/floatwidget/delete`,
@@ -26,6 +24,7 @@ export const deleteFloatingWidgetApi = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete floating widget");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -6,9 +6,6 @@ export const deletePanelApi = async (
panelName: string,
organization: string
) => {
console.log('panelName: ', panelName);
console.log('organization: ', organization);
console.log('zoneId: ', zoneId);
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/panel/delete`, {
method: "PATCH",
@@ -25,6 +22,7 @@ export const deletePanelApi = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete pannel");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -23,6 +23,7 @@ export const deleteTemplateApi = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete widget");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -4,18 +4,15 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
export const deleteWidgetApi = async (
widgetID: string,
organization: string,
zoneId:string
zoneId: string
) => {
console.log('zoneId: ', zoneId);
console.log('organization: ', organization);
console.log('widgetID: ', widgetID);
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/delete/widget`, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, widgetID,zoneId }),
body: JSON.stringify({ organization, widgetID, zoneId }),
});
if (!response.ok) {
@@ -24,6 +21,7 @@ export const deleteWidgetApi = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete widget");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -21,6 +21,7 @@ export const duplicateWidgetApi = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to dublicate widget");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -6,13 +6,13 @@ export const get3dWidgetZoneData = async (
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/3dwidgetData/${ZoneId}/${organization}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
`${url_Backend_dwinzo}/api/v2/3dwidgetData/${ZoneId}/${organization}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to fetch Zone3dWidgetData");
@@ -20,6 +20,7 @@ export const get3dWidgetZoneData = async (
return await response.json();
} catch (error: any) {
echo.error("Failed to fetch 3d data");
throw new Error(error.message);
}
};

View File

@@ -21,6 +21,7 @@ export const getFloatingZoneData = async (
return await response.json();
} catch (error: any) {
echo.error("Failed to fetch floating data");
throw new Error(error.message);
}
};

View File

@@ -22,6 +22,7 @@ export const getSelect2dZoneData = async (
return await response.json();
} catch (error: any) {
echo.error("Failed to fetch 2d widget data");
throw new Error(error.message);
}
};

View File

@@ -18,6 +18,7 @@ export const getTemplateData = async (organization?: string) => {
return await response.json();
} catch (error: any) {
echo.error("Failed to template data");
throw new Error(error.message);
}
};

View File

@@ -18,6 +18,7 @@ export const getZone2dData = async (organization?: string) => {
return await response.json();
} catch (error: any) {
echo.error("Failed to fetch 2d zone data");
throw new Error(error.message);
}
};

View File

@@ -2,7 +2,6 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
// let url_Backend_dwinzo = `http://192.168.0.102:5000`;
export const getZoneData = async (zoneId: string, organization: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/A_zone/${zoneId}/${organization}`,
@@ -20,6 +19,7 @@ export const getZoneData = async (zoneId: string, organization: string) => {
return await response.json();
} catch (error: any) {
echo.error("Failed to fetch zone data");
throw new Error(error.message);
}
};

View File

@@ -24,6 +24,7 @@ export const loadTempleteApi = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to load template");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -6,13 +6,16 @@ export const lockPanel = async (
lockedPanel: any
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/zones/lockedPanels`, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, zoneId, lockedPanel }),
});
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/zones/lockedPanels`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, zoneId, lockedPanel }),
}
);
if (!response.ok) {
throw new Error("Failed to Lock Panel in the zone");
@@ -21,10 +24,11 @@ export const lockPanel = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to fetch locked panel data");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};
};

View File

@@ -23,6 +23,7 @@ export const panelData = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to fetch panel data");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -1,7 +1,6 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
// let url_Backend_dwinzo = `http://192.168.0.102:5000`;
export const saveTemplateApi = async (organization: string, template: {}) => {
console.log('template: ', template);
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/template/save`, {
method: "POST",
@@ -19,6 +18,7 @@ export const saveTemplateApi = async (organization: string, template: {}) => {
return result;
} catch (error) {
echo.error("Failed to save template");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -1,77 +1,81 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
// let url_Backend_dwinzo = `http://192.168.0.102:5000`;
export const update3dWidget = async (
zoneId: string,
organization: string,
id: string,
position?: [number, number, number]
zoneId: string,
organization: string,
id: string,
position?: [number, number, number]
) => {
console.log("organization: ", organization);
console.log("zoneId: ", zoneId);
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/modifyPR/widget3D`, {
method: "PATCH",
headers: { "Content-Type": "application/json", },
body: JSON.stringify({
organization,
zoneId,
id,
position,
}),
}
);
console.log("organization: ", organization);
console.log("zoneId: ", zoneId);
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/modifyPR/widget3D`,
{
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
organization,
zoneId,
id,
position,
}),
}
);
if (!response.ok) {
throw new Error("Failed to add 3dwidget in the zone");
}
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");
}
if (!response.ok) {
echo.error("Failed to update 3d widget");
throw new Error("Failed to add 3dwidget in the zone");
}
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");
}
}
};
export const update3dWidgetRotation = async (
zoneId: string,
organization: string,
id: string,
rotation?: [number, number, number]
zoneId: string,
organization: string,
id: string,
rotation?: [number, number, number]
) => {
console.log("organization: ", organization);
console.log("zoneId: ", zoneId);
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/modifyPR/widget3D`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
organization,
zoneId,
id,
rotation,
}),
}
);
console.log("organization: ", organization);
console.log("zoneId: ", zoneId);
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/modifyPR/widget3D`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
organization,
zoneId,
id,
rotation,
}),
}
);
if (!response.ok) {
throw new Error("Failed to add 3dwidget in the zone");
}
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");
}
if (!response.ok) {
throw new Error("Failed to add 3dwidget in the zone");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to rotate 3d widget");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,9 +1,7 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
// let url_Backend_dwinzo = `http://192.168.0.102:5000`;
export const zoneCameraUpdate = async (
zonesdata:{},organization:string
) => {
export const zoneCameraUpdate = async (zonesdata: {}, organization: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/zone/save`, {
method: "POST",
@@ -20,10 +18,11 @@ export const zoneCameraUpdate = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to update zone camera");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};
};