Created
June 10, 2021 16:12
-
-
Save OzzyTheGiant/61a5f25aa4580a589d3052eb20142d28 to your computer and use it in GitHub Desktop.
Home page for sample Shopify app
This file contains hidden or 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 { useState } from 'react' | |
import { EmptyState, Layout, Page } from '@shopify/polaris' | |
import { ResourcePicker } from '@shopify/app-bridge-react' | |
const MAIN_IMAGE = "https://cdn.shopify.com/s/files/1/0262/4071/2726/files/emptystate-files.png" | |
function Index() { | |
// State | |
const [modal, setModal] = useState({ open: false }) | |
// Methods | |
const openModal = () => setModal({ open: true }) | |
const closeModal = () => setModal({ open: false }) | |
const handleSelection = (resources) => { | |
this.setState({ open: false }); | |
console.log(resources); | |
}; | |
return ( | |
<Page> | |
<ResourcePicker | |
resourceType="Product" | |
showVariants={false} | |
open={modal.open} | |
onSelection={handleSelection} | |
onCancel={closeModal}/> | |
<Layout> | |
<EmptyState | |
heading="Manage your inventory transfers" | |
action={{ content: 'Select Products', onAction: openModal }} | |
secondaryAction={{ content: 'Learn More', url: 'https://help.shopify.com' }} | |
image={MAIN_IMAGE}> | |
<p>Select products</p> | |
</EmptyState> | |
</Layout> | |
</Page> | |
) | |
} | |
export default Index |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment