From cd0b07b3adb36fb5ec098f9e511ab45d774fee7b Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Tue, 30 Jan 2018 12:41:01 -0500 Subject: Move to Prisma Backend --- frontend/components/Search.js | 68 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 frontend/components/Search.js (limited to 'frontend/components/Search.js') diff --git a/frontend/components/Search.js b/frontend/components/Search.js new file mode 100644 index 0000000..0ce136e --- /dev/null +++ b/frontend/components/Search.js @@ -0,0 +1,68 @@ +import Downshift from 'downshift'; +import { SEARCH_ITEMS_QUERY } from '../queries'; +import { graphql, compose } from 'react-apollo'; +import makeImage from '../lib/image'; +import { Router } from '../routes'; +import slugify from 'slugify'; + +function routeToItem(item) { + Router.pushRoute('item', { + slug: slugify(item.title), + itemId: item.id, + }); +} + +function BasicAutocomplete(props) { + const { items, onChange } = props; + return ( + item.title}> + {({ getInputProps, getItemProps, isOpen, inputValue, selectedItem, highlightedIndex }) => ( +
+ props.refetch({ searchTerm: e.target.value }), + style: { fontSize: '20px', padding: '20px', display: 'block', width: '100%' }, + })} + /> + {isOpen ? ( +
+ {items.map((item, index) => ( +
+ {item.title} + {item.title} +
+ ))} +
+ ) : null} +
+ )} +
+ ); +} + +const Search = props => ( + console.log(selectedItem)} + refetch={props.searchItems.refetch} + /> +); + +const searchEnhancer = graphql(SEARCH_ITEMS_QUERY, { + name: 'searchItems', + options: { + variables: { searchTerm: 'camo' }, + }, +}); +export default compose(searchEnhancer)(Search); -- cgit v1.3