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,
|
"required": false,
|
||||||
"presentable": false,
|
"presentable": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"options": {
|
"options": {}
|
||||||
"maxSize":5242880
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"indexes": [
|
"indexes": [
|
||||||
|
@ -244,9 +242,7 @@
|
||||||
"required": false,
|
"required": false,
|
||||||
"presentable": false,
|
"presentable": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"options": {
|
"options": {}
|
||||||
"maxSize":5242880
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
|
@ -533,9 +529,7 @@
|
||||||
"required": false,
|
"required": false,
|
||||||
"presentable": false,
|
"presentable": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"options": {
|
"options": {}
|
||||||
"maxSize":5242880
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
|
|
|
@ -119,6 +119,7 @@ function PriceCard({
|
||||||
if (userIsAuthenticated) {
|
if (userIsAuthenticated) {
|
||||||
await generateCheckoutPage(price);
|
await generateCheckoutPage(price);
|
||||||
} else {
|
} else {
|
||||||
|
localStorage.setItem("price", JSON.stringify(price));
|
||||||
openSignUpModalOnPriceClick(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>
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
localStorage.removeItem("price");
|
||||||
document
|
document
|
||||||
.getElementById("sign-up-modal")
|
.getElementById("sign-up-modal")
|
||||||
?.setAttribute("name", SourceModal.SignUp);
|
?.setAttribute("name", SourceModal.SignUp);
|
||||||
|
|
|
@ -5,7 +5,10 @@ import { yupResolver } from "@hookform/resolvers/yup";
|
||||||
import { signUpValidationSchema } from "@/utils/form";
|
import { signUpValidationSchema } from "@/utils/form";
|
||||||
import { companySizeList } from "@/constants";
|
import { companySizeList } from "@/constants";
|
||||||
import pb from "@/lib/pocketbase";
|
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() {
|
function ModalSignUp() {
|
||||||
const {
|
const {
|
||||||
|
@ -16,6 +19,29 @@ function ModalSignUp() {
|
||||||
} = useForm({
|
} = useForm({
|
||||||
resolver: yupResolver(signUpValidationSchema),
|
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) => {
|
const onSubmit = async (data: any) => {
|
||||||
data = {
|
data = {
|
||||||
emailVisibility: false,
|
emailVisibility: false,
|
||||||
|
@ -40,6 +66,8 @@ function ModalSignUp() {
|
||||||
) {
|
) {
|
||||||
reset();
|
reset();
|
||||||
document.getElementById("sign-up-modal")?.click();
|
document.getElementById("sign-up-modal")?.click();
|
||||||
|
const price = localStorage.getItem("price");
|
||||||
|
price && generateCheckoutPage(JSON.parse(price));
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("heyaa");
|
console.log("heyaa");
|
||||||
|
|
Loading…
Reference in New Issue