This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
outline/frontend/scenes/Search/Search.js
2016-08-05 18:44:15 +03:00

60 lines
1.5 KiB
JavaScript

import React from 'react';
import { observer } from 'mobx-react';
import _debounce from 'lodash/debounce';
import { Flex } from 'reflexbox';
import Layout from 'components/Layout';
import CenteredContent from 'components/CenteredContent';
import SearchField from './components/SearchField';
import DocumentPreview from 'components/DocumentPreview';
import styles from './Search.scss';
import SearchStore from './SearchStore';
@observer
class Search extends React.Component {
static store;
constructor(props) {
super(props);
this.store = new SearchStore();
}
render() {
const search = _debounce((searchTerm) => {
this.store.search(searchTerm);
}, 250);
return (
<Layout
title="Search"
titleText="Search"
search={ false }
loading={ this.store.isFetching }
>
<CenteredContent>
<Flex column auto>
<Flex auto>
<img
src={ require('assets/icons/search.svg') }
className={ styles.icon }
alt="Search"
/>
<SearchField
searchTerm={ this.store.searchTerm }
onChange={ search }
/>
</Flex>
{ this.store.documents && this.store.documents.map((document) => {
return (<DocumentPreview key={ document.id } document={ document } />);
}) }
</Flex>
</CenteredContent>
</Layout>
);
}
}
export default Search;