{!selectedUser && (
diff --git a/app/src/pages/UserAuth.tsx b/app/src/pages/UserAuth.tsx
index 8b162c6..90b8e2c 100644
--- a/app/src/pages/UserAuth.tsx
+++ b/app/src/pages/UserAuth.tsx
@@ -26,19 +26,23 @@ const UserAuth: React.FC = () => {
e.preventDefault();
const organization = email.split("@")[1].split(".")[0];
+ console.log('email, password, organization: ', email, password, organization);
try {
const res = await signInApi(email, password, organization);
+
if (res.message === "login successfull") {
setError("");
setOrganization(organization);
setUserName(res.name);
+ console.log(' res.userId: ', res.userId);
localStorage.setItem("userId", res.userId);
localStorage.setItem("email", res.email);
localStorage.setItem("userName", res.name);
if (res.isShare) {
setLoadingProgress(1);
- navigate("/Project");
+ // navigate("/Project");
+ navigate("/Dashboard");
}
} else if (res.message === "User Not Found!!! Kindly signup...") {
setError("Account not found");
diff --git a/app/src/services/dashboard/addedProject.ts b/app/src/services/dashboard/addedProject.ts
new file mode 100644
index 0000000..e69de29
diff --git a/app/src/services/dashboard/createProject.ts b/app/src/services/dashboard/createProject.ts
new file mode 100644
index 0000000..8d6fb98
--- /dev/null
+++ b/app/src/services/dashboard/createProject.ts
@@ -0,0 +1,38 @@
+let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
+// let url_Backend_dwinzo = `http://192.168.0.102:5000`;
+// let url_Backend_dwinzo = `http://192.168.0.110:5000`;
+
+export const createProject = async (
+ projectUuid: string,
+ userId: string,
+ thumbnail: string,
+ organization: string
+) => {
+ try {
+ const response = await fetch(`${url_Backend_dwinzo}/api/v1/upsertProject`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ projectUuid,
+ userId,
+ thumbnail,
+ organization,
+ }),
+ });
+
+ if (!response.ok) {
+ throw new Error("Failed to add project");
+ }
+
+ 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");
+ }
+ }
+};
diff --git a/app/src/services/dashboard/deleteProject.ts b/app/src/services/dashboard/deleteProject.ts
new file mode 100644
index 0000000..b5449d9
--- /dev/null
+++ b/app/src/services/dashboard/deleteProject.ts
@@ -0,0 +1,35 @@
+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 deleteProject = async (
+ projectId: string,
+ userId: string,
+ organization: string
+) => {
+ try {
+ const response = await fetch(
+ `${url_Backend_dwinzo}/api/v1//Project/archive/${projectId}`,
+ {
+ method: "PATCH",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({ userId, organization }),
+ }
+ );
+
+ if (!response.ok) {
+ throw new Error("Failed to clearPanel in the zone");
+ }
+
+ 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 {
+ throw new Error("An unknown error occurred");
+ }
+ }
+};
diff --git a/app/src/services/dashboard/getAllProjects.ts b/app/src/services/dashboard/getAllProjects.ts
new file mode 100644
index 0000000..a43aecd
--- /dev/null
+++ b/app/src/services/dashboard/getAllProjects.ts
@@ -0,0 +1,24 @@
+let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
+
+export const getAllProjects = async (userId: string, organization: string) => {
+ try {
+ const response = await fetch(
+ `${url_Backend_dwinzo}/api/v1/Projects/${userId}/${organization}`,
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ );
+
+ 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);
+ }
+};
diff --git a/app/src/services/dashboard/getTrash.ts b/app/src/services/dashboard/getTrash.ts
new file mode 100644
index 0000000..76cd989
--- /dev/null
+++ b/app/src/services/dashboard/getTrash.ts
@@ -0,0 +1,28 @@
+const url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
+// const url_Backend_dwinzo = `http://192.168.0.102:5000`;
+
+export const getTrash = async (organization: string) => {
+ console.log("Organization:", organization);
+
+ try {
+ const response = await fetch(
+ `${url_Backend_dwinzo}/api/v1/Trash/Lists?organization=${organization}`,
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ );
+
+ if (!response.ok) {
+ throw new Error("Failed to fetch trash data");
+ }
+
+ const data = await response.json();
+ return data;
+ } catch (error: any) {
+ console.error("Failed to fetch trash data:", error);
+ throw new Error(error.message || "Unknown error");
+ }
+};
diff --git a/app/src/services/dashboard/projectTutorial.ts b/app/src/services/dashboard/projectTutorial.ts
new file mode 100644
index 0000000..e27f907
--- /dev/null
+++ b/app/src/services/dashboard/projectTutorial.ts
@@ -0,0 +1,27 @@
+let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
+
+export const projectTutorial = async () => {
+ try {
+ const response = await fetch(`${url_Backend_dwinzo}/api/v1/tutorials`, {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ });
+
+ console.log("response: ", response);
+
+ if (!response.ok) {
+ throw new Error("Failed to add project");
+ }
+
+ 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");
+ }
+ }
+};
diff --git a/app/src/services/dashboard/recentlyViewed.ts b/app/src/services/dashboard/recentlyViewed.ts
new file mode 100644
index 0000000..cfefa70
--- /dev/null
+++ b/app/src/services/dashboard/recentlyViewed.ts
@@ -0,0 +1,24 @@
+let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
+
+export const recentlyViewed = async (organization: string, userId: string) => {
+ try {
+ const response = await fetch(
+ `${url_Backend_dwinzo}/api/v1/RecentlyViewed/${userId}/${organization}`,
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ );
+
+ if (!response.ok) {
+ throw new Error("Failed to fetch project");
+ }
+
+ return await response.json();
+ } catch (error: any) {
+ console.error("Failed to get project");
+ throw new Error(error.message);
+ }
+};
diff --git a/app/src/services/dashboard/restoreTrash.ts b/app/src/services/dashboard/restoreTrash.ts
new file mode 100644
index 0000000..3e5adb2
--- /dev/null
+++ b/app/src/services/dashboard/restoreTrash.ts
@@ -0,0 +1,26 @@
+const url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
+// const url_Backend_dwinzo = `http://192.168.0.102:5000`;
+
+export const restoreTrash = async (organization: string, projectId: string) => {
+ try {
+ const response = await fetch(
+ `${url_Backend_dwinzo}/api/v1/restore?organization=${organization}&projectId=${projectId}`,
+ {
+ method: "PATCH",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ );
+
+ if (!response.ok) {
+ throw new Error("Failed to fetch trash data");
+ }
+
+ const data = await response.json();
+ return data;
+ } catch (error: any) {
+ console.error("Failed to fetch trash data:", error);
+ throw new Error(error.message || "Unknown error");
+ }
+};
diff --git a/app/src/services/dashboard/searchProjects.ts b/app/src/services/dashboard/searchProjects.ts
new file mode 100644
index 0000000..2740432
--- /dev/null
+++ b/app/src/services/dashboard/searchProjects.ts
@@ -0,0 +1,35 @@
+let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
+
+export const searchProject = async (
+ organization: string,
+ userId: string,
+ searchName: string
+) => {
+ try {
+ const response = await fetch(
+ `${url_Backend_dwinzo}/api/v1/searchProjects?organization=${organization}&userId=${userId}&searchName=${searchName}`,
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ );
+
+ if (!response.ok) {
+ throw new Error("Failed to Search project");
+ }
+
+ console.log("response: ", response);
+ const result = await response.json();
+ console.log("result: ", result);
+
+ return result;
+ } catch (error) {
+ if (error instanceof Error) {
+ throw new Error(error.message);
+ } else {
+ throw new Error("An unknown error occurred");
+ }
+ }
+};
diff --git a/app/src/services/dashboard/trashSearchProject.ts b/app/src/services/dashboard/trashSearchProject.ts
new file mode 100644
index 0000000..85732b2
--- /dev/null
+++ b/app/src/services/dashboard/trashSearchProject.ts
@@ -0,0 +1,32 @@
+let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
+
+export const trashSearchProject = async (
+ organization: string,
+ userId: string,
+ searchName: string
+) => {
+ try {
+ const response = await fetch(
+ `${url_Backend_dwinzo}/api/v1/searchTrashProjects?organization=${organization}&userId=${userId}&searchName=${searchName}`,
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ );
+
+ if (!response.ok) {
+ throw new Error("Failed to add project");
+ }
+
+ 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");
+ }
+ }
+};
diff --git a/app/src/services/dashboard/updateProject.ts b/app/src/services/dashboard/updateProject.ts
new file mode 100644
index 0000000..8a1682c
--- /dev/null
+++ b/app/src/services/dashboard/updateProject.ts
@@ -0,0 +1,45 @@
+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 updateProject = async (
+ projectId: string,
+ userId: string,
+ organization: string,
+ thumbnail?: string,
+ projectName?: string
+) => {
+ const body: any = {
+ projectId,
+ userId,
+ organization,
+ };
+
+ if (projectName) body.projectName = projectName;
+ if (thumbnail) body.thumbnail = thumbnail;
+
+ try {
+ const response = await fetch(
+ `${url_Backend_dwinzo}/api/v1/Project/modify`,
+ {
+ method: "PATCH",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify(body),
+ }
+ );
+
+ if (!response.ok) {
+ throw new Error("Failed to clearPanel 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");
+ }
+ }
+};
diff --git a/app/src/services/dashboard/viewProject.ts b/app/src/services/dashboard/viewProject.ts
new file mode 100644
index 0000000..d2dff52
--- /dev/null
+++ b/app/src/services/dashboard/viewProject.ts
@@ -0,0 +1,28 @@
+let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
+
+export const viewProject = async (
+ organization: string,
+ projectId: string,
+ userId: string
+) => {
+ try {
+ const response = await fetch(
+ `${url_Backend_dwinzo}/api/v1/Project/view?organization=${organization}&projectId=${projectId}&userId=${userId}`,
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ );
+
+ if (!response.ok) {
+ throw new Error("Failed to fetch");
+ }
+
+ return await response.json();
+ } catch (error: any) {
+ console.error("Failed to get asset image:", error);
+ throw new Error(error.message);
+ }
+};
diff --git a/app/src/services/factoryBuilder/signInSignUp/signUpApi.ts b/app/src/services/factoryBuilder/signInSignUp/signUpApi.ts
index aa9c63b..29939fb 100644
--- a/app/src/services/factoryBuilder/signInSignUp/signUpApi.ts
+++ b/app/src/services/factoryBuilder/signInSignUp/signUpApi.ts
@@ -20,6 +20,7 @@ export const signUpApi = async (
}
const result = await response.json();
+ console.log("result: ", result);
return result;
} catch (error) {
echo.error("Failed to sign-up");
diff --git a/app/src/store/builder/store.ts b/app/src/store/builder/store.ts
index 06c7bfc..527ee4d 100644
--- a/app/src/store/builder/store.ts
+++ b/app/src/store/builder/store.ts
@@ -1,454 +1,497 @@
import * as THREE from "three";
import { create } from "zustand";
import { io } from "socket.io-client";
-import * as CONSTANTS from '../../types/world/worldConstants';
+import * as CONSTANTS from "../../types/world/worldConstants";
export const useSocketStore = create
((set: any, get: any) => ({
- socket: null,
- initializeSocket: (email: string, organization: string) => {
- const existingSocket = get().socket;
- if (existingSocket) {
- return;
- }
+ socket: null,
+ initializeSocket: (email: string, organization: string, userId?: string) => {
+ const existingSocket = get().socket;
+ if (existingSocket) {
+ return;
+ }
- const socket = io(
- `http://${process.env.REACT_APP_SERVER_SOCKET_API_BASE_URL}/Builder`,
- {
- reconnection: true,
- auth: { email, organization },
- }
- );
+ const socket = io(
+ `http://${process.env.REACT_APP_SERVER_SOCKET_API_BASE_URL}/Builder`,
+ {
+ reconnection: true,
+ auth: { email, organization },
+ }
+ );
- const visualizationSocket = io(
- `http://${process.env.REACT_APP_SERVER_SOCKET_API_BASE_URL}/Visualization`,
- {
- reconnection: true,
- auth: { email, organization },
- }
- );
+ const visualizationSocket = io(
+ `http://${process.env.REACT_APP_SERVER_SOCKET_API_BASE_URL}/Visualization`,
+ {
+ reconnection: true,
+ auth: { email, organization },
+ }
+ );
- set({ socket, visualizationSocket });
- },
- disconnectSocket: () => {
- set((state: any) => {
- state.socket?.disconnect();
- state.visualizationSocket?.disconnect();
- return { socket: null };
- });
- },
+ const dashBoardSocket = io(
+ `http://${process.env.REACT_APP_SERVER_SOCKET_API_BASE_URL}/project`,
+ {
+ reconnection: true,
+ auth: { email, organization, userId },
+ }
+ );
+
+ set({ socket, visualizationSocket, dashBoardSocket });
+ },
+ disconnectSocket: () => {
+ set((state: any) => {
+ state.socket?.disconnect();
+ state.visualizationSocket?.disconnect();
+ state.dashBoardSocket?.disconnect();
+ return { socket: null };
+ });
+ },
}));
export const useLoadingProgress = create<{
- loadingProgress: number;
- setLoadingProgress: (x: number) => void;
+ loadingProgress: number;
+ setLoadingProgress: (x: number) => void;
}>((set) => ({
- loadingProgress: 1,
- setLoadingProgress: (x: number) => set({ loadingProgress: x }),
+ loadingProgress: 1,
+ setLoadingProgress: (x: number) => set({ loadingProgress: x }),
}));
export const useOrganization = create((set: any) => ({
- organization: "",
- setOrganization: (x: any) => set(() => ({ organization: x })),
+ organization: "",
+ setOrganization: (x: any) => set(() => ({ organization: x })),
}));
export const useToggleView = create((set: any) => ({
- toggleView: false,
- setToggleView: (x: any) => set(() => ({ toggleView: x })),
+ toggleView: false,
+ setToggleView: (x: any) => set(() => ({ toggleView: x })),
}));
export const useUpdateScene = create((set: any) => ({
- updateScene: false,
- setUpdateScene: (x: any) => set(() => ({ updateScene: x })),
+ updateScene: false,
+ setUpdateScene: (x: any) => set(() => ({ updateScene: x })),
}));
export const useWalls = create((set: any) => ({
- walls: [],
- setWalls: (x: any) => set(() => ({ walls: x })),
+ walls: [],
+ setWalls: (x: any) => set(() => ({ walls: x })),
}));
export const useRoomsState = create((set: any) => ({
- roomsState: [],
- setRoomsState: (x: any) => set(() => ({ roomsState: x })),
+ roomsState: [],
+ setRoomsState: (x: any) => set(() => ({ roomsState: x })),
}));
export const useZones = create((set: any) => ({
- zones: [],
- setZones: (callback: any) =>
- set((state: any) => ({
- zones: typeof callback === "function" ? callback(state.zones) : callback,
- })),
+ zones: [],
+ setZones: (callback: any) =>
+ set((state: any) => ({
+ zones: typeof callback === "function" ? callback(state.zones) : callback,
+ })),
}));
interface ZonePointsState {
- zonePoints: THREE.Vector3[];
- setZonePoints: (points: THREE.Vector3[]) => void;
+ zonePoints: THREE.Vector3[];
+ setZonePoints: (points: THREE.Vector3[]) => void;
}
export const useZonePoints = create((set) => ({
- zonePoints: [],
- setZonePoints: (points) => set({ zonePoints: points }),
+ zonePoints: [],
+ setZonePoints: (points) => set({ zonePoints: points }),
}));
export const useSelectedItem = create((set: any) => ({
- selectedItem: { name: "", id: "", type: undefined, category: '', subCatergory: '' },
- setSelectedItem: (x: any) => set(() => ({ selectedItem: x })),
+ selectedItem: {
+ name: "",
+ id: "",
+ type: undefined,
+ category: "",
+ subCatergory: "",
+ },
+ setSelectedItem: (x: any) => set(() => ({ selectedItem: x })),
}));
export const useNavMesh = create((set: any) => ({
- navMesh: null,
- setNavMesh: (x: any) => set({ navMesh: x }),
+ navMesh: null,
+ setNavMesh: (x: any) => set({ navMesh: x }),
}));
export const useSelectedAssets = create((set: any) => ({
- selectedAssets: [],
- setSelectedAssets: (x: any) => set(() => ({ selectedAssets: x })),
+ selectedAssets: [],
+ setSelectedAssets: (x: any) => set(() => ({ selectedAssets: x })),
}));
export const useLayers = create((set: any) => ({
- Layers: 1,
- setLayers: (x: any) => set(() => ({ Layers: x })),
+ Layers: 1,
+ setLayers: (x: any) => set(() => ({ Layers: x })),
}));
export const useCamPosition = create((set: any) => ({
- camPosition: { x: undefined, y: undefined, z: undefined },
- setCamPosition: (newCamPosition: any) => set({ camPosition: newCamPosition }),
+ camPosition: { x: undefined, y: undefined, z: undefined },
+ setCamPosition: (newCamPosition: any) => set({ camPosition: newCamPosition }),
}));
export const useMenuVisible = create((set: any) => ({
- menuVisible: false,
- setMenuVisible: (x: any) => set(() => ({ menuVisible: x })),
+ menuVisible: false,
+ setMenuVisible: (x: any) => set(() => ({ menuVisible: x })),
}));
export const useDeleteTool = create((set: any) => ({
- deleteTool: false,
- setDeleteTool: (x: any) => set(() => ({ deleteTool: x })),
+ deleteTool: false,
+ setDeleteTool: (x: any) => set(() => ({ deleteTool: x })),
}));
export const useToolMode = create((set: any) => ({
- toolMode: null,
- setToolMode: (x: any) => set(() => ({ toolMode: x })),
+ toolMode: null,
+ setToolMode: (x: any) => set(() => ({ toolMode: x })),
}));
export const useNewLines = create((set: any) => ({
- newLines: [],
- setNewLines: (x: any) => set(() => ({ newLines: x })),
+ newLines: [],
+ setNewLines: (x: any) => set(() => ({ newLines: x })),
}));
export const useDeletedLines = create((set: any) => ({
- deletedLines: [],
- setDeletedLines: (x: any) => set(() => ({ deletedLines: x })),
+ deletedLines: [],
+ setDeletedLines: (x: any) => set(() => ({ deletedLines: x })),
}));
export const useMovePoint = create((set: any) => ({
- movePoint: false,
- setMovePoint: (x: any) => set(() => ({ movePoint: x })),
+ movePoint: false,
+ setMovePoint: (x: any) => set(() => ({ movePoint: x })),
}));
export const useDeletePointOrLine = create((set: any) => ({
- deletePointOrLine: false,
- setDeletePointOrLine: (x: any) => set(() => ({ deletePointOrLine: x })),
+ deletePointOrLine: false,
+ setDeletePointOrLine: (x: any) => set(() => ({ deletePointOrLine: x })),
}));
export const useFloorItems = create((set: any) => ({
- floorItems: null,
- setFloorItems: (callback: any) =>
- set((state: any) => ({
- floorItems:
- typeof callback === "function" ? callback(state.floorItems) : callback,
- })),
+ floorItems: null,
+ setFloorItems: (callback: any) =>
+ set((state: any) => ({
+ floorItems:
+ typeof callback === "function" ? callback(state.floorItems) : callback,
+ })),
}));
export const useWallItems = create((set: any) => ({
- wallItems: [],
- setWallItems: (callback: any) =>
- set((state: any) => ({
- wallItems:
- typeof callback === "function" ? callback(state.wallItems) : callback,
- })),
+ wallItems: [],
+ setWallItems: (callback: any) =>
+ set((state: any) => ({
+ wallItems:
+ typeof callback === "function" ? callback(state.wallItems) : callback,
+ })),
}));
export const useSelectedWallItem = create((set: any) => ({
- selectedWallItem: null,
- setSelectedWallItem: (x: any) => set(() => ({ selectedWallItem: x })),
+ selectedWallItem: null,
+ setSelectedWallItem: (x: any) => set(() => ({ selectedWallItem: x })),
}));
export const useSelectedFloorItem = create((set: any) => ({
- selectedFloorItem: null,
- setSelectedFloorItem: (x: any) => set(() => ({ selectedFloorItem: x })),
+ selectedFloorItem: null,
+ setSelectedFloorItem: (x: any) => set(() => ({ selectedFloorItem: x })),
}));
export const useDeletableFloorItem = create((set: any) => ({
- deletableFloorItem: null,
- setDeletableFloorItem: (x: any) => set(() => ({ deletableFloorItem: x })),
+ deletableFloorItem: null,
+ setDeletableFloorItem: (x: any) => set(() => ({ deletableFloorItem: x })),
}));
export const useSetScale = create((set: any) => ({
- scale: null,
- setScale: (x: any) => set(() => ({ scale: x })),
+ scale: null,
+ setScale: (x: any) => set(() => ({ scale: x })),
}));
export const useRoofVisibility = create((set: any) => ({
- roofVisibility: false,
- setRoofVisibility: (x: any) => set(() => ({ roofVisibility: x })),
+ roofVisibility: false,
+ setRoofVisibility: (x: any) => set(() => ({ roofVisibility: x })),
}));
export const useWallVisibility = create((set: any) => ({
- wallVisibility: false,
- setWallVisibility: (x: any) => set(() => ({ wallVisibility: x })),
+ wallVisibility: false,
+ setWallVisibility: (x: any) => set(() => ({ wallVisibility: x })),
}));
export const useShadows = create((set: any) => ({
- shadows: false,
- setShadows: (x: any) => set(() => ({ shadows: x })),
+ shadows: false,
+ setShadows: (x: any) => set(() => ({ shadows: x })),
}));
export const useSunPosition = create((set: any) => ({
- sunPosition: { x: undefined, y: undefined, z: undefined },
- setSunPosition: (newSuntPosition: any) =>
- set({ sunPosition: newSuntPosition }),
+ sunPosition: { x: undefined, y: undefined, z: undefined },
+ setSunPosition: (newSuntPosition: any) =>
+ set({ sunPosition: newSuntPosition }),
}));
export const useRemoveLayer = create((set: any) => ({
- removeLayer: false,
- setRemoveLayer: (x: any) => set(() => ({ removeLayer: x })),
+ removeLayer: false,
+ setRemoveLayer: (x: any) => set(() => ({ removeLayer: x })),
}));
export const useRemovedLayer = create((set: any) => ({
- removedLayer: null,
- setRemovedLayer: (x: any) => set(() => ({ removedLayer: x })),
+ removedLayer: null,
+ setRemovedLayer: (x: any) => set(() => ({ removedLayer: x })),
}));
export const useActiveLayer = create((set: any) => ({
- activeLayer: 1,
- setActiveLayer: (x: any) => set({ activeLayer: x }),
+ activeLayer: 1,
+ setActiveLayer: (x: any) => set({ activeLayer: x }),
}));
interface RefTextUpdateState {
- refTextupdate: number;
- setRefTextUpdate: (
- callback: (currentValue: number) => number | number
- ) => void;
+ refTextupdate: number;
+ setRefTextUpdate: (
+ callback: (currentValue: number) => number | number
+ ) => void;
}
export const useRefTextUpdate = create((set) => ({
- refTextupdate: -1000,
- setRefTextUpdate: (callback) =>
- set((state) => ({
- refTextupdate:
- typeof callback === "function"
- ? callback(state.refTextupdate)
- : callback,
- })),
+ refTextupdate: -1000,
+ setRefTextUpdate: (callback) =>
+ set((state) => ({
+ refTextupdate:
+ typeof callback === "function"
+ ? callback(state.refTextupdate)
+ : callback,
+ })),
}));
export const useResetCamera = create((set: any) => ({
- resetCamera: false,
- setResetCamera: (x: any) => set({ resetCamera: x }),
+ resetCamera: false,
+ setResetCamera: (x: any) => set({ resetCamera: x }),
}));
export const useAddAction = create((set: any) => ({
- addAction: null,
- setAddAction: (x: any) => set({ addAction: x }),
+ addAction: null,
+ setAddAction: (x: any) => set({ addAction: x }),
}));
export const useActiveTool = create((set: any) => ({
- activeTool: "cursor",
- setActiveTool: (x: any) => set({ activeTool: x }),
+ activeTool: "cursor",
+ setActiveTool: (x: any) => set({ activeTool: x }),
}));
export const useActiveSubTool = create((set: any) => ({
- activeSubTool: "cursor",
- setActiveSubTool: (x: any) => set({ activeSubTool: x }),
+ activeSubTool: "cursor",
+ setActiveSubTool: (x: any) => set({ activeSubTool: x }),
}));
export const use2DUndoRedo = create((set: any) => ({
- is2DUndoRedo: null,
- set2DUndoRedo: (x: any) => set({ is2DUndoRedo: x }),
+ is2DUndoRedo: null,
+ set2DUndoRedo: (x: any) => set({ is2DUndoRedo: x }),
}));
export const useElevation = create((set: any) => ({
- elevation: 45,
- setElevation: (x: any) => set({ elevation: x }),
+ elevation: 45,
+ setElevation: (x: any) => set({ elevation: x }),
}));
export const useAzimuth = create((set: any) => ({
- azimuth: -160,
- setAzimuth: (x: any) => set({ azimuth: x }),
+ azimuth: -160,
+ setAzimuth: (x: any) => set({ azimuth: x }),
}));
export const useRenderDistance = create((set: any) => ({
- renderDistance: 40,
- setRenderDistance: (x: any) => set({ renderDistance: x }),
+ renderDistance: 40,
+ setRenderDistance: (x: any) => set({ renderDistance: x }),
}));
export const useCamMode = create((set: any) => ({
- camMode: "ThirdPerson",
- setCamMode: (x: any) => set({ camMode: x }),
+ camMode: "ThirdPerson",
+ setCamMode: (x: any) => set({ camMode: x }),
}));
export const useUserName = create((set: any) => ({
- userName: "",
- setUserName: (x: any) => set({ userName: x }),
+ userName: "",
+ setUserName: (x: any) => set({ userName: x }),
}));
export const useObjectPosition = create((set: any) => ({
- objectPosition: { x: undefined, y: undefined, z: undefined },
- setObjectPosition: (newObjectPosition: any) =>
- set({ objectPosition: newObjectPosition }),
+ objectPosition: { x: undefined, y: undefined, z: undefined },
+ setObjectPosition: (newObjectPosition: any) =>
+ set({ objectPosition: newObjectPosition }),
}));
export const useObjectRotation = create((set: any) => ({
- objectRotation: { x: undefined, y: undefined, z: undefined },
- setObjectRotation: (newObjectRotation: any) =>
- set({ objectRotation: newObjectRotation }),
+ objectRotation: { x: undefined, y: undefined, z: undefined },
+ setObjectRotation: (newObjectRotation: any) =>
+ set({ objectRotation: newObjectRotation }),
}));
export const useDrieTemp = create((set: any) => ({
- drieTemp: undefined,
- setDrieTemp: (x: any) => set({ drieTemp: x }),
+ drieTemp: undefined,
+ setDrieTemp: (x: any) => set({ drieTemp: x }),
}));
export const useActiveUsers = create((set: any) => ({
- activeUsers: [],
- setActiveUsers: (callback: (prev: any[]) => any[] | any[]) =>
- set((state: { activeUsers: any[] }) => ({
- activeUsers:
- typeof callback === "function" ? callback(state.activeUsers) : callback,
- })),
+ activeUsers: [],
+ setActiveUsers: (callback: (prev: any[]) => any[] | any[]) =>
+ set((state: { activeUsers: any[] }) => ({
+ activeUsers:
+ typeof callback === "function" ? callback(state.activeUsers) : callback,
+ })),
}));
export const useDrieUIValue = create((set: any) => ({
- drieUIValue: { touch: null, temperature: null, humidity: null },
+ drieUIValue: { touch: null, temperature: null, humidity: null },
- setDrieUIValue: (x: any) =>
- set((state: any) => ({ drieUIValue: { ...state.drieUIValue, ...x } })),
+ setDrieUIValue: (x: any) =>
+ set((state: any) => ({ drieUIValue: { ...state.drieUIValue, ...x } })),
- setTouch: (value: any) =>
- set((state: any) => ({
- drieUIValue: { ...state.drieUIValue, touch: value },
- })),
- setTemperature: (value: any) =>
- set((state: any) => ({
- drieUIValue: { ...state.drieUIValue, temperature: value },
- })),
- setHumidity: (value: any) =>
- set((state: any) => ({
- drieUIValue: { ...state.drieUIValue, humidity: value },
- })),
+ setTouch: (value: any) =>
+ set((state: any) => ({
+ drieUIValue: { ...state.drieUIValue, touch: value },
+ })),
+ setTemperature: (value: any) =>
+ set((state: any) => ({
+ drieUIValue: { ...state.drieUIValue, temperature: value },
+ })),
+ setHumidity: (value: any) =>
+ set((state: any) => ({
+ drieUIValue: { ...state.drieUIValue, humidity: value },
+ })),
}));
export const useStartSimulation = create((set: any) => ({
- startSimulation: false,
- setStartSimulation: (x: any) => set({ startSimulation: x }),
+ startSimulation: false,
+ setStartSimulation: (x: any) => set({ startSimulation: x }),
}));
export const useEyeDropMode = create((set: any) => ({
- eyeDropMode: false,
- setEyeDropMode: (x: any) => set({ eyeDropMode: x }),
+ eyeDropMode: false,
+ setEyeDropMode: (x: any) => set({ eyeDropMode: x }),
}));
export const useEditingPoint = create((set: any) => ({
- editingPoint: false,
- setEditingPoint: (x: any) => set({ editingPoint: x }),
+ editingPoint: false,
+ setEditingPoint: (x: any) => set({ editingPoint: x }),
}));
export const usezoneTarget = create((set: any) => ({
- zoneTarget: [],
- setZoneTarget: (x: any) => set({ zoneTarget: x }),
+ zoneTarget: [],
+ setZoneTarget: (x: any) => set({ zoneTarget: x }),
}));
export const usezonePosition = create((set: any) => ({
- zonePosition: [],
- setZonePosition: (x: any) => set({ zonePosition: x }),
+ zonePosition: [],
+ setZonePosition: (x: any) => set({ zonePosition: x }),
}));
interface EditPositionState {
- Edit: boolean;
- setEdit: (value: boolean) => void;
+ Edit: boolean;
+ setEdit: (value: boolean) => void;
}
export const useEditPosition = create((set) => ({
- Edit: false,
- setEdit: (value) => set({ Edit: value }),
+ Edit: false,
+ setEdit: (value) => set({ Edit: value }),
}));
export const useAsset3dWidget = create((set: any) => ({
- widgetSelect: "",
- setWidgetSelect: (x: any) => set({ widgetSelect: x }),
+ widgetSelect: "",
+ setWidgetSelect: (x: any) => set({ widgetSelect: x }),
}));
export const useWidgetSubOption = create((set: any) => ({
- widgetSubOption: "2D",
- setWidgetSubOption: (x: any) => set({ widgetSubOption: x }),
+ widgetSubOption: "2D",
+ setWidgetSubOption: (x: any) => set({ widgetSubOption: x }),
}));
export const useLimitDistance = create((set: any) => ({
- limitDistance: true,
- setLimitDistance: (x: any) => set({ limitDistance: x }),
+ limitDistance: true,
+ setLimitDistance: (x: any) => set({ limitDistance: x }),
+}));
+export const useProjectName = create((set: any) => ({
+ projectName: "Creating Your Project",
+ setProjectName: (x: any) => set({ projectName: x }),
}));
+// // export const useProjectCount = create((set: any) => ({
+// // projectCount: 1, // Initial state for projectCount
+// // // Function to update projectCount
+// // setProjectCount: (x: number) =>
+// // set((state: any) => ({
+// // projectCount: state.projectCount + x,
+// // })),
+// // }));
+// export const useProjectCount = create((set: any) => ({
+// projectCount: Number(localStorage.getItem("projectCount")) || 1, // Load from localStorage or default to 1
+// setProjectCount: (x: number) =>
+// set((state: any) => {
+// const newCount = state.projectCount + x;
+// localStorage.setItem("projectCount", newCount.toString()); // Sync with localStorage
+// return { projectCount: newCount };
+// }),
+// }));
+
export const useTileDistance = create((set: any) => ({
- gridValue: { size: CONSTANTS.gridConfig.size, divisions: CONSTANTS.gridConfig.divisions },
- planeValue: { height: CONSTANTS.planeConfig.height, width: CONSTANTS.planeConfig.width },
+ gridValue: {
+ size: CONSTANTS.gridConfig.size,
+ divisions: CONSTANTS.gridConfig.divisions,
+ },
+ planeValue: {
+ height: CONSTANTS.planeConfig.height,
+ width: CONSTANTS.planeConfig.width,
+ },
- setGridValue: (value: any) =>
- set((state: any) => ({
- gridValue: { ...state.gridValue, ...value },
- })),
+ setGridValue: (value: any) =>
+ set((state: any) => ({
+ gridValue: { ...state.gridValue, ...value },
+ })),
- setPlaneValue: (value: any) =>
- set((state: any) => ({
- planeValue: { ...state.planeValue, ...value },
- })),
+ setPlaneValue: (value: any) =>
+ set((state: any) => ({
+ planeValue: { ...state.planeValue, ...value },
+ })),
}));
export const usePlayAgv = create((set, get) => ({
- PlayAgv: [],
- setPlayAgv: (updateFn: (prev: any[]) => any[]) =>
- set({ PlayAgv: updateFn(get().PlayAgv) }),
+ PlayAgv: [],
+ setPlayAgv: (updateFn: (prev: any[]) => any[]) =>
+ set({ PlayAgv: updateFn(get().PlayAgv) }),
}));
// Define the Asset type
type Asset = {
- id: string;
- name: string;
- position?: [number, number, number]; // Optional: 3D position
- rotation?: { x: number; y: number; z: number }; // Optional: Euler rotation
+ id: string;
+ name: string;
+ position?: [number, number, number]; // Optional: 3D position
+ rotation?: { x: number; y: number; z: number }; // Optional: Euler rotation
};
// Zustand store type
type ZoneAssetState = {
- zoneAssetId: Asset | null;
- setZoneAssetId: (asset: Asset | null) => void;
+ zoneAssetId: Asset | null;
+ setZoneAssetId: (asset: Asset | null) => void;
};
// Zustand store
export const useZoneAssetId = create((set) => ({
- zoneAssetId: null,
- setZoneAssetId: (asset) => set({ zoneAssetId: asset }),
+ zoneAssetId: null,
+ setZoneAssetId: (asset) => set({ zoneAssetId: asset }),
}));
// version visible hidden
interface VersionHistoryState {
- viewVersionHistory: boolean;
- setVersionHistory: (value: boolean) => void;
+ viewVersionHistory: boolean;
+ setVersionHistory: (value: boolean) => void;
}
const useVersionHistoryStore = create((set) => ({
- viewVersionHistory: false,
- setVersionHistory: (value) => set({ viewVersionHistory: value }),
+ viewVersionHistory: false,
+ setVersionHistory: (value) => set({ viewVersionHistory: value }),
}));
export default useVersionHistoryStore;
interface ShortcutStore {
- showShortcuts: boolean;
- setShowShortcuts: (value: boolean) => void;
- toggleShortcuts: () => void;
+ showShortcuts: boolean;
+ setShowShortcuts: (value: boolean) => void;
+ toggleShortcuts: () => void;
}
export const useShortcutStore = create((set) => ({
- showShortcuts: false,
- setShowShortcuts: (value) => set({ showShortcuts: value }),
- toggleShortcuts: () =>
- set((state) => ({ showShortcuts: !state.showShortcuts })),
-}));
\ No newline at end of file
+ showShortcuts: false,
+ setShowShortcuts: (value) => set({ showShortcuts: value }),
+ toggleShortcuts: () =>
+ set((state) => ({ showShortcuts: !state.showShortcuts })),
+}));