Skip to content

Instantly share code, notes, and snippets.

@AlbionaHoti
Last active October 11, 2020 18:25
Show Gist options
  • Save AlbionaHoti/6bb59c708db0556cf2b2c4cff756975a to your computer and use it in GitHub Desktop.
Save AlbionaHoti/6bb59c708db0556cf2b2c4cff756975a to your computer and use it in GitHub Desktop.
webiny-starter-e-commerce-nextjs-stripe
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