From 0116c25ddd348211197611b19463fc40678ebdf3 Mon Sep 17 00:00:00 2001 From: alexsparkes Date: Sun, 16 Jun 2024 18:47:36 +0100 Subject: [PATCH] refactor(marketplace): Item page alterations --- .../Elements/MainModal/backend/TabNavbar.jsx | 2 +- .../marketplace/views/newItemPage.jsx | 137 ++++++++++-------- 2 files changed, 80 insertions(+), 59 deletions(-) diff --git a/src/components/Elements/MainModal/backend/TabNavbar.jsx b/src/components/Elements/MainModal/backend/TabNavbar.jsx index 16df0b7e..268fb430 100644 --- a/src/components/Elements/MainModal/backend/TabNavbar.jsx +++ b/src/components/Elements/MainModal/backend/TabNavbar.jsx @@ -144,7 +144,7 @@ const TabNavbar = ({ modalClose }) => {
{navbarLogo}
- {variables.getMessage(`modals.main.navbar.${activeTab}`)} + changeTab(activeTab)} className={clsx("text-xl capitalize tracking-normal transition-all duration-150 ease-in-out", { 'text-neutral-300 cursor-pointer hover:text-neutral-100': subTab !== '' && activeTab === 'marketplace' })}>{variables.getMessage(`modals.main.navbar.${activeTab}`)} {subTab !== '' && ( <> diff --git a/src/features/marketplace/views/newItemPage.jsx b/src/features/marketplace/views/newItemPage.jsx index 64ab50c1..237e20c3 100644 --- a/src/features/marketplace/views/newItemPage.jsx +++ b/src/features/marketplace/views/newItemPage.jsx @@ -1,5 +1,6 @@ import variables from 'config/variables'; import { useTab } from 'components/Elements/MainModal/backend/TabContext'; +import placeholderIcon from 'assets/icons/marketplace-placeholder.png'; import { useEffect, useState } from 'react'; import { ShareModal } from 'components/Elements'; import { @@ -18,12 +19,20 @@ import { import { Header } from 'components/Layout/Settings'; import Modal from 'react-modal'; import Markdown from 'markdown-to-jsx'; +import { Button } from 'components/Elements'; const NewItemPage = () => { const { subTab } = useTab(); const controller = new AbortController(); const [itemName, setItemName] = useState(''); const [ItemDescription, setItemDescription] = useState(''); + const [ItemAuthor, setItemAuthor] = useState(''); + const [ItemType, setItemType] = useState(''); + const [ItemIcon, setItemIcon] = useState(''); + const [count, setCount] = useState(5); + let quotes = []; + let ItemData; + //const [ItemData, setItemData] = useState([]); async function getItemData() { const item = await ( @@ -34,7 +43,17 @@ const NewItemPage = () => { console.log(item); setItemName(item.data.display_name); + setItemType(item.data.type); setItemDescription(item.data.description); + setItemAuthor(item.data.author); + setItemType(item.data.type); + setItemIcon(item.data.icon_url); + console.log(ItemType) + if (ItemType === 'quotes') { + quotes = item.data.quotes + console.log(quotes) + } + ItemData = item.data.data; } useEffect(() => { @@ -62,7 +81,7 @@ const NewItemPage = () => {
); - if (this.props.data.data.sideload === true) { + /*if (this.props.data.data.sideload === true) { return template(variables.getMessage('modals.main.marketplace.product.sideload_warning')); } @@ -74,7 +93,7 @@ const NewItemPage = () => { if (shortLocale !== this.props.data.data.language) { return template(variables.getMessage('modals.main.marketplace.product.not_in_language')); } - } + }*/ return null; }; @@ -157,7 +176,7 @@ const NewItemPage = () => { <> {/* { report={false} goBack={this.props.toggleFunction} />*/} - {itemName}
- {/*
+
{moreInfoItem( , variables.getMessage('modals.main.marketplace.product.created_by'), - this.props.data.author, + ItemAuthor, )} {itemWarning()}
- {this.props.data.data.photos && ( + {/*{this.props.data.data.photos && (
@@ -213,15 +231,14 @@ const NewItemPage = () => { }} /> )}*/} -
- - {variables.getMessage('modals.main.marketplace.product.description')} - - {ItemDescription} -
-
- {/*} - {this.props.data.data.quotes && ( +
+ + {variables.getMessage('modals.main.marketplace.product.description')} + + {ItemDescription} +
+ {quotes[0]} + {ItemType === 'quotes' && ( <> @@ -229,7 +246,7 @@ const NewItemPage = () => { - {this.props.data.data.quotes.slice(0, this.state.count).map((quote, index) => ( + {quotes.slice(0, count).map((quote, index) => ( @@ -238,15 +255,15 @@ const NewItemPage = () => {
{variables.getMessage('modals.main.settings.sections.quote.title')} {variables.getMessage('modals.main.settings.sections.quote.author')}
{quote.quote} {quote.author}
- this.incrementCount('quotes')}> - {this.state.count !== this.props.data.data.quotes.length + count === quotes.length}> + {count !== quotes.length ? variables.getMessage('modals.main.marketplace.product.show_all') : variables.getMessage('modals.main.marketplace.product.show_less')}
)} - {this.props.data.data.settings && ( + {/*{this.props.data.data.settings && ( <> @@ -272,31 +289,31 @@ const NewItemPage = () => { - )} + )}*/}
{variables.getMessage('modals.main.marketplace.product.details')}
- {this.props.data.data.updated_at && + {/*{this.props.data.data.updated_at && moreInfoItem( , variables.getMessage('modals.main.marketplace.product.updated_at'), formattedDate, - )} - {this.props.data.data.quotes && + )}*/} + {ItemData?.quotes && moreInfoItem( , variables.getMessage('modals.main.marketplace.product.no_quotes'), - this.props.data.data.quotes.length, + ItemData.quotes.length, )} - {this.props.data.data.photos && + {ItemData?.photos && moreInfoItem( , variables.getMessage('modals.main.marketplace.product.no_images'), - this.props.data.data.photos.length, + ItemData.photos.length, )} - {this.props.data.data.quotes && this.props.data.data.language + {/*{ItemData.quotes && ItemData.language ? moreInfoItem( , variables.getMessage('modals.main.settings.sections.language.title'), @@ -309,14 +326,14 @@ const NewItemPage = () => { variables.getMessage( 'modals.main.marketplace.' + this.getName(this.props.data.data.type), ) || 'marketplace', - )} + )}*/}
@@ -324,14 +341,19 @@ const NewItemPage = () => { className="icon" alt="icon" draggable={false} - src={this.props.data.data.icon_url} + src={ItemIcon} onError={(e) => { e.target.onerror = null; e.target.src = placeholderIcon; }} /> {localStorage.getItem('welcomePreview') !== 'true' ? ( - this.state.button +
- )} + )}*/} + {/*} {this.props.data.data.in_collections?.length > 0 && (
@@ -384,34 +407,32 @@ const NewItemPage = () => {
- )} + )}*/}
- {/*} - {moreByCurator.length > 1 && ( -
- - {variables.getMessage('modals.main.marketplace.product.more_from_curator', { - name: this.props.data.author, - })} - -
- this.props.toggleFunction('item', input)} - collectionFunction={(input) => this.props.toggleFunction('collection', input)} - filter={''} - moreByCreator={true} - showCreateYourOwn={false} - /> -
+ {/*{moreByCurator.length > 1 && ( +
+ + {variables.getMessage('modals.main.marketplace.product.more_from_curator', { + name: this.props.data.author, + })} + +
+ this.props.toggleFunction('item', input)} + collectionFunction={(input) => this.props.toggleFunction('collection', input)} + filter={''} + moreByCreator={true} + showCreateYourOwn={false} + />
- )} - */} +
+ )}*/} ); };