forked from mrwyndham/fastpocket
feature - added purchase intent
This commit is contained in:
parent
a83a6d64c0
commit
fb64f6bcd6
Binary file not shown.
|
@ -149,9 +149,7 @@
|
|||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize":5242880
|
||||
}
|
||||
"options": {}
|
||||
}
|
||||
],
|
||||
"indexes": [
|
||||
|
@ -244,9 +242,7 @@
|
|||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize":5242880
|
||||
}
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
|
@ -533,9 +529,7 @@
|
|||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize":5242880
|
||||
}
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
|
|
|
@ -119,6 +119,7 @@ function PriceCard({
|
|||
if (userIsAuthenticated) {
|
||||
await generateCheckoutPage(price);
|
||||
} else {
|
||||
localStorage.setItem("price", JSON.stringify(price));
|
||||
openSignUpModalOnPriceClick(price);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
"use client";
|
||||
import HeroHome from "@/sections/HeroHome";
|
||||
import FeaturesBlocks from "@/sections/FeaturesBlocks";
|
||||
import FeaturesZigZag from "@/sections/FeaturesZigzag";
|
||||
import Newsletter from "@/sections/Newsletter/Newsletter";
|
||||
import HeroVideo from "@/sections/Video";
|
||||
import Aos from "aos";
|
||||
import "aos/dist/aos.css";
|
||||
import { useEffect } from "react";
|
||||
import React from "react";
|
||||
import { SourceModal } from "@/types";
|
||||
|
||||
export default function Home() {
|
||||
useEffect(() => {
|
||||
Aos.init({
|
||||
delay: 50,
|
||||
easing: "ease-out-cubic",
|
||||
once: true,
|
||||
offset: 50,
|
||||
});
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
document
|
||||
.getElementById("sign-up-modal")
|
||||
?.setAttribute("name", SourceModal.SignUp);
|
||||
document.getElementById("sign-up-modal")?.removeAttribute("price_id");
|
||||
document.getElementById("sign-up-modal")?.click();
|
||||
}, []);
|
||||
return (
|
||||
<>
|
||||
{/* Page sections */}
|
||||
<HeroHome />
|
||||
<HeroVideo />
|
||||
<FeaturesBlocks />
|
||||
<FeaturesZigZag />
|
||||
<Newsletter />
|
||||
</>
|
||||
);
|
||||
}
|
|
@ -102,6 +102,7 @@ export default function Header({ isUserLoggedIn }: HeaderProps) {
|
|||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
localStorage.removeItem("price");
|
||||
document
|
||||
.getElementById("sign-up-modal")
|
||||
?.setAttribute("name", SourceModal.SignUp);
|
||||
|
|
|
@ -5,7 +5,10 @@ import { yupResolver } from "@hookform/resolvers/yup";
|
|||
import { signUpValidationSchema } from "@/utils/form";
|
||||
import { companySizeList } from "@/constants";
|
||||
import pb from "@/lib/pocketbase";
|
||||
import { login } from "@/app/(auth)/actions";
|
||||
import { createCheckoutSession, login } from "@/app/(auth)/actions";
|
||||
import { toast } from "react-toastify";
|
||||
import { Price } from "@/types";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
function ModalSignUp() {
|
||||
const {
|
||||
|
@ -16,6 +19,29 @@ function ModalSignUp() {
|
|||
} = useForm({
|
||||
resolver: yupResolver(signUpValidationSchema),
|
||||
});
|
||||
const router = useRouter();
|
||||
const generateCheckoutPage = async (price: Price) => {
|
||||
try {
|
||||
const checkoutSessionResponse = await createCheckoutSession(
|
||||
price.price_id
|
||||
);
|
||||
console.log(checkoutSessionResponse);
|
||||
router.push(checkoutSessionResponse.url);
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
toast.error(error.message, {
|
||||
position: "bottom-left",
|
||||
autoClose: 5000,
|
||||
hideProgressBar: false,
|
||||
closeOnClick: true,
|
||||
pauseOnHover: true,
|
||||
draggable: true,
|
||||
progress: undefined,
|
||||
theme: "colored",
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
const onSubmit = async (data: any) => {
|
||||
data = {
|
||||
emailVisibility: false,
|
||||
|
@ -40,6 +66,8 @@ function ModalSignUp() {
|
|||
) {
|
||||
reset();
|
||||
document.getElementById("sign-up-modal")?.click();
|
||||
const price = localStorage.getItem("price");
|
||||
price && generateCheckoutPage(JSON.parse(price));
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("heyaa");
|
||||
|
|
Loading…
Reference in New Issue