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 PageHeader from '../molecules/PageHeader'
|
||||||
import SearchBar from '../molecules/SearchBar'
|
import SearchBar from '../molecules/SearchBar'
|
||||||
import AssetList from '../organisms/AssetList'
|
import AssetList from '../organisms/AssetList'
|
||||||
import SearchCategoriesFilter from '../molecules/SearchCategoriesFilter'
|
|
||||||
import { SearchPriceFilter } from '../molecules/SearchPriceFilter'
|
import { SearchPriceFilter } from '../molecules/SearchPriceFilter'
|
||||||
|
|
||||||
import styles from './Search.module.css'
|
import styles from './Search.module.css'
|
||||||
|
|
||||||
export declare type SearchPageProps = {
|
export declare type SearchPageProps = {
|
||||||
text: string | string[]
|
text: string | string[]
|
||||||
categories: string[] | undefined
|
|
||||||
tag: string | string[]
|
tag: string | string[]
|
||||||
queryResult: QueryResult
|
queryResult: QueryResult
|
||||||
}
|
}
|
||||||
|
|
||||||
const SearchPage = ({
|
const SearchPage = ({ text, tag, queryResult }: SearchPageProps) => {
|
||||||
text,
|
|
||||||
categories,
|
|
||||||
tag,
|
|
||||||
queryResult
|
|
||||||
}: SearchPageProps) => {
|
|
||||||
const categoriesText = categories?.join(', ')
|
|
||||||
return (
|
return (
|
||||||
<Layout noPageHeader>
|
<Layout noPageHeader>
|
||||||
<section className={styles.grid}>
|
<section className={styles.grid}>
|
||||||
<div className={styles.search}>
|
<div className={styles.search}>
|
||||||
<PageHeader title={`Search for ${text || categoriesText || tag}`} />
|
<PageHeader title={`Search for ${text || tag}`} />
|
||||||
{text && <SearchBar initialValue={text as string} />}
|
{text && <SearchBar initialValue={text as string} />}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<aside className={styles.side}>
|
<aside className={styles.side}>
|
||||||
<SearchCategoriesFilter />
|
|
||||||
<SearchPriceFilter />
|
<SearchPriceFilter />
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
|
@ -6,27 +6,14 @@ import SearchPage, { SearchPageProps } from '../components/templates/Search'
|
|||||||
import { config } from '../config/ocean'
|
import { config } from '../config/ocean'
|
||||||
import { JSONparse, priceQueryParamToWei } from '../utils'
|
import { JSONparse, priceQueryParamToWei } from '../utils'
|
||||||
|
|
||||||
const Search: NextPage<SearchPageProps> = ({
|
const Search: NextPage<SearchPageProps> = ({ text, tag, queryResult }) => {
|
||||||
text,
|
return <SearchPage text={text} tag={tag} queryResult={queryResult} />
|
||||||
categories,
|
|
||||||
tag,
|
|
||||||
queryResult
|
|
||||||
}) => {
|
|
||||||
return (
|
|
||||||
<SearchPage
|
|
||||||
text={text}
|
|
||||||
categories={categories}
|
|
||||||
tag={tag}
|
|
||||||
queryResult={queryResult}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getSearchQuery(
|
export function getSearchQuery(
|
||||||
page?: string | string[],
|
page?: string | string[],
|
||||||
offset?: string | string[],
|
offset?: string | string[],
|
||||||
text?: string | string[],
|
text?: string | string[],
|
||||||
categoriesParsed?: string[],
|
|
||||||
tag?: string | string[],
|
tag?: string | string[],
|
||||||
priceQuery?: [string | undefined, string | undefined]
|
priceQuery?: [string | undefined, string | undefined]
|
||||||
) {
|
) {
|
||||||
@ -35,7 +22,6 @@ export function getSearchQuery(
|
|||||||
offset: Number(offset) || 20,
|
offset: Number(offset) || 20,
|
||||||
query: {
|
query: {
|
||||||
text,
|
text,
|
||||||
categories: categoriesParsed,
|
|
||||||
tags: tag ? [tag] : undefined,
|
tags: tag ? [tag] : undefined,
|
||||||
price: priceQuery
|
price: priceQuery
|
||||||
},
|
},
|
||||||
@ -51,19 +37,8 @@ export function getSearchQuery(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Search.getInitialProps = async context => {
|
Search.getInitialProps = async context => {
|
||||||
const {
|
const { text, tag, page, offset, minPrice, maxPrice } = context.query
|
||||||
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 minPriceParsed = priceQueryParamToWei(
|
const minPriceParsed = priceQueryParamToWei(
|
||||||
minPrice as string,
|
minPrice as string,
|
||||||
'Error parsing context.query.minPrice'
|
'Error parsing context.query.minPrice'
|
||||||
@ -83,12 +58,11 @@ Search.getInitialProps = async context => {
|
|||||||
|
|
||||||
const aquarius = new Aquarius(config.aquariusUri as string, Logger)
|
const aquarius = new Aquarius(config.aquariusUri as string, Logger)
|
||||||
const queryResult = await aquarius.queryMetadata(
|
const queryResult = await aquarius.queryMetadata(
|
||||||
getSearchQuery(page, offset, text, categoriesParsed, tag, priceQuery)
|
getSearchQuery(page, offset, text, tag, priceQuery)
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
text: text,
|
text: text,
|
||||||
categories: categoriesParsed,
|
|
||||||
tag: tag,
|
tag: tag,
|
||||||
queryResult
|
queryResult
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user