Refactor aisle API services: remove createAisleApi, update deleteAisleApi to include versionId, and modify wall asset APIs for consistency in endpoint naming. Enhance floor and wall store functionality with new setters and methods for managing floors and walls, including decal handling. Introduce FloorInstance and FloorInstances components for rendering floor data, and implement FloorCreator for interactive floor creation. Add reference floor visualization with snapping capabilities. Update wall API services for improved error handling and response management.

This commit is contained in:
2025-06-26 17:47:32 +05:30
parent b4745451d2
commit 1e88006780
28 changed files with 1442 additions and 122 deletions

View File

@@ -10,7 +10,7 @@ export const deleteAisleApi = async (aisleUuid: string, projectId: string, versi
token: localStorage.getItem("token") || "", // Coerce null to empty string
refresh_token: localStorage.getItem("refreshToken") || "",
},
body: JSON.stringify({ aisleUuid, projectId }),
body: JSON.stringify({ aisleUuid, projectId, versionId }),
});
const newAccessToken = response.headers.get("x-access-token");
if (newAccessToken) {

View File

@@ -1,6 +1,6 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const createAisleApi = async (
export const upsertAisleApi = async (
aisleUuid: string,
points: any,
type: Object,

View File

@@ -7,7 +7,7 @@ export const deleteWallItem = async (
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/deleteWallItem`,
`${url_Backend_dwinzo}/api/V1/wallItems/delete`,
{
method: "DELETE",
headers: {

View File

@@ -3,7 +3,7 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
export const getWallItems = async (organization: string, projectId?: string, versionId?: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/V1/walls/${projectId}/${versionId}`,
`${url_Backend_dwinzo}/api/V1/wallItems/${projectId}/${versionId}`,
{
method: "GET",
headers: {

View File

@@ -12,7 +12,7 @@ export const setWallItem = async (
scale: Object
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setWallItems`, {
const response = await fetch(`${url_Backend_dwinzo}/api/V1/wallItems`, {
method: "POST",
headers: {
Authorization: "Bearer <access_token>",

View File

@@ -0,0 +1,39 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteWallApi = async (
projectId: string,
versionId: string,
wallUuid: string
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/V1/deleteWall`, {
method: "PATCH",
headers: {
Authorization: "Bearer <access_token>",
"Content-Type": "application/json",
token: localStorage.getItem("token") || "",
refresh_token: localStorage.getItem("refreshToken") || "",
},
body: JSON.stringify({ projectId, versionId, wallUuid }),
});
const newAccessToken = response.headers.get("x-access-token");
if (newAccessToken) {
localStorage.setItem("token", newAccessToken);
}
if (!response.ok) {
console.error("Failed to delete wall:", response.statusText);
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete wall");
if (error instanceof Error) {
console.log(error.message);
} else {
console.log("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,37 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getWallsApi = async (
projectId: string,
versionId: string,
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/V1/Walls/${projectId}/${versionId}`, {
method: "GET",
headers: {
Authorization: "Bearer <access_token>",
"Content-Type": "application/json",
token: localStorage.getItem("token") || "",
refresh_token: localStorage.getItem("refreshToken") || "",
},
});
const newAccessToken = response.headers.get("x-access-token");
if (newAccessToken) {
localStorage.setItem("token", newAccessToken);
}
if (!response.ok) {
console.error("Failed to get wall:", response.statusText);
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get wall");
if (error instanceof Error) {
console.log(error.message);
} else {
console.log("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,39 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const upsertWallApi = async (
projectId: string,
versionId: string,
wallData: Wall
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/V1/UpsertWall`, {
method: "POST",
headers: {
Authorization: "Bearer <access_token>",
"Content-Type": "application/json",
token: localStorage.getItem("token") || "",
refresh_token: localStorage.getItem("refreshToken") || "",
},
body: JSON.stringify({ projectId, versionId, wallData }),
});
const newAccessToken = response.headers.get("x-access-token");
if (newAccessToken) {
localStorage.setItem("token", newAccessToken);
}
if (!response.ok) {
console.error("Failed to upsert wall:", response.statusText);
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to upsert wall");
if (error instanceof Error) {
console.log(error.message);
} else {
console.log("An unknown error occurred");
}
}
};