Last active
October 11, 2020 18:25
-
-
Save AlbionaHoti/6bb59c708db0556cf2b2c4cff756975a to your computer and use it in GitHub Desktop.
webiny-starter-e-commerce-nextjs-stripe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react' | |
// Ant design | |
import { Input } from 'antd' | |
const { Search } = Input | |
import ProductList, { QUERY } from '../components/ProductList' // QUERY -> returns the producst and categories data | |
// Apollo | |
import { initializeApollo } from '../lib/apolloClient' | |
function Home() { | |
const [query, updateQuery] = useState('') | |
return ( | |
<div> | |
<Input.Group> | |
<Search | |
placeholder="Search for products" | |
onSearch={(value) => console.log(value)} | |
style={{ width: 200, margin: '20px 5px' }} | |
onChange={(e) => | |
updateQuery(e.target.value.toLocaleLowerCase()) | |
} | |
value={query} | |
/> | |
</Input.Group> | |
<ProductList search={query} /> | |
</div> | |
) | |
} | |
export async function getStaticProps() { | |
const apolloClient = initializeApollo() | |
await apolloClient.query({ | |
query: QUERY, | |
}) | |
return { | |
props: { | |
initialApolloState: apolloClient.cache.extract(), | |
}, | |
} | |
} | |
export default Home |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment