1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00
market/src/pages/search.tsx
Matthias Kretschmann 3505db21da
Owner/publisher search (#187)
* make owner search work

* owner/publisher search from asset details

* copy & cleanup

* style tweaks

* timing

* make search combinations work again

* remove account search highjacking

* switch owner source

* search route fixes

* eth address truncation in text search titles
2020-11-03 14:57:40 +01:00

28 lines
930 B
TypeScript

import React, { ReactElement } from 'react'
import PageSearch from '../components/templates/Search'
import { PageProps } from 'gatsby'
import Layout from '../components/Layout'
import queryString from 'query-string'
import { accountTruncate } from '../utils/wallet'
import ethereumAddress from 'ethereum-address'
export default function PageGatsbySearch(props: PageProps): ReactElement {
const parsed = queryString.parse(props.location.search)
const { text, owner, tags, categories } = parsed
const isETHAddress = ethereumAddress.isAddress(text as string)
const searchValue =
(isETHAddress ? accountTruncate(text as string) : text) ||
tags ||
categories
const title = owner
? `Published by ${accountTruncate(owner as string)}`
: `Search for ${searchValue || 'all data sets'}`
return (
<Layout title={title} uri={props.uri}>
<PageSearch location={props.location} />
</Layout>
)
}