mirror of
https://github.com/mue/mue.git
synced 2026-07-27 02:31:06 +02:00
- Converted ItemPage from a class component to a functional component using hooks for state management. - Introduced MarketplaceContext for managing marketplace-related state and actions. - Created custom hooks: useMarketplaceData for fetching and sorting marketplace items, useMarketplaceInstall for handling installation and uninstallation of items, and useMarketplaceNavigation for managing navigation within the marketplace. - Implemented BrowsePage and CollectionPage components to display items and collections with improved structure and functionality. - Enhanced error handling and loading states across the marketplace features.
84 lines
2.3 KiB
JavaScript
84 lines
2.3 KiB
JavaScript
import variables from 'config/variables';
|
|
import { MdSearch, MdOutlineArrowForward } from 'react-icons/md';
|
|
|
|
import { Button } from 'components/Elements';
|
|
import Items from '../components/Items/Items';
|
|
|
|
const BrowsePage = ({
|
|
type,
|
|
items,
|
|
featuredCollection,
|
|
filter,
|
|
onFilterChange,
|
|
onItemClick,
|
|
onCollectionClick,
|
|
onSortChange,
|
|
}) => {
|
|
return (
|
|
<>
|
|
<div className="headerExtras marketplaceCondition">
|
|
{type !== 'collections' && (
|
|
<div>
|
|
<form className="marketplaceSearch">
|
|
<input
|
|
label={variables.getMessage('widgets.search')}
|
|
placeholder={variables.getMessage('widgets.search')}
|
|
name="filter"
|
|
id="filter"
|
|
value={filter}
|
|
onChange={onFilterChange}
|
|
/>
|
|
<MdSearch />
|
|
</form>
|
|
</div>
|
|
)}
|
|
</div>
|
|
|
|
{type === 'collections' ? (
|
|
items.map((item) =>
|
|
!item.news ? (
|
|
<div
|
|
key={item.name}
|
|
className="collection"
|
|
style={
|
|
item.news
|
|
? { backgroundColor: item.background_colour }
|
|
: {
|
|
backgroundImage: `linear-gradient(to left, #000, transparent, #000), url('${item.img}')`,
|
|
}
|
|
}
|
|
>
|
|
<div className="content">
|
|
<span className="title">{item.display_name}</span>
|
|
<span className="subtitle">{item.description}</span>
|
|
</div>
|
|
<Button
|
|
type="collection"
|
|
onClick={() => onCollectionClick(item.name)}
|
|
icon={<MdOutlineArrowForward />}
|
|
label={variables.getMessage('modals.main.marketplace.explore_collection')}
|
|
iconPlacement="right"
|
|
/>
|
|
</div>
|
|
) : null,
|
|
)
|
|
) : (
|
|
<Items
|
|
filterOptions={true}
|
|
type={type}
|
|
items={items}
|
|
collection={featuredCollection}
|
|
onCollection={false}
|
|
toggleFunction={onItemClick}
|
|
collectionFunction={onCollectionClick}
|
|
filter={filter}
|
|
onSortChange={onSortChange}
|
|
showCreateYourOwn={true}
|
|
/>
|
|
)}
|
|
</>
|
|
);
|
|
};
|
|
|
|
export { BrowsePage as default, BrowsePage };
|