diff --git a/src/features/marketplace/api/MarketplaceDataContext.jsx b/src/features/marketplace/api/MarketplaceDataContext.jsx index dac65a19..60f773b9 100644 --- a/src/features/marketplace/api/MarketplaceDataContext.jsx +++ b/src/features/marketplace/api/MarketplaceDataContext.jsx @@ -36,7 +36,11 @@ export const MarketplaceDataProvider = ({ children }) => { numOfRequests++; console.log('Request number: ', numOfRequests); - setItems(sortItems(data, 'z-a')); + //setItems(sortItems(data, 'z-a')); + const shuffledData = data.sort(() => Math.random() - 0.5); + + setItems(shuffledData); + setDone(true); }; @@ -71,6 +75,20 @@ export const MarketplaceDataProvider = ({ children }) => { resolve(item.data); }); }; + + const getCollectionData = async (collectionName) => { + const response = await fetch( + `${variables.constants.API_URL}/marketplace/collection/${collectionName}`, + { + signal: controller.signal, + }, + ); + const item = await response.json(); + setSelectedCollection(item.data); + return new Promise((resolve) => { + resolve(item.data); + }); + } return ( { getItems, getCollections, getItemData, + getCollectionData, setSelectedItem, setSelectedCollection, collections, diff --git a/src/features/marketplace/components/Collection/Collection.jsx b/src/features/marketplace/components/Collection/Collection.jsx index 9e190492..30734da4 100644 --- a/src/features/marketplace/components/Collection/Collection.jsx +++ b/src/features/marketplace/components/Collection/Collection.jsx @@ -8,7 +8,7 @@ import { useTab } from 'components/Elements/MainModal/backend/TabContext'; const Collection = ({ collection }) => { const { setSubTab } = useTab(); - const { setSelectedCollection } = useMarketData(); + const { setSelectedCollection, getCollectionData } = useMarketData(); const getStyle = () => { if (collection?.news) { @@ -21,12 +21,13 @@ const Collection = ({ collection }) => { }; const SelectCollection = () => { - setSubTab(collection.display_name); - setSelectedCollection(collection); + getCollectionData(collection.name).then((data) => { + setSubTab(data.display_name); + }); } return ( -
+
{collection?.display_name} {collection?.description ? collection?.description.substr(0, 75) : ''} diff --git a/src/features/marketplace/components/Elements/ItemCard/ItemCard.jsx b/src/features/marketplace/components/Elements/ItemCard/ItemCard.jsx index 6b709ec7..311360fd 100644 --- a/src/features/marketplace/components/Elements/ItemCard/ItemCard.jsx +++ b/src/features/marketplace/components/Elements/ItemCard/ItemCard.jsx @@ -15,6 +15,7 @@ function ItemCard({ item, type, onCollection, isCurator, cardStyle }) { const SelectItem = () => { getItemData(item.type, item.name).then((data) => { setSubTab(data.display_name); + console.log(data) }); }; @@ -66,8 +67,8 @@ function ItemCard({ item, type, onCollection, isCurator, cardStyle }) { key={item.name} style={{ // alpha 66=0.4 33=0.2 00=0 - backgroundImage: `radial-gradient(circle at center 25%, ${item.colour}66 0%, ${item.colour}33 10%, ${item.colour}00 75%)`, - // backgroundImage: `radial-gradient(circle at center 25%, ${item.colour}60, ${item.colour}0F)`, + //backgroundImage: `radial-gradient(circle at center 25%, ${item.colour}66 0%, ${item.colour}33 10%, ${item.colour}00 75%)`, + backgroundImage: `radial-gradient(circle at center 25%, ${item.colour}60, ${item.colour}0F)`, // backgroundImage: `radial-gradient(circle at center 25%, ${item.colour}55, ${item.colour}0A)`, }} > diff --git a/src/features/marketplace/views/CollectionPage.jsx b/src/features/marketplace/views/CollectionPage.jsx index 360892b1..37c7a875 100644 --- a/src/features/marketplace/views/CollectionPage.jsx +++ b/src/features/marketplace/views/CollectionPage.jsx @@ -2,6 +2,7 @@ import { useMarketData } from 'features/marketplace/api/MarketplaceDataContext'; import variables from 'config/variables'; import { MdLibraryAdd } from 'react-icons/md'; import { Button } from 'components/Elements'; +import { NewItems as Items } from '../components/Items/Items'; function CollectionPage() { const { selectedCollection } = useMarketData(); @@ -71,6 +72,7 @@ function CollectionPage() { }*/ />
+ ); }