Created
January 28, 2019 18:42
-
-
Save ryanflorence/0a2502fa4eaccdc4d2d811466e3ce214 to your computer and use it in GitHub Desktop.
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, { useEffect } from "react" | |
import useFetch from "./useFetch" | |
export default function ProcessingPurchase({ | |
send, | |
context: { workshopData, ticketsToPurchase, stripeToken } | |
}) { | |
let [charge, error] = useFetch("/purchaseWorkshop", { | |
workshopId: workshopData.id, | |
ticketsToPurchase, | |
stripeTokenId: stripeToken.id, | |
stripeEmail: stripeToken.email | |
}) | |
useEffect( | |
() => { | |
if (charge) { | |
send({ type: "SUCCESS", payload: charge }) | |
} else if (error) { | |
send({ type: "ERROR", payload: error }) | |
} | |
}, | |
[charge, error] | |
) | |
return <div>Processing Purchase</div> | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment