Merge branch 'main-dev' into dev-api-socket-coordination
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React, { useState, useEffect, useMemo, useCallback } from "react";
|
||||
import { useDecalStore } from "../../../../store/builder/store";
|
||||
import { getFilteredAssets } from "./assetsHelpers/filteredAssetsHelper";
|
||||
import { fetchCategoryDecals } from "./assetsHelpers/fetchDecalsHelper";
|
||||
import { useBuilderStore } from "../../../../store/builder/useBuilderStore";
|
||||
import {
|
||||
fetchAllAssets,
|
||||
fetchCategoryAssets,
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
import { ArrowIcon } from "../../../icons/ExportCommonIcons";
|
||||
|
||||
const Assets: React.FC = () => {
|
||||
const { selectedSubCategory, setSelectedSubCategory } = useDecalStore();
|
||||
const { selectedDecalCategory, setSelectedDecalCategory } = useBuilderStore();
|
||||
const [searchValue, setSearchValue] = useState<string | null>(null);
|
||||
const [selectedCategory, setSelectedCategory] = useState<string | null>(null);
|
||||
const [assets, setAssets] = useState<AssetProp[] | DecalProp[]>([]);
|
||||
@@ -31,9 +31,9 @@ const Assets: React.FC = () => {
|
||||
assets,
|
||||
searchValue,
|
||||
selectedCategory,
|
||||
selectedSubCategory,
|
||||
selectedDecalCategory,
|
||||
}),
|
||||
[assets, searchValue, selectedCategory, selectedSubCategory]
|
||||
[assets, searchValue, selectedCategory, selectedDecalCategory]
|
||||
);
|
||||
|
||||
const handleFetchCategory = useCallback(
|
||||
@@ -43,14 +43,14 @@ const Assets: React.FC = () => {
|
||||
if (category === "Decals") {
|
||||
const res = await fetchCategoryDecals("Safety");
|
||||
setAssets(res);
|
||||
setSelectedSubCategory("Safety");
|
||||
setSelectedDecalCategory("Safety");
|
||||
} else {
|
||||
const res = await fetchCategoryAssets(category);
|
||||
setAssets(res);
|
||||
}
|
||||
setIsLoading(false);
|
||||
},
|
||||
[setSelectedSubCategory]
|
||||
[setSelectedDecalCategory]
|
||||
);
|
||||
|
||||
const fetchGlobalSearch = useCallback(async (term: string) => {
|
||||
@@ -90,7 +90,7 @@ const Assets: React.FC = () => {
|
||||
className="back-button"
|
||||
onClick={() => {
|
||||
setSelectedCategory(null);
|
||||
setSelectedSubCategory(null);
|
||||
setSelectedDecalCategory(null);
|
||||
setAssets([]);
|
||||
setSearchValue(null);
|
||||
}}
|
||||
@@ -106,14 +106,13 @@ const Assets: React.FC = () => {
|
||||
{ACTIVE_DECAL_SUBCATEGORIES.map((cat) => (
|
||||
<div
|
||||
key={cat.name}
|
||||
className={`catogory-asset-filter-wrapper ${
|
||||
selectedSubCategory === cat.name ? "active" : ""
|
||||
}`}
|
||||
className={`catogory-asset-filter-wrapper ${selectedDecalCategory === cat.name ? "active" : ""
|
||||
}`}
|
||||
onClick={async () => {
|
||||
setIsLoading(true);
|
||||
const res = await fetchCategoryDecals(cat.name);
|
||||
setAssets(res);
|
||||
setSelectedSubCategory(cat.name);
|
||||
setSelectedDecalCategory(cat.name);
|
||||
setIsLoading(false);
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -2,19 +2,19 @@ interface FilterProps {
|
||||
assets: AssetProp[] | DecalProp[];
|
||||
searchValue: string | null;
|
||||
selectedCategory: string | null;
|
||||
selectedSubCategory: string | null;
|
||||
selectedDecalCategory: string | null;
|
||||
}
|
||||
|
||||
export const getFilteredAssets = ({
|
||||
assets,
|
||||
searchValue,
|
||||
selectedCategory,
|
||||
selectedSubCategory,
|
||||
selectedDecalCategory,
|
||||
}: FilterProps) => {
|
||||
const term = searchValue?.trim().toLowerCase();
|
||||
if (!term) return assets;
|
||||
|
||||
if (selectedCategory === "Decals" || selectedSubCategory) {
|
||||
if (selectedCategory === "Decals" || selectedDecalCategory) {
|
||||
return (assets as DecalProp[]).filter((a) =>
|
||||
a.decalName?.toLowerCase().includes(term)
|
||||
);
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import React from "react";
|
||||
import { useDroppedDecal, useSelectedItem } from "../../../../../store/builder/store";
|
||||
import { useSelectedItem } from "../../../../../store/builder/store";
|
||||
import { useBuilderStore } from "../../../../../store/builder/useBuilderStore";
|
||||
|
||||
export const RenderAsset: React.FC<{ asset: AssetProp | DecalProp; index: number }> = ({ asset, index }) => {
|
||||
const { setSelectedItem } = useSelectedItem();
|
||||
const { setDroppedDecal } = useDroppedDecal();
|
||||
const { setDroppedDecal } = useBuilderStore();
|
||||
|
||||
if ("decalName" in asset) {
|
||||
return (
|
||||
|
||||
@@ -98,27 +98,27 @@ const AisleProperties: React.FC = () => {
|
||||
|
||||
const dashLengthValue = useMemo(() => {
|
||||
return dashLength.toString();
|
||||
}, [aisleType, dashLength]);
|
||||
}, [dashLength]);
|
||||
|
||||
const dotRadiusValue = useMemo(() => {
|
||||
return dotRadius.toString();
|
||||
}, [aisleType, dotRadius]);
|
||||
}, [dotRadius]);
|
||||
|
||||
const gapLengthValue = useMemo(() => {
|
||||
return gapLength.toString();
|
||||
}, [aisleType, gapLength]);
|
||||
}, [gapLength]);
|
||||
|
||||
const aisleWidthValue = useMemo(() => {
|
||||
return aisleWidth.toString();
|
||||
}, [aisleType, aisleWidth]);
|
||||
}, [aisleWidth]);
|
||||
|
||||
const aisleLengthValue = useMemo(() => {
|
||||
return aisleLength.toString();
|
||||
}, [aisleType, aisleLength]);
|
||||
}, [aisleLength]);
|
||||
|
||||
const aisleIsFlipped = useMemo(() => {
|
||||
return isFlipped;
|
||||
}, [aisleType, isFlipped]);
|
||||
}, [isFlipped]);
|
||||
|
||||
const renderAdvancedProperties = () => {
|
||||
switch (aisleType) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import RenameInput from "./inputs/RenameInput";
|
||||
import { ArrowIcon } from "../icons/ExportCommonIcons";
|
||||
import MenuBar from "./menu/menu";
|
||||
import { ProjectIcon } from "../icons/HeaderIcons";
|
||||
import { useProjectName, useSocketStore } from "../../store/builder/store";
|
||||
import { useProjectName } from "../../store/builder/store";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { getAllProjects } from "../../services/dashboard/getAllProjects";
|
||||
import { updateProject } from "../../services/dashboard/updateProject";
|
||||
@@ -14,7 +14,7 @@ const FileMenu: React.FC = () => {
|
||||
const containerRef = useRef<HTMLButtonElement>(null);
|
||||
let clickTimeout: NodeJS.Timeout | null = null;
|
||||
const { projectName, setProjectName } = useProjectName();
|
||||
const { dashBoardSocket } = useSocketStore();
|
||||
// const { dashBoardSocket } = useSocketStore();
|
||||
const { projectId } = useParams();
|
||||
const { userId, organization, email } = getUserData();
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@ import { toggleTheme } from "../../../utils/theme";
|
||||
import useVersionHistoryVisibleStore, {
|
||||
useShortcutStore,
|
||||
} from "../../../store/builder/store";
|
||||
import useModuleStore, { useSubModuleStore } from "../../../store/useModuleStore";
|
||||
import useModuleStore, {
|
||||
useSubModuleStore,
|
||||
} from "../../../store/useModuleStore";
|
||||
import { useVersionHistoryStore } from "../../../store/builder/useVersionHistoryStore";
|
||||
|
||||
interface MenuBarProps {
|
||||
@@ -21,11 +23,12 @@ interface MenuItem {
|
||||
}
|
||||
|
||||
const MenuBar: React.FC<MenuBarProps> = ({ setOpenMenu }) => {
|
||||
|
||||
const navigate = useNavigate();
|
||||
const [activeMenu, setActiveMenu] = useState<string | null>(null);
|
||||
const [activeSubMenu, setActiveSubMenu] = useState<string | null>(null);
|
||||
const [selectedItems, setSelectedItems] = useState<Record<string, boolean>>({});
|
||||
const [selectedItems, setSelectedItems] = useState<Record<string, boolean>>(
|
||||
{}
|
||||
);
|
||||
|
||||
const { setCreateNewVersion } = useVersionHistoryStore();
|
||||
const { setVersionHistoryVisible } = useVersionHistoryVisibleStore();
|
||||
@@ -49,7 +52,9 @@ const MenuBar: React.FC<MenuBarProps> = ({ setOpenMenu }) => {
|
||||
};
|
||||
|
||||
const handleLogout = () => {
|
||||
const theme = localStorage.getItem("theme") ?? "light";
|
||||
localStorage.clear();
|
||||
localStorage.setItem("theme", theme);
|
||||
navigate("/");
|
||||
};
|
||||
|
||||
@@ -61,7 +66,7 @@ const MenuBar: React.FC<MenuBarProps> = ({ setOpenMenu }) => {
|
||||
setCreateNewVersion(true);
|
||||
setVersionHistoryVisible(true);
|
||||
setSubModule("properties");
|
||||
setActiveModule('builder');
|
||||
setActiveModule("builder");
|
||||
}
|
||||
|
||||
const menus: Record<string, MenuItem[]> = {
|
||||
@@ -222,7 +227,7 @@ const MenuBar: React.FC<MenuBarProps> = ({ setOpenMenu }) => {
|
||||
onClick={() => {
|
||||
setVersionHistoryVisible(true);
|
||||
setSubModule("properties");
|
||||
setActiveModule('builder');
|
||||
setActiveModule("builder");
|
||||
}}
|
||||
>
|
||||
<div className="menu-button">
|
||||
|
||||
Reference in New Issue
Block a user