mue/src/components/modals/main/marketplace/Items.jsx

166 lines
5.6 KiB
React
Raw Normal View History

import variables from 'modules/variables';
2022-10-17 20:41:00 +00:00
import TextField from '@mui/material/TextField';
2022-08-03 09:42:04 +00:00
import React, { useState } from 'react';
2022-08-21 11:41:05 +00:00
import {
MdAutoFixHigh,
MdOutlineArrowForward,
MdExpandMore,
MdOutlineOpenInNew,
MdOutlinePhoto as Background,
MdOutlineFormatQuote as Quote,
MdOutlineSettings as Advanced,
MdSearch,
2022-08-21 11:41:05 +00:00
} from 'react-icons/md';
export default function Items({
type,
items,
collection,
toggleFunction,
collectionFunction,
onCollection,
}) {
const [count, setCount] = useState(8);
2022-10-17 20:41:00 +00:00
const [filter, setFilter] = useState('');
const [cheese, setCheese] = useState('photo')
const [filteredCategory, setFilteredCategory] = useState('');
const incrementCount = () => {
if (count !== items.length && count <= items.length) {
2022-08-03 09:42:04 +00:00
if (count + 8 > items.length) {
setCount(count + (items.length - count));
2022-08-03 09:42:04 +00:00
} else {
setCount(count + 8);
}
}
};
return (
<>
{(type === 'all' && !onCollection) || (type === 'collections' && !onCollection) ? (
<>
<div style={{ display: 'flex', flexFlow: 'row', alignItems: 'center', gap: '30px' }}>
<form className="marketplaceSearch">
<input
label="Search"
name="filter"
id="filter"
value={filter}
onChange={(event) => setFilter(event.target.value)}
/>
<MdSearch/>
</form>
</div>
2022-08-03 09:42:04 +00:00
<div
className="collection"
2022-08-21 11:41:05 +00:00
style={
collection.news
? { backgroundColor: collection.background_colour }
: {
backgroundImage: `linear-gradient(to left, #000, transparent, #000), url('${collection.img}')`,
}
}
2022-08-03 09:42:04 +00:00
>
<div className="content">
<span className="title">{collection.display_name}</span>
<span className="subtitle">{collection.description}</span>
</div>
2022-08-08 14:21:35 +00:00
{collection.news === true ? (
<a
className="collectionButton"
href={collection.news_link}
target="_blank"
rel="noopener noreferrer"
>
2022-08-29 20:07:52 +00:00
{variables.getMessage('modals.main.marketplace.learn_more')} <MdOutlineOpenInNew />
2022-08-08 14:21:35 +00:00
</a>
) : (
<button
className="collectionButton"
onClick={() => collectionFunction(collection.name)}
>
<MdOutlineArrowForward />{' '}
{variables.getMessage('modals.main.marketplace.explore_collection')}
2022-08-08 14:21:35 +00:00
</button>
)}
2022-08-03 09:42:04 +00:00
</div>
</>
) : null}
<div className="items">
{items
.filter(
(item) =>
item.name.toLowerCase().includes(filter.toLowerCase()) ||
filter === '' ||
item.author.toLowerCase().includes(filter.toLowerCase()) ||
item.type.toLowerCase().includes(filter.toLowerCase() || cheese),
)
.map((item) => (
<div className="item" onClick={() => toggleFunction(item)} key={item.name}>
<img
alt="icon"
draggable="false"
src={variables.constants.DDG_IMAGE_PROXY + item.icon_url}
/>
<div className="card-details">
<span className="card-title">{item.display_name || item.name}</span>
<span className="card-subtitle">{item.author}</span>
</div>
</div>
))}
</div>
2022-10-17 20:41:00 +00:00
{/*<div className="items">
{items.slice(0, count).map((item) => (
<div className="item" onClick={() => toggleFunction(item)} key={item.name}>
<img
alt="icon"
draggable="false"
src={variables.constants.DDG_IMAGE_PROXY + item.icon_url}
/>
<div className="card-details">
<span className="card-title">{item.display_name || item.name}</span>
<span className="card-subtitle">{item.author}</span>
</div>
2021-04-03 12:32:00 +00:00
</div>
))}
2022-10-17 20:41:00 +00:00
</div>
2022-08-03 09:42:04 +00:00
<div className="showMoreItems">
{count !== items.length && items.length >= 8 ? (
<span className="link" onClick={incrementCount}>
2022-08-29 20:07:52 +00:00
<MdExpandMore /> {variables.getMessage('modals.main.marketplace.product.show_more')}
2022-08-03 09:42:04 +00:00
</span>
2022-08-02 20:39:11 +00:00
) : null}
{items.length <= 8 ? (
2022-08-03 09:42:04 +00:00
<span className="subtitle">
{variables.getMessage('modals.main.marketplace.product.showing')} {items.length} /{' '}
{items.length}
2022-08-03 09:42:04 +00:00
</span>
2022-08-02 20:39:11 +00:00
) : (
2022-08-03 09:42:04 +00:00
<span className="subtitle">
{variables.getMessage('modals.main.marketplace.product.showing')} {count} /{' '}
{items.length}
2022-08-03 09:42:04 +00:00
</span>
2022-08-02 20:39:11 +00:00
)}
2022-10-17 20:41:00 +00:00
</div>*/}
<div className="loader"></div>
{type === 'all' && !onCollection ? (
<div className="createYourOwn">
<MdAutoFixHigh />
<span className="title">{variables.getMessage('modals.main.marketplace.cant_find')}</span>
<span className="subtitle">
{variables.getMessage('modals.main.marketplace.knowledgebase_one')}{' '}
<a
className="link"
target="_blank"
href={variables.constants.KNOWLEDGEBASE}
rel="noreferrer"
>
{variables.getMessage('modals.main.marketplace.knowledgebase_two')}
</a>{' '}
{variables.getMessage('modals.main.marketplace.knowledgebase_three')}
</span>
</div>
) : null}
</>
);
}