Skip to content

Commit

Permalink
Fixed linting errors preventing compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
TomPadmanathan committed Oct 10, 2023
1 parent ee85457 commit c2dd17b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pages/api/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const config: config = {
},
};

export default async (
const webhookHandler = async (
request: NextApiRequest,
response: NextApiResponse
): Promise<void> => {
Expand Down Expand Up @@ -102,3 +102,4 @@ function createOrder(customer: any, session: stripeSession): void {
});
});
}
export default webhookHandler;
22 changes: 17 additions & 5 deletions pages/checkout/new-checkout-session.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, { useEffect, useState, useContext } from 'react';
import React, { useEffect, useState, useContext, useCallback } from 'react';
import { Appearance, loadStripe, Stripe } from '@stripe/stripe-js';
import { Elements } from '@stripe/react-stripe-js';
import CheckoutForm from '@/components/CheckoutForm';
import { AppContext } from '@/context/AppContext';
import { NextRouter, useRouter } from 'next/router';
import { cart } from '@/interfaces/cart';

const stripePromise: Promise<Stripe | null> = loadStripe(
'pk_test_51NHEXnCgtXcc2Q70RVpnW27B2K9q2NSYP5VA9m7AMjaDpWtpXsVyH8ApqUe3dcoU7iln44Xih7zJgVdOMpTNNv6I00Z3xlQnlO'
Expand All @@ -15,7 +14,20 @@ export default function App() {
const { cart } = useContext(AppContext);
const router: NextRouter = useRouter();

async function fetchData() {
// async function fetchData() {
// const response: Response = await fetch('/api/create-payment-intent', {
// method: 'POST',
// headers: { 'Content-Type': 'application/json' },
// body: JSON.stringify({
// cart: cart,
// userData: JSON.stringify(router.query),
// }),
// });
// const data = await response.json();
// setClientSecret(data.clientSecret);
// }

const fetchData = useCallback(async () => {
const response: Response = await fetch('/api/create-payment-intent', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
Expand All @@ -26,11 +38,11 @@ export default function App() {
});
const data = await response.json();
setClientSecret(data.clientSecret);
}
}, [cart, router.query]);

useEffect((): void => {
if (cart.length > 0 && router.isReady) fetchData();
}, [cart, router.isReady]);
}, [cart, router.isReady, fetchData]);

interface options {
clientSecret: string;
Expand Down

0 comments on commit c2dd17b

Please sign in to comment.