diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-09-14 12:18:12 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-09-14 12:18:12 -0400 |
| commit | 2d145b026cfdf54a63bef0b9d6324b6785390307 (patch) | |
| tree | f6c1d8f987437803a5c026e70535bf9ff244e885 /stepped-solutions/FINISHED/frontend/components/Items.js | |
| parent | 8a5825d52271d712ec7c8348447d433067e13ef2 (diff) | |
move finished folder
Diffstat (limited to 'stepped-solutions/FINISHED/frontend/components/Items.js')
| -rw-r--r-- | stepped-solutions/FINISHED/frontend/components/Items.js | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/stepped-solutions/FINISHED/frontend/components/Items.js b/stepped-solutions/FINISHED/frontend/components/Items.js deleted file mode 100644 index 9b5426c..0000000 --- a/stepped-solutions/FINISHED/frontend/components/Items.js +++ /dev/null @@ -1,61 +0,0 @@ -import React, { Component } from 'react'; -import { Query } from 'react-apollo'; -import gql from 'graphql-tag'; -import styled from 'styled-components'; -import Item from './Item'; -import Pagination from './Pagination'; -import { perPage } from '../config'; - -const ALL_ITEMS_QUERY = gql` - query ALL_ITEMS_QUERY($skip: Int = 0, $first: Int = ${perPage}) { - items(first: $first, skip: $skip, orderBy: createdAt_DESC) { - id - title - price - description - image - largeImage - } - } -`; - -const Center = styled.div` - text-align: center; -`; - -const ItemsList = styled.div` - display: grid; - grid-template-columns: 1fr 1fr; - grid-gap: 60px; - max-width: ${props => props.theme.maxWidth}; - margin: 0 auto; -`; - -class Items extends Component { - render() { - return ( - <Center> - <Pagination page={this.props.page} /> - <Query - query={ALL_ITEMS_QUERY} - // fetchPolicy="network-only" - variables={{ - skip: this.props.page * perPage - perPage, - }} - > - {({ data, error, loading }) => { - if (loading) return <p>Loading...</p>; - if (error) return <p>Error: {error.message}</p>; - return ( - <ItemsList>{data.items.map(item => <Item item={item} key={item.id} />)}</ItemsList> - ); - }} - </Query> - <Pagination page={this.props.page} /> - </Center> - ); - } -} - -export default Items; -export { ALL_ITEMS_QUERY }; |
