Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Fyrlex committed Dec 19, 2023
1 parent 851dc73 commit c964b20
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pages/admin/webshop/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const AdminCreateProducts: NextPage<{
text: 'Product is succesvol aangemaakt!',
});

await router.push('/admin/sponsors/');
await router.push('/admin/webshop/');
}
} catch (error) {
console.error(error);
Expand Down
5 changes: 2 additions & 3 deletions pages/api/stripe/payment_intent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const calculateOrderAmount = async (items: DisplayProduct[], isMember: boolean):
item!.price = (product!.price * item.amount * 0.85) / 100;
} else price += product!.price * item.amount;
}
return price;

return Math.round(price);
};

export default async function paymentIntent(
Expand Down Expand Up @@ -63,8 +64,6 @@ export default async function paymentIntent(
if (member) {
const paymentIntent = await stripe.paymentIntents.update(id!, { amount: await calculateOrderAmount(items, true) });

console.log(items);

res.status(StatusCodes.OK).json({
error: false,
message: getReasonPhrase(StatusCodes.OK),
Expand Down
14 changes: 14 additions & 0 deletions pages/kassa.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ const Checkout: NextPage = () => {
}).catch(console.error);
}, []);

useEffect(() => {
const handleBeforeUnload = (event: BeforeUnloadEvent) => {
const message = 'Are you sure you want to leave this page?';
event.returnValue = message; // Standard for most browsers
return message; // For some older browsers
};

window.addEventListener('beforeunload', handleBeforeUnload);

return () => {
window.removeEventListener('beforeunload', handleBeforeUnload);
};
}, []);

return (
<>
{useMetaData('Kassa', 'Kassa', '/kassa')}
Expand Down

0 comments on commit c964b20

Please sign in to comment.