Refactor simulation product handling and state management

- Replaced `useComparisonProduct` with `useSimulationState` in multiple components to streamline state management.
- Updated `SyncCam` to use `comparisonScene` instead of `comparisonProduct`.
- Modified `Products` component to utilize `mainScene` and `comparisonScene` for product selection.
- Adjusted various simulation functions to accept `ProductsSchema` instead of `productsSchema`.
- Enhanced `Simulator` component to fetch simulation data using the updated state structure.
- Refined Zustand store to manage `mainScene` and `comparisonScene` states, including their respective setters and clearers.
- Updated type definitions for products to ensure consistency across the application.
- Cleaned up shortcut key handling to reflect changes in state management.
This commit is contained in:
2025-09-08 11:40:27 +05:30
parent c8e9633050
commit 80a672adf0
20 changed files with 637 additions and 640 deletions

View File

@@ -1,4 +1,5 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
interface SimulationData {
key: string;
data?: object | any;
@@ -28,6 +29,7 @@ interface ProjectSimulation {
projectId: string | undefined;
versions: VersionSimulation[];
}
export const saveSimulationData = async (data: any) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/V1/SimulatedUpsert`, {
@@ -59,8 +61,9 @@ export const saveSimulationData = async (data: any) => {
}
}
};
export const updateSimulateData = async (data: any) => {
console.log("data: update", data);
// console.log("data: update", data);
try {
const response = await fetch(`${url_Backend_dwinzo}/api/V1/ValidateSimulated`, {
method: "POST",
@@ -91,18 +94,25 @@ export const updateSimulateData = async (data: any) => {
}
}
};
export const getSimulationData = async (projectId: string, versionId: string, productUuid: string) => {
console.log("called");
export const getSimulationData = async (
projectId: string,
versionId: string,
productUuid: string
) => {
// console.log("called");
try {
const response = await fetch(`${url_Backend_dwinzo}/api/V1/SimulatedDatas/${projectId}/${versionId}?productUuid=${productUuid}`, {
method: "GET",
headers: {
Authorization: "Bearer <access_token>",
"Content-Type": "application/json",
token: localStorage.getItem("token") || "",
refresh_token: localStorage.getItem("refreshToken") || "",
},
});
const response = await fetch(
`${url_Backend_dwinzo}/api/V1/SimulatedDatas/${projectId}/${versionId}?productUuid=${productUuid}`,
{
method: "GET",
headers: {
Authorization: "Bearer <access_token>",
"Content-Type": "application/json",
token: localStorage.getItem("token") || "",
refresh_token: localStorage.getItem("refreshToken") || "",
},
}
);
console.log("response: ", response);