From 2d145b026cfdf54a63bef0b9d6324b6785390307 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Fri, 14 Sep 2018 12:18:12 -0400 Subject: move finished folder --- .../FINISHED/frontend/components/Search.js | 94 ---------------------- 1 file changed, 94 deletions(-) delete mode 100644 stepped-solutions/FINISHED/frontend/components/Search.js (limited to 'stepped-solutions/FINISHED/frontend/components/Search.js') diff --git a/stepped-solutions/FINISHED/frontend/components/Search.js b/stepped-solutions/FINISHED/frontend/components/Search.js deleted file mode 100644 index c29f93e..0000000 --- a/stepped-solutions/FINISHED/frontend/components/Search.js +++ /dev/null @@ -1,94 +0,0 @@ -import React from 'react'; -import Downshift, { resetIdCounter } from 'downshift'; -import Router from 'next/router'; -import { ApolloConsumer } from 'react-apollo'; -import gql from 'graphql-tag'; -import debounce from 'lodash.debounce'; -import { DropDown, DropDownItem, SearchStyles } from './styles/DropDown'; - -const SEARCH_ITEMS_QUERY = gql` - query SEARCH_ITEMS_QUERY($searchTerm: String!) { - items(where: { OR: [{ title_contains: $searchTerm }, { description_contains: $searchTerm }] }) { - id - image - title - } - } -`; - -function routeToItem(item) { - Router.push({ - pathname: '/item', - query: { - id: item.id, - }, - }); -} - -class AutoComplete extends React.Component { - state = { - items: [], - loading: false, - }; - onChange = debounce(async (e, client) => { - console.log('Searching...'); - // turn loading on - this.setState({ loading: true }); - // Manually query apollo client - const res = await client.query({ - query: SEARCH_ITEMS_QUERY, - variables: { searchTerm: e.target.value }, - }); - this.setState({ - items: res.data.items, - loading: false, - }); - }, 350); - render() { - resetIdCounter(); - return ( - - (item === null ? '' : item.title)}> - {({ getInputProps, getItemProps, isOpen, inputValue, highlightedIndex }) => ( -
- - {client => ( - { - e.persist(); - this.onChange(e, client); - }, - })} - /> - )} - - {isOpen && ( - - {this.state.items.map((item, index) => ( - - {item.title} - {item.title} - - ))} - {!this.state.items.length && - !this.state.loading && Nothing Found {inputValue}} - - )} -
- )} -
-
- ); - } -} - -export default AutoComplete; -- cgit v1.3