socket and api integerated successfully
This commit is contained in:
@@ -46,7 +46,7 @@ const SelectedAisleProperties: React.FC = () => {
|
||||
const updateBackend = (updatedAisle: Aisle) => {
|
||||
if (updatedAisle && projectId) {
|
||||
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
|
||||
// API
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ const SelectedDecalProperties = () => {
|
||||
const updateBackend = (updatedData: Wall | Floor) => {
|
||||
if ('wallUuid' in updatedData) {
|
||||
if (projectId && updatedData) {
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
// API
|
||||
|
||||
upsertWallApi(projectId, selectedVersion?.versionId || '', updatedData);
|
||||
@@ -45,7 +45,7 @@ const SelectedDecalProperties = () => {
|
||||
}
|
||||
} else if ('floorUuid' in updatedData) {
|
||||
if (projectId && updatedData) {
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
// API
|
||||
|
||||
upsertFloorApi(projectId, selectedVersion?.versionId || '', updatedData);
|
||||
|
||||
@@ -43,7 +43,7 @@ const SelectedFloorProperties = () => {
|
||||
if (!isNaN(parsed) && floor) {
|
||||
const updatedFloor = updateFloor(floor.floorUuid, { floorDepth: parsed });
|
||||
if (projectId) {
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
|
||||
// API
|
||||
|
||||
@@ -72,7 +72,7 @@ const SelectedFloorProperties = () => {
|
||||
if (!isNaN(parsed) && floor) {
|
||||
const updatedFloor = updateFloor(floor.floorUuid, { bevelStrength: parsed });
|
||||
if (projectId) {
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
|
||||
// API
|
||||
|
||||
@@ -100,7 +100,7 @@ const SelectedFloorProperties = () => {
|
||||
if (!floor) return;
|
||||
const updatedFloor = updateFloor(floor.floorUuid, { isBeveled: !floor.isBeveled });
|
||||
if (projectId) {
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
|
||||
// API
|
||||
|
||||
@@ -128,7 +128,7 @@ const SelectedFloorProperties = () => {
|
||||
const key = activeSurface === "top" ? "topMaterial" : "sideMaterial";
|
||||
const updatedFloor = updateFloor(floor.floorUuid, { [key]: material.textureId });
|
||||
if (projectId) {
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
|
||||
// API
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ const SelectedWallProperties = () => {
|
||||
if (!isNaN(height) && wall) {
|
||||
const updatedWall = updateWall(wall.wallUuid, { wallHeight: height });
|
||||
if (updatedWall && projectId) {
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
|
||||
// API
|
||||
|
||||
@@ -76,7 +76,7 @@ const SelectedWallProperties = () => {
|
||||
if (!isNaN(thickness) && wall) {
|
||||
const updatedWall = updateWall(wall.wallUuid, { wallThickness: thickness });
|
||||
if (updatedWall && projectId) {
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
|
||||
// API
|
||||
|
||||
@@ -105,7 +105,7 @@ const SelectedWallProperties = () => {
|
||||
const updated = (activeSide === "side1" ? { insideMaterial: material.textureId } : { outsideMaterial: material.textureId })
|
||||
const updatedWall = updateWall(wall.wallUuid, updated);
|
||||
if (updatedWall && projectId) {
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
|
||||
// API
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ import { getUserData } from "../../../../functions/getUserData";
|
||||
import { useVersionContext } from "../../../../modules/builder/version/versionContext";
|
||||
|
||||
const VersionSaved = () => {
|
||||
const { versionHistory, addVersion, createNewVersion, setCreateNewVersion } = useVersionHistoryStore();
|
||||
const { addVersion, createNewVersion, setCreateNewVersion } = useVersionHistoryStore();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { setSelectedVersion } = selectedVersionStore();
|
||||
const { selectedVersion, setSelectedVersion } = selectedVersionStore();
|
||||
const [newName, setNewName] = useState(new Date().toLocaleString("en-US", {
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
@@ -26,8 +26,6 @@ const VersionSaved = () => {
|
||||
const { projectId } = useParams();
|
||||
const { userId } = getUserData();
|
||||
|
||||
const latestVersion = versionHistory?.[0];
|
||||
|
||||
useEffect(() => {
|
||||
if (createNewVersion) {
|
||||
const defaultName = new Date().toLocaleString("en-US", {
|
||||
@@ -43,12 +41,12 @@ const VersionSaved = () => {
|
||||
}, [createNewVersion]);
|
||||
|
||||
const handleSave = () => {
|
||||
if (!latestVersion || !projectId) return;
|
||||
if (!selectedVersion || !projectId) return;
|
||||
|
||||
const updatedName = (newName.trim() || latestVersion.versionName) ?? latestVersion.timeStamp;
|
||||
const updatedDescription = (description.trim() || latestVersion.versionName) ?? latestVersion.timeStamp;
|
||||
const updatedName = (newName.trim() || selectedVersion.versionName) ?? selectedVersion.timeStamp;
|
||||
const updatedDescription = (description.trim() || selectedVersion.versionName) ?? selectedVersion.timeStamp;
|
||||
|
||||
createVersionApi(projectId, userId, latestVersion.versionId, updatedName, updatedDescription).then((data) => {
|
||||
createVersionApi(projectId, userId, selectedVersion.versionId, updatedName, updatedDescription).then((data) => {
|
||||
setSaveFinish(true);
|
||||
setCreateNewVersion(false);
|
||||
|
||||
@@ -84,7 +82,7 @@ const VersionSaved = () => {
|
||||
setCreateNewVersion(false);
|
||||
};
|
||||
|
||||
if (!latestVersion) return null;
|
||||
if (!selectedVersion) return null;
|
||||
|
||||
return (
|
||||
<div className={`versionSaved`}>
|
||||
@@ -105,7 +103,7 @@ const VersionSaved = () => {
|
||||
placeholder="Enter new version name"
|
||||
/>
|
||||
<div className="label">
|
||||
by @{latestVersion.createdBy}{" "}{new Date(latestVersion.timeStamp).toLocaleDateString("en-US", {
|
||||
by @{selectedVersion.createdBy}{" "}{new Date(selectedVersion.timeStamp).toLocaleDateString("en-US", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "2-digit",
|
||||
|
||||
Reference in New Issue
Block a user