diff --git a/web/src/components/ResourceItem.tsx b/web/src/components/ResourceItem.tsx index 164ac8c8..8c311015 100644 --- a/web/src/components/ResourceItem.tsx +++ b/web/src/components/ResourceItem.tsx @@ -22,12 +22,12 @@ const ResourceItem = ({ }; return ( -
- +
+ - {resource.id} - handleRenameBtnClick(resource)}> + {resource.id} + handleRenameBtnClick(resource)}> {resource.filename}
diff --git a/web/src/hooks/index.ts b/web/src/hooks/index.ts index b9e50af1..2ca0fc05 100644 --- a/web/src/hooks/index.ts +++ b/web/src/hooks/index.ts @@ -1,5 +1,4 @@ export * from "./useDebounce"; -export * from "./useListStyle"; export * from "./useLoading"; export * from "./useTimeoutFn"; export * from "./useToggle"; diff --git a/web/src/hooks/useListStyle.ts b/web/src/hooks/useListStyle.ts deleted file mode 100644 index 528bae36..00000000 --- a/web/src/hooks/useListStyle.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { useState } from "react"; - -const useListStyle = () => { - // true is Table Style, false is Grid Style - const [listStyle, setListStyle] = useState(false); - - return { - listStyle: listStyle, - setToTableStyle: () => { - setListStyle(true); - }, - setToGridStyle: () => { - setListStyle(false); - }, - }; -}; -export default useListStyle; diff --git a/web/src/pages/ResourcesDashboard.tsx b/web/src/pages/ResourcesDashboard.tsx index 0657de80..8e00db2e 100644 --- a/web/src/pages/ResourcesDashboard.tsx +++ b/web/src/pages/ResourcesDashboard.tsx @@ -4,7 +4,6 @@ import { useEffect, useMemo, useState } from "react"; import { toast } from "react-hot-toast"; import { useTranslation } from "react-i18next"; import useLoading from "@/hooks/useLoading"; -import useListStyle from "@/hooks/useListStyle"; import { useResourceStore } from "@/store/module"; import { getResourceUrl } from "@/utils/resource"; import Icon from "@/components/Icon"; @@ -24,9 +23,8 @@ const ResourcesDashboard = () => { const resourceStore = useResourceStore(); const resources = resourceStore.state.resources; const [selectedList, setSelectedList] = useState>([]); - const [isVisible, setIsVisible] = useState(false); + const [listStyle, setListStyle] = useState<"GRID" | "TABLE">("GRID"); const [queryText, setQueryText] = useState(""); - const { listStyle, setToTableStyle, setToGridStyle } = useListStyle(); const [dragActive, setDragActive] = useState(false); useEffect(() => { @@ -41,14 +39,6 @@ const ResourcesDashboard = () => { }); }, []); - useEffect(() => { - if (selectedList.length === 0) { - setIsVisible(false); - } else { - setIsVisible(true); - } - }, [selectedList]); - const handleCheckBtnClick = (resourceId: ResourceId) => { setSelectedList([...selectedList, resourceId]); }; @@ -102,12 +92,8 @@ const ResourcesDashboard = () => { } }; - const handleStyleChangeBtnClick = (listStyleValue: boolean) => { - if (listStyleValue) { - setToTableStyle(); - } else { - setToGridStyle(); - } + const handleStyleChangeBtnClick = (listStyle: "GRID" | "TABLE") => { + setListStyle(listStyle); setSelectedList([]); }; @@ -160,7 +146,7 @@ const ResourcesDashboard = () => { resources .filter((res: Resource) => (queryText === "" ? true : res.filename.toLowerCase().includes(queryText.toLowerCase()))) .map((resource) => - listStyle ? ( + listStyle === "TABLE" ? ( {
- {isVisible && ( + {selectedList.length > 0 && ( @@ -273,17 +259,17 @@ const ResourcesDashboard = () => {
handleStyleChangeBtnClick(false)} + onClick={() => handleStyleChangeBtnClick("GRID")} >
handleStyleChangeBtnClick(true)} + onClick={() => handleStyleChangeBtnClick("TABLE")} >
@@ -297,16 +283,16 @@ const ResourcesDashboard = () => { ) : (
- {listStyle && ( -
- {t("resources.select")} - ID - {t("resources.name")} + {listStyle === "TABLE" && ( +
+ + ID + {t("resources.name")}
)}