mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
remove search categories
This commit is contained in:
parent
dd297800da
commit
5703cbecac
@ -1,12 +0,0 @@
|
||||
.optionItem {
|
||||
margin-bottom: calc(var(--spacer) / 4);
|
||||
padding-left: 1.5rem;
|
||||
}
|
||||
|
||||
.optionItem label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.optionItem input {
|
||||
margin-left: -1.5rem;
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
import React from 'react'
|
||||
import useCategoriesQueryParams from '../../hooks/useCategoriesQueryParams'
|
||||
import SearchFilterSection from '../atoms/SearchFilterSection'
|
||||
import Checkbox from '../atoms/Checkbox'
|
||||
import { CATEGORIES } from '../../models/PublishForm'
|
||||
|
||||
import styles from './SearchCategoriesFilter.module.css'
|
||||
|
||||
const SearchCategoriesFilter = () => {
|
||||
const { selectedCategories, toggleCategory } = useCategoriesQueryParams(
|
||||
CATEGORIES
|
||||
)
|
||||
|
||||
return (
|
||||
<SearchFilterSection title="Filter by type">
|
||||
<ul>
|
||||
{CATEGORIES.map(category => (
|
||||
<li key={category} className={styles.optionItem}>
|
||||
<Checkbox
|
||||
name={category}
|
||||
checked={selectedCategories.includes(category)}
|
||||
onChange={() => toggleCategory(category)}
|
||||
label={category}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</SearchFilterSection>
|
||||
)
|
||||
}
|
||||
|
||||
export default SearchCategoriesFilter
|
@ -4,35 +4,27 @@ import Layout from '../../Layout'
|
||||
import PageHeader from '../molecules/PageHeader'
|
||||
import SearchBar from '../molecules/SearchBar'
|
||||
import AssetList from '../organisms/AssetList'
|
||||
import SearchCategoriesFilter from '../molecules/SearchCategoriesFilter'
|
||||
import { SearchPriceFilter } from '../molecules/SearchPriceFilter'
|
||||
|
||||
import styles from './Search.module.css'
|
||||
|
||||
export declare type SearchPageProps = {
|
||||
text: string | string[]
|
||||
categories: string[] | undefined
|
||||
|
||||
tag: string | string[]
|
||||
queryResult: QueryResult
|
||||
}
|
||||
|
||||
const SearchPage = ({
|
||||
text,
|
||||
categories,
|
||||
tag,
|
||||
queryResult
|
||||
}: SearchPageProps) => {
|
||||
const categoriesText = categories?.join(', ')
|
||||
const SearchPage = ({ text, tag, queryResult }: SearchPageProps) => {
|
||||
return (
|
||||
<Layout noPageHeader>
|
||||
<section className={styles.grid}>
|
||||
<div className={styles.search}>
|
||||
<PageHeader title={`Search for ${text || categoriesText || tag}`} />
|
||||
<PageHeader title={`Search for ${text || tag}`} />
|
||||
{text && <SearchBar initialValue={text as string} />}
|
||||
</div>
|
||||
|
||||
<aside className={styles.side}>
|
||||
<SearchCategoriesFilter />
|
||||
<SearchPriceFilter />
|
||||
</aside>
|
||||
|
||||
|
@ -6,27 +6,14 @@ import SearchPage, { SearchPageProps } from '../components/templates/Search'
|
||||
import { config } from '../config/ocean'
|
||||
import { JSONparse, priceQueryParamToWei } from '../utils'
|
||||
|
||||
const Search: NextPage<SearchPageProps> = ({
|
||||
text,
|
||||
categories,
|
||||
tag,
|
||||
queryResult
|
||||
}) => {
|
||||
return (
|
||||
<SearchPage
|
||||
text={text}
|
||||
categories={categories}
|
||||
tag={tag}
|
||||
queryResult={queryResult}
|
||||
/>
|
||||
)
|
||||
const Search: NextPage<SearchPageProps> = ({ text, tag, queryResult }) => {
|
||||
return <SearchPage text={text} tag={tag} queryResult={queryResult} />
|
||||
}
|
||||
|
||||
export function getSearchQuery(
|
||||
page?: string | string[],
|
||||
offset?: string | string[],
|
||||
text?: string | string[],
|
||||
categoriesParsed?: string[],
|
||||
tag?: string | string[],
|
||||
priceQuery?: [string | undefined, string | undefined]
|
||||
) {
|
||||
@ -35,7 +22,6 @@ export function getSearchQuery(
|
||||
offset: Number(offset) || 20,
|
||||
query: {
|
||||
text,
|
||||
categories: categoriesParsed,
|
||||
tags: tag ? [tag] : undefined,
|
||||
price: priceQuery
|
||||
},
|
||||
@ -51,19 +37,8 @@ export function getSearchQuery(
|
||||
}
|
||||
|
||||
Search.getInitialProps = async context => {
|
||||
const {
|
||||
text,
|
||||
categories,
|
||||
tag,
|
||||
page,
|
||||
offset,
|
||||
minPrice,
|
||||
maxPrice
|
||||
} = context.query
|
||||
const categoriesParsed = JSONparse<string[]>(
|
||||
categories as string,
|
||||
'Error parsing context.query.categories and setting categoriesParsed'
|
||||
)
|
||||
const { text, tag, page, offset, minPrice, maxPrice } = context.query
|
||||
|
||||
const minPriceParsed = priceQueryParamToWei(
|
||||
minPrice as string,
|
||||
'Error parsing context.query.minPrice'
|
||||
@ -83,12 +58,11 @@ Search.getInitialProps = async context => {
|
||||
|
||||
const aquarius = new Aquarius(config.aquariusUri as string, Logger)
|
||||
const queryResult = await aquarius.queryMetadata(
|
||||
getSearchQuery(page, offset, text, categoriesParsed, tag, priceQuery)
|
||||
getSearchQuery(page, offset, text, tag, priceQuery)
|
||||
)
|
||||
|
||||
return {
|
||||
text: text,
|
||||
categories: categoriesParsed,
|
||||
tag: tag,
|
||||
queryResult
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user