Created
September 27, 2019 00:47
-
-
Save dapperAuteur/ce45192b1f858049aca5490327cb4f7d to your computer and use it in GitHub Desktop.
stripe skus
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, { Component } from "react" | |
import { graphql, StaticQuery } from "gatsby" | |
import SkuCard from "./SkuCard" | |
const containerStyles = { | |
display: "flex", | |
flexDirection: "row", | |
flexWrap: "wrap", | |
justifyContent: "space-between", | |
padding: "1rem 0 1rem 0", | |
} | |
class Skus extends Component { | |
state = { | |
stripe: null, | |
} | |
componentDidMount() { | |
const stripe = window.Stripe(process.env.GATSBY_STRIPE_PUBLIC_KEY) | |
this.setState({ stripe }) | |
console.log("stripe", stripe) | |
} | |
render() { | |
return ( | |
<StaticQuery | |
query={graphql` | |
query SkusForProduct { | |
skus: allStripeSku { | |
edges { | |
node { | |
id | |
currency | |
price | |
attributes { | |
name | |
} | |
} | |
} | |
} | |
} | |
`} | |
render={({ skus }) => ( | |
<div style={containerStyles}> | |
{skus.edges.map(({ node: sku }) => { | |
console.log("skus", skus) | |
return ( | |
<SkuCard key={sku.id} sku={sku} stripe={this.state.stripe} /> | |
) | |
})} | |
</div> | |
)} | |
/> | |
) | |
} | |
} | |
export default Skus |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment