Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Fyrlex committed Sep 28, 2023
1 parent 9d92b1a commit 690a218
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 112 deletions.
103 changes: 0 additions & 103 deletions components/ShoppingCartItem.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions lib/hooks/useLocalStorage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export const useLocalStorage = <T extends object,>(key: string, initialValue: T)
const index = (storedValue as []).findIndex((o: DisplayProduct) => o.name === (value as DisplayProduct).name);

if (index !== -1) {
if ((value as DisplayProduct).stock === 0) return undefined;
if ((value as DisplayProduct).amount + (storedValue as DisplayProduct[])[index].amount > (value as DisplayProduct).stock) return undefined;
// if ((value as DisplayProduct).stock === 0) return undefined;
// if ((value as DisplayProduct).amount + (storedValue as DisplayProduct[])[index].amount > (value as DisplayProduct).stock) return undefined;
if ((value as DisplayProduct).amount + (storedValue as DisplayProduct[])[index].amount < 0) return undefined;
setStoredValue((storedValue as DisplayProduct[]).filter(p => p.name !== (value as DisplayProduct).name) as SetStateAction<T>);
const amount = (storedValue as DisplayProduct[])[index].amount + (value as DisplayProduct).amount;
Expand Down
2 changes: 1 addition & 1 deletion pages/api/products/[product_id].ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import dbConnect from '../../../src/util/dbConnect';
import { ironOptions } from '../../../src/util/ironConfig';
import { Stripe } from 'stripe';

const stripe = new Stripe(process.env.NEXT_STRIPE_SECRET_KEY, {
const stripe = new Stripe(process.env.NEXT_PUBLIC_STRIPE_SECRET_KEY, {
apiVersion: '2022-11-15',
});

Expand Down
2 changes: 1 addition & 1 deletion pages/api/products/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import dbConnect from '../../../src/util/dbConnect';
import { ironOptions } from '../../../src/util/ironConfig';
import { Stripe } from 'stripe';

const stripe = new Stripe(process.env.NEXT_STRIPE_SECRET_KEY, {
const stripe = new Stripe(process.env.NEXT_PUBLIC_STRIPE_SECRET_KEY, {
apiVersion: '2022-11-15',
});

Expand Down
6 changes: 3 additions & 3 deletions pages/api/stripe/customer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { NextApiRequest, NextApiResponse } from 'next';
import dbConnect from '../../../src/util/dbConnect';
import { Stripe } from 'stripe';

const stripe = new Stripe(process.env.NEXT_STRIPE_SECRET_KEY, {
const stripe = new Stripe(process.env.NEXT_PUBLIC_STRIPE_SECRET_KEY, {
apiVersion: '2022-11-15',
});

Expand All @@ -16,8 +16,8 @@ interface Body {
name: string;
email: string;
payment_intent: string;
}
}
};
};
}

export default async function customerHandler(
Expand Down
4 changes: 2 additions & 2 deletions pages/api/stripe/orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { Stripe } from 'stripe';
import { withIronSessionApiRoute } from 'iron-session/next';
import { ironOptions } from '../../../src/util/ironConfig';

const stripe = new Stripe(process.env.NEXT_STRIPE_SECRET_KEY, {
const stripe = new Stripe(process.env.NEXT_PUBLIC_STRIPE_SECRET_KEY, {
apiVersion: '2022-11-15',
});

dbConnect();

export default withIronSessionApiRoute(async function paymentHandler(
req: Omit<NextApiRequest, 'body'> & { body: Body },
req: Omit<NextApiRequest, 'body'> & { body: Body; },
res: NextApiResponse<ResponseData<Stripe.PaymentIntent[]>>,
): Promise<void> {
switch (req.method) {
Expand Down

0 comments on commit 690a218

Please sign in to comment.