From 28995a6ad36569f43a5d5ad67d4a0241940bbe18 Mon Sep 17 00:00:00 2001 From: alexsparkes Date: Wed, 19 Jun 2024 12:38:11 +0100 Subject: [PATCH] fix(marketplace): Collection page --- .../Elements/MainModal/backend/TabNavbar.jsx | 14 +++++- .../api/MarketplaceDataContext.jsx | 21 +++++++-- .../components/Collection/Collection.jsx | 18 +++++--- .../marketplace/components/Items/Items.jsx | 2 - .../marketplace/views/CollectionPage.jsx | 32 ++++++++----- .../views/{Added.jsx => Library.jsx} | 0 src/features/misc/views/Addons.jsx | 2 +- src/features/misc/views/Marketplace.jsx | 45 +++++++++++++++---- 8 files changed, 102 insertions(+), 32 deletions(-) rename src/features/marketplace/views/{Added.jsx => Library.jsx} (100%) diff --git a/src/components/Elements/MainModal/backend/TabNavbar.jsx b/src/components/Elements/MainModal/backend/TabNavbar.jsx index fa0089da..00683e29 100644 --- a/src/components/Elements/MainModal/backend/TabNavbar.jsx +++ b/src/components/Elements/MainModal/backend/TabNavbar.jsx @@ -10,12 +10,14 @@ import { import { IoMdPricetag } from "react-icons/io"; import { motion, AnimatePresence } from 'framer-motion'; import { useTab } from './TabContext'; +import { useMarketData } from 'features/marketplace/api/MarketplaceDataContext'; import { Tooltip } from 'components/Elements'; import variables from 'config/variables'; import clsx from 'clsx'; const TabNavbar = ({ modalClose }) => { const { activeTab, subTab, changeTab, subSection, setSubTab, setSubSection } = useTab(); + const { setSelectedItem, setSelectedCollection } = useMarketData(); const tabs = [ { id: 'settings', label: 'Settings', icon: }, @@ -146,7 +148,11 @@ const TabNavbar = ({ modalClose }) => { {navbarLogo}
changeTab(activeTab)} + onClick={() => { + changeTab(activeTab); + setSelectedItem(null); + setSelectedCollection(null); + }} className={clsx( 'text-xl capitalize tracking-normal transition-all duration-150 ease-in-out', { @@ -206,7 +212,11 @@ const TabNavbar = ({ modalClose }) => { {tabs.map((tab) => (
); } -export default CollectionPage; +export { CollectionPage as default, CollectionPage }; diff --git a/src/features/marketplace/views/Added.jsx b/src/features/marketplace/views/Library.jsx similarity index 100% rename from src/features/marketplace/views/Added.jsx rename to src/features/marketplace/views/Library.jsx diff --git a/src/features/misc/views/Addons.jsx b/src/features/misc/views/Addons.jsx index b7f303cf..91fbbe23 100644 --- a/src/features/misc/views/Addons.jsx +++ b/src/features/misc/views/Addons.jsx @@ -1,7 +1,7 @@ import variables from 'config/variables'; import { memo } from 'react'; -import Added from '../../marketplace/views/Added'; +import Added from '../../marketplace/views/Library'; import Create from '../../marketplace/views/Create'; function Addons(props) { diff --git a/src/features/misc/views/Marketplace.jsx b/src/features/misc/views/Marketplace.jsx index 73a995d6..716e47ba 100644 --- a/src/features/misc/views/Marketplace.jsx +++ b/src/features/misc/views/Marketplace.jsx @@ -5,6 +5,7 @@ import MarketplaceTab from '../../marketplace/views/Browse'; import { useTab } from 'components/Elements/MainModal/backend/TabContext'; import { ItemPage } from '../../marketplace/views/ItemPage'; +import { CollectionPage } from '../../marketplace/views/CollectionPage'; import { NewItems as Items } from '../../marketplace/components/Items/Items'; import { AnimatePresence, motion } from 'framer-motion'; @@ -33,12 +34,15 @@ function Marketplace(props) { collections = [], getItems, getCollections, + selectedCollection, selectedItem, } = useMarketData(); const { subTab } = useTab(); const [itemsView, setItemsView] = useState('grid'); const [itemsFilter, setItemsFilter] = useState('all'); const [filteredItems, setFilteredItems] = useState([]); + const randomIndex = Math.floor(Math.random() * collections.length); + const collection = collections[randomIndex]; const fetchMarketData = async () => { try { @@ -71,11 +75,14 @@ function Marketplace(props) { ); }, [itemsFilter]); - const viewOptions = useMemo(() => [ - { id: 'grid', icon: }, - { id: 'list', icon: }, - ], []); - + const viewOptions = useMemo( + () => [ + { id: 'grid', icon: }, + { id: 'list', icon: }, + ], + [], + ); + const ItemView = useCallback(() => { return (
@@ -124,9 +131,31 @@ function Marketplace(props) { exit={{ opacity: 0 }} transition={{ duration: 0.8 }} > - {subTab === '' ? ( + {subTab === '' && selectedItem === null && selectedCollection === null && ( <> - + + +
+ +
+ +
+
+ +
+ + )} + {selectedItem !== null && ( + + + + )} + {selectedCollection !== null && ( + + )} + {/*{subTab === '' ? ( + <> +
@@ -141,7 +170,7 @@ function Marketplace(props) { - )} + )}*/} );