function handleBuy(product_id) {
console.log("handle buy: ", product_id);
// Handle Paddle
try {
new Paddle.Checkout.open({
product: product_id,
email: user ? user.email : "", // Replace 'user.email' with actual user email
passthrough: "1",
successCallback: function (data) {
// Redirect to dashboard after successful purchase
router.push("/dashboard");
},
closeCallback: function () {
// Handle checkout close event
setIsLoading(false); // Update loading state if needed
},
});
} catch (error) {
console.error(error);
}
}