first commit

This commit is contained in:
2025-06-10 15:28:23 +05:30
commit e22a2dc275
699 changed files with 100382 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
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/V1/ProductUpsert`,
{
method: "POST",
headers: {
Authorization: "Bearer <access_token>",
"Content-Type": "application/json",
token: localStorage.getItem("token") || "",
refresh_token: localStorage.getItem("refreshToken") || "",
},
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) {
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

@@ -0,0 +1,33 @@
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/V1/DeleteEvent`,
{
method: "PATCH",
headers: {
Authorization: "Bearer <access_token>",
"Content-Type": "application/json",
token: localStorage.getItem("token") || "",
refresh_token: localStorage.getItem("refreshToken") || "",
},
body: JSON.stringify(body),
}
);
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

@@ -0,0 +1,33 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteProductApi = async (body: any) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/V1/DeleteProduct`,
{
method: "PATCH",
headers: {
Authorization: "Bearer <access_token>",
"Content-Type": "application/json",
token: localStorage.getItem("token") || "",
refresh_token: localStorage.getItem("refreshToken") || "",
},
body: JSON.stringify(body),
}
);
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

@@ -0,0 +1,35 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getProductApi = async (
productUuid: string,
projectId: string
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/V1/EventsByProduct?productUuid=${productUuid}&projectId=${projectId}`,
{
method: "GET",
headers: {
Authorization: "Bearer <access_token>",
"Content-Type": "application/json",
token: localStorage.getItem("token") || "",
refresh_token: localStorage.getItem("refreshToken") || "",
},
}
);
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

@@ -0,0 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getAllProductsApi = async (projectId: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/V1/ProjectProducts/${projectId}`,
{
method: "GET",
headers: {
Authorization: "Bearer <access_token>",
"Content-Type": "application/json",
token: localStorage.getItem("token") || "",
refresh_token: localStorage.getItem("refreshToken") || "",
},
}
);
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

@@ -0,0 +1,36 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const renameProductApi = async (body: {
productName: string;
productUuid: string;
projectId: string;
}) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/V1/RenameProduct`, {
method: "PATCH",
headers: {
Authorization: "Bearer <access_token>",
"Content-Type": "application/json",
token: localStorage.getItem("token") || "",
refresh_token: localStorage.getItem("refreshToken") || "",
},
body: JSON.stringify(body),
});
if (!response.ok) {
throw new Error("Failed to rename product");
}
const result = await response.json();
console.log('result: ', result);
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

@@ -0,0 +1,40 @@
onmessage = function (e) {
const { materials, positions, sizes } = e.data;
const collisions = [];
const allPairs = [];
for (let i = 0; i < materials.length; i++) {
for (let j = i + 1; j < materials.length; j++) {
const mat1 = materials[i];
const mat2 = materials[j];
const pos1 = positions[mat1.materialId];
const pos2 = positions[mat2.materialId];
if (!pos1 || !pos2) continue;
const size1 = sizes[mat1.materialId] || 0.2;
const size2 = sizes[mat2.materialId] || 0.2;
const distance = Math.sqrt(
Math.pow(pos1.x - pos2.x, 2) +
Math.pow(pos1.y - pos2.y, 2) +
Math.pow(pos1.z - pos2.z, 2)
);
allPairs.push({
materialId1: mat1.materialId,
materialId2: mat2.materialId
});
if (distance < (size1 + size2)) {
collisions.push({
materialId1: mat1.materialId,
materialId2: mat2.materialId,
distance: distance
});
}
}
}
postMessage({ collisions, allPairs });
};