forked from mrwyndham/fastpocket
feature - updated schema and tested fe on a new tenant
This commit is contained in:
parent
8fb705b9f0
commit
d154c18a2e
|
@ -22,10 +22,13 @@ export async function apiPrices() {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
const productResponse = await productRequest.json();
|
const productResponse = await productRequest.json();
|
||||||
|
console.log("app/pricing/actions","productResponse",productResponse)
|
||||||
const unsortedProducts: Product[] = productResponse.items;
|
const unsortedProducts: Product[] = productResponse.items;
|
||||||
|
console.log("app/pricing/actions","unsortedProducts",unsortedProducts)
|
||||||
const prices = await pb.collection("price").getFullList<Price>();
|
const prices = await pb.collection("price").getFullList<Price>();
|
||||||
|
console.log("app/pricing/actions","prices",prices)
|
||||||
for (const product of unsortedProducts) {
|
for (const product of unsortedProducts) {
|
||||||
product.metadata.benefits = JSON.parse(product.metadata.benefits as any);
|
product.metadata.benefits = product?.metadata?.benefits ? JSON.parse(product.metadata.benefits as any) : [];
|
||||||
const pricesOfProduct = prices.filter(price => price.product_id === product.product_id);
|
const pricesOfProduct = prices.filter(price => price.product_id === product.product_id);
|
||||||
for (const priceOfProduct of pricesOfProduct){
|
for (const priceOfProduct of pricesOfProduct){
|
||||||
if (priceOfProduct.interval === "year"){
|
if (priceOfProduct.interval === "year"){
|
||||||
|
|
|
@ -15,11 +15,15 @@ export default async function AccountPage() {
|
||||||
!pb.authStore.isValid && redirect("/");
|
!pb.authStore.isValid && redirect("/");
|
||||||
return (
|
return (
|
||||||
user && (
|
user && (
|
||||||
<>
|
<main
|
||||||
|
id="content"
|
||||||
|
role="main"
|
||||||
|
className="h-full flex flex-col min-h-screen mx-auto w-screen overflow-hidden bg-white dark:bg-black"
|
||||||
|
>
|
||||||
<PageHeader title="Account" subtitle={<></>} />
|
<PageHeader title="Account" subtitle={<></>} />
|
||||||
|
|
||||||
<AccountContent user={user} />
|
<AccountContent user={user} />
|
||||||
</>
|
</main>
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ export async function signup(formData: SignUpForm) {
|
||||||
const email = formData.email;
|
const email = formData.email;
|
||||||
const password = formData.password;
|
const password = formData.password;
|
||||||
const organisation = formData.organisation;
|
const organisation = formData.organisation;
|
||||||
|
console.log('app/(auth)/actions', 'organisation', organisation)
|
||||||
const pocketbaseUrl = process.env.NEXT_PUBLIC_POCKETBASE_URL_STRING as string;
|
const pocketbaseUrl = process.env.NEXT_PUBLIC_POCKETBASE_URL_STRING as string;
|
||||||
const adminToken = process.env.NEXT_PUBLIC_POCKETBASE_ADMIN_TOKEN as string;
|
const adminToken = process.env.NEXT_PUBLIC_POCKETBASE_ADMIN_TOKEN as string;
|
||||||
try {
|
try {
|
||||||
|
@ -211,6 +212,8 @@ export async function getSubscriptions() {
|
||||||
pb.authStore.loadFromCookie(cookie?.value || '');
|
pb.authStore.loadFromCookie(cookie?.value || '');
|
||||||
const userId = (pb.authStore.model as User).id
|
const userId = (pb.authStore.model as User).id
|
||||||
const subscriptions = await pb.collection("subscription").getFullList<Subscription>({filter: `user_id="${userId}" && status="active"`});
|
const subscriptions = await pb.collection("subscription").getFullList<Subscription>({filter: `user_id="${userId}" && status="active"`});
|
||||||
|
console.log('here')
|
||||||
|
console.log('app/(auth)/actions', 'subscriptions', subscriptions)
|
||||||
if (subscriptions.length === 0){
|
if (subscriptions.length === 0){
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,18 +29,22 @@ function Header({ isUserLoggedIn }: HeaderProps) {
|
||||||
{!isUserLoggedIn ? (
|
{!isUserLoggedIn ? (
|
||||||
<>
|
<>
|
||||||
<button
|
<button
|
||||||
onClick={() => async (router?: AppRouterInstance) => {
|
onClick={() =>
|
||||||
const authCookie = await getAuthCookie();
|
(async (router?: AppRouterInstance) => {
|
||||||
pb.authStore.loadFromCookie(authCookie || "");
|
console.log("firing");
|
||||||
if (!authCookie || !pb.authStore.isValid) {
|
const authCookie = await getAuthCookie();
|
||||||
document
|
pb.authStore.loadFromCookie(authCookie || "");
|
||||||
.getElementById("sign-in-modal")
|
if (!authCookie || !pb.authStore.isValid) {
|
||||||
?.setAttribute("name", "signIn");
|
console.log("firing");
|
||||||
document.getElementById("sign-in-modal")?.click();
|
document
|
||||||
} else {
|
.getElementById("sign-in-modal")
|
||||||
router?.push("/account");
|
?.setAttribute("name", "signIn");
|
||||||
}
|
document.getElementById("sign-in-modal")?.click();
|
||||||
}}
|
} else {
|
||||||
|
router?.push("/account");
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
}
|
||||||
className={`btn-sm cursor-pointer rounded py-5 w-24 text-primary hover:text-primary/70`}
|
className={`btn-sm cursor-pointer rounded py-5 w-24 text-primary hover:text-primary/70`}
|
||||||
>
|
>
|
||||||
Sign In
|
Sign In
|
||||||
|
|
|
@ -74,17 +74,21 @@ function AccountContent({ user }: ManageSubscriptionProps) {
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
{subscription ? (
|
{/* //TODO: Create Application Component */}
|
||||||
|
{/* {subscription ? (
|
||||||
<div className="max-w-6xl mx-auto h-full w-full py-8 px-6 md:pt-12">
|
<div className="max-w-6xl mx-auto h-full w-full py-8 px-6 md:pt-12">
|
||||||
<div className="flex flex-row justify-between w-full bg-gray-700 p-8 rounded">
|
<div className="flex flex-row justify-between w-full bg-gray-100 dark:bg-gray-700 p-8 rounded">
|
||||||
<div>
|
<div>
|
||||||
<h3 className="font-architects-daughter text-xl text-pink-600 mb-2">
|
<h3 className="font-architects-daughter text-xl text-secondary mb-2">
|
||||||
Get Started
|
Get Started
|
||||||
</h3>
|
</h3>
|
||||||
<ol className="list-decimal ml-6">
|
<ol className="list-decimal ml-6">
|
||||||
<li>
|
<li>
|
||||||
<p className="text-lg text-white">
|
<p className="text-lg text-white">
|
||||||
<a href={downloadApplicationLink} className="text-pink-500">
|
<a
|
||||||
|
href={downloadApplicationLink}
|
||||||
|
className="text-secondary"
|
||||||
|
>
|
||||||
Download the application
|
Download the application
|
||||||
</a>{" "}
|
</a>{" "}
|
||||||
by scanning the QR code
|
by scanning the QR code
|
||||||
|
@ -94,7 +98,7 @@ function AccountContent({ user }: ManageSubscriptionProps) {
|
||||||
<p className="text-lg text-white">
|
<p className="text-lg text-white">
|
||||||
<a
|
<a
|
||||||
href={portalWebsiteTemplatesLink}
|
href={portalWebsiteTemplatesLink}
|
||||||
className="text-pink-500"
|
className="text-secondary"
|
||||||
>
|
>
|
||||||
Upload some PDF
|
Upload some PDF
|
||||||
</a>{" "}
|
</a>{" "}
|
||||||
|
@ -106,7 +110,7 @@ function AccountContent({ user }: ManageSubscriptionProps) {
|
||||||
Setup some{" "}
|
Setup some{" "}
|
||||||
<a
|
<a
|
||||||
href={portalWebsiteIntegrationsLink}
|
href={portalWebsiteIntegrationsLink}
|
||||||
className="text-pink-500"
|
className="text-secondary"
|
||||||
>
|
>
|
||||||
Integrations
|
Integrations
|
||||||
</a>
|
</a>
|
||||||
|
@ -138,35 +142,35 @@ function AccountContent({ user }: ManageSubscriptionProps) {
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<></>
|
<></>
|
||||||
)}
|
)} */}
|
||||||
<div className="max-w-6xl mx-auto mb-2 h-full w-full px-6">
|
<div className="max-w-6xl mx-auto mb-2 h-full w-full px-6">
|
||||||
<div className="w-full bg-gray-700 p-8 rounded">
|
<div className="w-full bg-gray-100 dark:bg-gray-700 p-8 rounded">
|
||||||
<h3 className="font-architects-daughter text-xl text-pink-600 mb-2">
|
<h3 className="font-architects-daughter text-xl text-secondary mb-2">
|
||||||
Your Subscription
|
Your Subscription
|
||||||
</h3>
|
</h3>
|
||||||
{subscription ? (
|
{subscription ? (
|
||||||
<>
|
<>
|
||||||
<h2 className="h2 text-3xl mb-3">
|
<h2 className="h2 text-3xl mb-3 text-base-content">
|
||||||
{subscription?.product?.name}
|
{subscription?.product?.name}
|
||||||
</h2>
|
</h2>
|
||||||
<p className="text-lg text-white mb-4">
|
<p className="text-lg text-base-content mb-4">
|
||||||
{subscription.product?.description}
|
{subscription.product?.description}
|
||||||
</p>
|
</p>
|
||||||
<button
|
<button
|
||||||
onClick={manageSubscription}
|
onClick={manageSubscription}
|
||||||
className="btn text-base capitalize !rounded-md text-white bg-bg-gray-925 hover:bg-gray-900 w-full sm:w-auto mt-8"
|
className="btn text-base capitalize !rounded-md text-base-300 bg-secondary hover:bg-secondary/60 w-full sm:w-auto mt-8"
|
||||||
>
|
>
|
||||||
Manage Subscription
|
Manage Subscription
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<p className="text-lg text-white mb-4">
|
<p className="text-lg text-base-content mb-4">
|
||||||
{"You haven’t upgraded your workflow yet"}
|
{"You haven’t upgraded your workflow yet"}
|
||||||
</p>
|
</p>
|
||||||
<button
|
<button
|
||||||
onClick={() => router.push("/pricing")}
|
onClick={() => router.push("/pricing")}
|
||||||
className="px-10 py-2 text-base capitalize !rounded-3xl text-white bg-gradient-to-r from-primary to-secondary hover:bg-gray-900 w-full sm:w-auto"
|
className="px-10 py-2 text-base capitalize !rounded-3xl text-base-content bg-gradient-to-r from-primary to-secondary hover:bg-gray-900 w-full sm:w-auto"
|
||||||
>
|
>
|
||||||
Upgrade
|
Upgrade
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -10,6 +10,7 @@ import SuccessModal from "@/sections/SuccessModal";
|
||||||
import LoadingModal from "@/sections/LoadingModal";
|
import LoadingModal from "@/sections/LoadingModal";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { ModalStatus } from "@/types";
|
import { ModalStatus } from "@/types";
|
||||||
|
import Icon from "@/components/icon";
|
||||||
|
|
||||||
function ModalSignIn() {
|
function ModalSignIn() {
|
||||||
const [status, setStatus] = useState<ModalStatus>(ModalStatus.Default);
|
const [status, setStatus] = useState<ModalStatus>(ModalStatus.Default);
|
||||||
|
@ -31,18 +32,14 @@ function ModalSignIn() {
|
||||||
onChange={whenModalOpens}
|
onChange={whenModalOpens}
|
||||||
/>
|
/>
|
||||||
<label htmlFor="sign-in-modal" className="modal cursor-pointer">
|
<label htmlFor="sign-in-modal" className="modal cursor-pointer">
|
||||||
<label className="modal-box relative bg-gray-850 max-w-full md:max-w-[550px] py-4 px-3 md:p-6">
|
<label className="modal-box relative bg-gray-100 dark:bg-gray-850 max-w-full md:max-w-[550px] py-4 px-3 md:p-6">
|
||||||
<div className="flex justify-end pb-2 select-none">
|
<div className="flex justify-end pb-2 select-none">
|
||||||
<label
|
<label
|
||||||
onClick={handleCloseModal}
|
onClick={handleCloseModal}
|
||||||
htmlFor="sign-in-modal"
|
htmlFor="sign-in-modal"
|
||||||
className="cursor-pointer"
|
className="cursor-pointer"
|
||||||
>
|
>
|
||||||
<Image
|
<Icon name="Dismiss20Filled" size="medium" />
|
||||||
className="rounded-full p-1 hover:bg-gray-500"
|
|
||||||
src={xButton}
|
|
||||||
alt={""}
|
|
||||||
/>
|
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div className={status === ModalStatus.Default ? "block" : "hidden"}>
|
<div className={status === ModalStatus.Default ? "block" : "hidden"}>
|
||||||
|
|
|
@ -73,7 +73,7 @@ const ModalSignInForm = forwardRef<FormRefMethods, ModalSignInFormProps>(
|
||||||
{...register("email")}
|
{...register("email")}
|
||||||
id="SignInEmail"
|
id="SignInEmail"
|
||||||
type="text"
|
type="text"
|
||||||
className="w-full appearance-none bg-transparent border border-white focus:border-white rounded-sm px-4 mr-2 text-white placeholder-white"
|
className="w-full appearance-none bg-transparent border rounded-sm px-4 mr-2 text-black placeholder-black border-black dark:text-white dark:placeholder-white dark:border-white"
|
||||||
placeholder="Your email…"
|
placeholder="Your email…"
|
||||||
aria-label="Your email…"
|
aria-label="Your email…"
|
||||||
autoComplete="on"
|
autoComplete="on"
|
||||||
|
@ -90,7 +90,7 @@ const ModalSignInForm = forwardRef<FormRefMethods, ModalSignInFormProps>(
|
||||||
{...register("password")}
|
{...register("password")}
|
||||||
id="SignInPwd"
|
id="SignInPwd"
|
||||||
type="password"
|
type="password"
|
||||||
className="w-full appearance-none bg-transparent border border-white focus:border-white rounded-sm px-4 mr-2 text-white placeholder-white"
|
className="w-full appearance-none bg-transparent border rounded-sm px-4 mr-2 text-black placeholder-black border-black dark:text-white dark:placeholder-white dark:border-white"
|
||||||
placeholder="Your password..."
|
placeholder="Your password..."
|
||||||
aria-label="Your password..."
|
aria-label="Your password..."
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -10,6 +10,7 @@ import LoadingModal from "@/sections/LoadingModal";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { ModalStatus } from "@/types";
|
import { ModalStatus } from "@/types";
|
||||||
import { FormRefMethods } from "../ModalSignIn/ModalSignInForm";
|
import { FormRefMethods } from "../ModalSignIn/ModalSignInForm";
|
||||||
|
import Icon from "@/components/icon";
|
||||||
|
|
||||||
function ModalSignUp() {
|
function ModalSignUp() {
|
||||||
const [status, setStatus] = useState<ModalStatus>(ModalStatus.Default);
|
const [status, setStatus] = useState<ModalStatus>(ModalStatus.Default);
|
||||||
|
@ -40,11 +41,7 @@ function ModalSignUp() {
|
||||||
htmlFor="sign-up-modal"
|
htmlFor="sign-up-modal"
|
||||||
className="cursor-pointer"
|
className="cursor-pointer"
|
||||||
>
|
>
|
||||||
<Image
|
<Icon name="Dismiss20Filled" size="medium" />
|
||||||
className="rounded-full p-1 hover:bg-gray-500"
|
|
||||||
src={xButton}
|
|
||||||
alt="image"
|
|
||||||
/>
|
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div className={status === ModalStatus.Default ? "block" : "hidden"}>
|
<div className={status === ModalStatus.Default ? "block" : "hidden"}>
|
||||||
|
|
Loading…
Reference in New Issue