fix form and show links

This commit is contained in:
Paul Miller
2022-03-22 08:27:51 -05:00
parent c8f2f28920
commit 232a5fc49d
2 changed files with 29 additions and 5 deletions

View File

@@ -11,12 +11,14 @@ const DonationSteps = () => {
setDeductable(event.target.value);
};
function handleStep1() {
function handleStep1(e: React.FormEvent<HTMLInputElement>) {
e.preventDefault();
setStep(2);
}
// STEP 2
function handleStep2() {
function handleStep2(e: React.FormEvent<HTMLInputElement>) {
e.preventDefault();
setStep(3);
}

View File

@@ -4,14 +4,36 @@ import { fetchPostJSON } from "../utils/api-helpers";
const Pay = ({ amount = 100.0 }) => {
// const [stripeUrl, setStripeUrl] = useState("");
const [btcpayUrl, setBtcPayUrl] = useState("");
const { data: stripe } = useSWR(
const { data: stripe, error: stripeError } = useSWR(
["/api/stripe_checkout", { amount }],
fetchPostJSON
);
return <p>{stripe && stripe.url}</p>;
const { data: btcpay, error: btcpayError } = useSWR(
["/api/btcpay", { amount }],
fetchPostJSON
);
console.log(btcpayError);
return (
<div>
{stripe?.url && (
<p>
<a href={stripe.url}>Pay with card</a>
</p>
)}
{stripeError && <mark>heyo</mark>}
<mark>Error: {stripeError?.message}</mark>
{btcpay?.url && (
<p>
<a href={btcpay.url}>Pay with Bitcoin</a>
</p>
)}
<mark>Error: {btcpayError}</mark>
</div>
);
};
export default Pay;