bugfix - fixed button press issue

This commit is contained in:
James Wyndham 2024-02-29 09:05:02 +08:00
parent afa4040243
commit 4d98a54da4
5 changed files with 24 additions and 11 deletions

View File

@ -188,6 +188,16 @@ export async function createCheckoutSession(price_id: string, type: string) {
}
console.log('token', token);
console.log('url ', `${pocketbaseUrl}/create-checkout-session`);
const body = JSON.stringify({
price: {
id: price_id,
type: type
},
quantity: 1
});
console.log('body',body);
try{
const createCheckoutSessionResponse = await fetch(
`${pocketbaseUrl}/create-checkout-session`,
@ -197,20 +207,18 @@ export async function createCheckoutSession(price_id: string, type: string) {
"Content-Type": "application/json",
Authorization: token,
},
body: JSON.stringify({
price: {
id: price_id,
type: type
},
quantity: 1
}),
body: body,
}
);
console.log('createCheckoutSessionResponse.status', createCheckoutSessionResponse.status)
if (createCheckoutSessionResponse.status !== 200) {
throw new Error("Failed to process Request");
}
const createCheckoutSessionData: CheckoutSession = await createCheckoutSessionResponse.json();
if (createCheckoutSessionData.url === "") {
throw new Error("Failed to process request an invalid URL was served");
}
return createCheckoutSessionData;
} catch (error) {
throw error;

View File

@ -112,6 +112,7 @@ export default function Header({ isUserLoggedIn }: HeaderProps) {
document.getElementById("sign-up-modal")?.click();
}}
className={`btn btn-primary btn-sm text-primary-content`}
id="sign-up-modal-button"
>
Sign Up
</button>

View File

@ -1,3 +1,5 @@
"use client";
import { Price, Product, SourceModal } from "@/types";
import { createCheckoutSession, isAuthenticated } from "@/app/(auth)/actions";
import { toast } from "react-toastify";
@ -15,7 +17,7 @@ export default function PriceCard({
}) {
const router = useRouter();
const openSignUpModalOnPriceClick = (price: Price, type: string) => {
const signUpModal = document.getElementById("sign-up-modal");
const signUpModal = document.getElementById("sign-up-modal-button");
if (!signUpModal) return;
signUpModal.setAttribute("price_id", price.price_id);
signUpModal.setAttribute("type", type);
@ -28,6 +30,7 @@ export default function PriceCard({
price.price_id,
type
);
console.log(checkoutSessionResponse);
router.push(checkoutSessionResponse.url);
} catch (error) {
if (error instanceof Error) {
@ -46,6 +49,7 @@ export default function PriceCard({
};
const submitForm = async (product: Product) => {
const userIsAuthenticated = await isAuthenticated();
console.log("userIsAuthenticated", userIsAuthenticated);
const price = isAnnual ? product.yearlyPrice : product.monthlyPrice;
if (userIsAuthenticated) {
await generateCheckoutPage(price, product.type);

View File

@ -174,7 +174,7 @@ function AccountContent({ user }: ManageSubscriptionProps) {
</button>
<button
onClick={manageSubscription}
className="btn btn-neutral text-base-content capitalize border-none"
className="btn btn-neutral text-primary-content capitalize border-none"
>
Manage Purchases
</button>

View File

@ -45,7 +45,7 @@ const WaitingListWithImageHero = () => {
return (
<Background>
<div className="h-screen w-full bg-clip flex items-center justify-center">
<div className="text-center py-8 px-4 sm:px-6 lg:px-8 bg-base-300 rounded-xl shadow-lg">
<div className="text-center py-8 px-4 sm:px-6 lg:px-8 bg-base-100 rounded-xl shadow-lg">
<h1 className=" text-3xl sm:text-6xl text-base-content font-heading whitespace-nowrap flex flex-row justify-center pb-6 gap-x-3">
<Logo />
{title}