diff --git a/src/components/Resources/CollectionTab.jsx b/src/components/Resources/CollectionTab.jsx index e55d087..c46f24a 100644 --- a/src/components/Resources/CollectionTab.jsx +++ b/src/components/Resources/CollectionTab.jsx @@ -43,7 +43,7 @@ export default function CollectionTab({ className, products }) { {({ datas }) => ( diff --git a/src/components/Resources/index.jsx b/src/components/Resources/index.jsx index 54df7c4..cc9fb81 100644 --- a/src/components/Resources/index.jsx +++ b/src/components/Resources/index.jsx @@ -1,9 +1,9 @@ import React, { useState } from "react"; import { Link } from "react-router-dom"; -import authProfilePic from "../../assets/images/auth-profile-picture.png"; -import profileBanner from "../../assets/images/profile-cover.png"; -import collections from "../../data/collectionplan_data.json"; -import marketPlace from "../../data/marketplace_data.json"; +// import authProfilePic from "../../assets/images/auth-profile-picture.png"; +// import profileBanner from "../../assets/images/profile-cover.png"; +// import collections from "../../data/collectionplan_data.json"; Should this be cleaned off? +// import marketPlace from "../../data/marketplace_data.json"; import products from "../../data/product_data.json"; import Layout from "../Partials/Layout"; import ActivitiesTab from "./ActivitiesTab"; @@ -12,130 +12,132 @@ import CreatedTab from "./CreatedTab"; import HiddenProductsTab from "./HiddenProductsTab"; import OnSaleTab from "./OnSaleTab"; import OwnTab from "./OwnTab"; +import LoadingSpinner from "../Spinners/LoadingSpinner"; export default function Resources(props) { - console.log('RESOURCES=>',props); - const onSaleProducts = marketPlace.data; - const CreatedSell = marketPlace.data; - const CreatedBits = products.datas; + // console.log("RESOURCES=>", props); // const mainProducts = products.datas; const ownProducts = products.datas; - const collectionProducts = collections.data; - const tabs = [ - { - id: 1, - name: "onsale", - content: "On Sale", - }, - { - id: 2, - name: "owned", - content: "Owned", - }, - { - id: 3, - name: "created", - content: "Created", - }, - { - id: 4, - name: "hidden", - content: "Hidden", - }, - { - id: 5, - name: "collection", - content: "Collection", - }, - { - id: 6, - name: "activity", - content: "Activity", - }, - ]; + // Resource Props + const __resources = props.MyResourceData; + + // Collection Items + const collectionProducts = __resources?.collectiondata?.data; + const tab_categories = __resources?.tab_categories?.data; + const onSaleProducts = __resources?.marketdata?.data; + const CreatedSell = __resources?.marketdata?.data; + const CreatedBits = __resources?.productdata?.data; + + const [tab, setTab] = useState(tab_categories ? tab_categories[0]?.name : ""); - const [tab, setTab] = useState(tabs[0].name); const tabHandler = (value) => { setTab(value); }; + + // Category Components + const tabComponents = { + onsale: , + owned: , + created: ( + + ), + hidden: ( + + ), + collection: , + activity: , + }; + + const defaultTabComponent = ; + + const selectedTabComponent = tabComponents[tab] || defaultTabComponent; + + // Tab Item Component + const TabItem = ({ tabValue, isActive }) => { + return ( +
  • tabHandler(tabValue.name)} + > + + {tabValue.content} + + + 16 + +
  • + ); + }; + + // Tab List Component + const TabList = ({ tabCategories }) => { + return ( +
      + {tabCategories.length > 0 && + tabCategories?.map((tabValue, idx) => ( + + ))} +
    + ); + }; + return ( <>
    -
    -
    -
    -
    -
    -
      - {tabs && - tabs.length > 0 && - tabs.map((tabValue) => ( -
    • tabHandler(tabValue.name)} - > - - {tabValue.content} - - - 16 - -
    • - ))} -
    -
    -
    - - Upload Product - + {props.MyResourceData.length == 0 || + Object.keys(props.MyResourceData).length == 0 ? ( +
    + +
    + ) : ( +
    +
    +
    +
    +
    +
      + +
    +
    +
    + + Upload Product + +
    +
    -
    +
    + +
    + {selectedTabComponent}
    - -
    - {tab === "onsale" ? ( - - ) : tab === "owned" ? ( - - ) : tab === "created" ? ( - - ) : tab === "hidden" ? ( - - ) : tab === "collection" ? ( - - ) : tab === "activity" ? ( - - ) : ( - "" - )} -
    -
    + )}
    diff --git a/src/views/ResourcePage.jsx b/src/views/ResourcePage.jsx index 2e03364..a6dd647 100644 --- a/src/views/ResourcePage.jsx +++ b/src/views/ResourcePage.jsx @@ -1,24 +1,21 @@ -import React, { useContext, useState, useEffect } from "react"; +import React, { useState, useEffect } from "react"; import Resources from "../components/Resources"; -import {useSelector} from "react-redux"; import usersService from "../services/UsersService"; export default function ResourcePage() { + const [MyResourceData, setMyResourceData] = useState([]); + const api = new usersService(); - const [MyResourceData, setMyResourceData] = useState([]); - const api = new usersService(); + const getMyResourceData = async () => { + try { + const res = await api.getResourceList(); + setMyResourceData(res.data); + } catch (error) { + throw new Error("Error getting mode"); + } + }; + useEffect(() => { + getMyResourceData(); + }, []); - const getMyResourceData = async () => { - try { - const res = await api.getResourceList(); - setMyResourceData(res.data); - } catch (error) { - console.log("Error getting mode"); - } - }; - useEffect(() => { - getMyResourceData(); - }, []); - - return ; -} + return ; +} \ No newline at end of file