diff --git a/app/main.wasp b/app/main.wasp index 7ce6035..3f59068 100644 --- a/app/main.wasp +++ b/app/main.wasp @@ -87,8 +87,9 @@ entity User {=psl createdAt DateTime @default(now()) lastActiveTimestamp DateTime @default(now()) isAdmin Boolean @default(false) - hasAcceptedTos Boolean @default(true) - hasSubscribedToMarketingEmails Boolean @default(true) + hasAcceptedTos Boolean @default(false) + hasSubscribedToMarketingEmails Boolean @default(false) + isSignUpComplete Boolean @default(false) stripeId String? checkoutSessionId String? hasPaid Boolean @default(false) @@ -200,10 +201,10 @@ page LoginPage { component: import Login from "@src/client/auth/LoginPage" } -route SignupRoute { path: "/signup", to: SignupPage } -page SignupPage { - component: import { Signup } from "@src/client/auth/SignupPage" -} +// route SignupRoute { path: "/signup", to: SignupPage } +// page SignupPage { +// component: import { Signup } from "@src/client/auth/SignupPage" +// } route TocPageRoute { path: "/toc", to: TocPage } page TocPage { diff --git a/app/migrations/20240408050407_add_column_to_store_signup_complete_status/migration.sql b/app/migrations/20240408050407_add_column_to_store_signup_complete_status/migration.sql new file mode 100644 index 0000000..8762276 --- /dev/null +++ b/app/migrations/20240408050407_add_column_to_store_signup_complete_status/migration.sql @@ -0,0 +1,4 @@ +-- AlterTable +ALTER TABLE "User" ADD COLUMN "isSignUpComplete" BOOLEAN NOT NULL DEFAULT false, +ALTER COLUMN "hasAcceptedTos" SET DEFAULT false, +ALTER COLUMN "hasSubscribedToMarketingEmails" SET DEFAULT false; diff --git a/app/src/client/App.tsx b/app/src/client/App.tsx index e596311..7f4496e 100644 --- a/app/src/client/App.tsx +++ b/app/src/client/App.tsx @@ -4,7 +4,8 @@ import './Main.css'; import AppNavBar from './components/AppNavBar'; import ServerNotRechableComponent from './components/ServerNotRechableComponent'; import LoadingComponent from './components/LoadingComponent'; -import { useMemo, useEffect, ReactNode } from 'react'; +import TosAndMarketingEmailsModal from './components/TosAndMarketingEmailsModal'; +import { useMemo, useEffect, ReactNode, useState } from 'react'; import { useLocation } from 'react-router-dom'; const addServerErrorClass = () => { @@ -25,6 +26,8 @@ const removeServerErrorClass = () => { */ export default function App({ children }: { children: ReactNode }) { const location = useLocation(); + const [showTosAndMarketingEmailsModal, setShowTosAndMarketingEmailsModal] = + useState(false); const { data: user, isError, isLoading } = useAuth(); const shouldDisplayAppNavBar = useMemo(() => { @@ -43,12 +46,45 @@ export default function App({ children }: { children: ReactNode }) { return location.pathname.startsWith('/chat'); }, [location]); + const isCheckoutPage = useMemo(() => { + return location.pathname.startsWith('/checkout'); + }, [location]); + + const isAccountPage = useMemo(() => { + return location.pathname.startsWith('/account'); + }, [location]); + useEffect(() => { if (user) { - const lastSeenAt = new Date(user.lastActiveTimestamp); - const today = new Date(); - if (today.getTime() - lastSeenAt.getTime() > 5 * 60 * 1000) { - updateCurrentUser({ lastActiveTimestamp: today }); + if (!user.isSignUpComplete) { + if (user.hasAcceptedTos && user.hasSubscribedToMarketingEmails) { + updateCurrentUser({ + isSignUpComplete: true, + }); + setShowTosAndMarketingEmailsModal(false); + } else { + const hasAcceptedTos = + localStorage.getItem('hasAcceptedTos') === 'true'; + const hasSubscribedToMarketingEmails = + localStorage.getItem('hasSubscribedToMarketingEmails') === 'true'; + if (!hasAcceptedTos || !hasSubscribedToMarketingEmails) { + setShowTosAndMarketingEmailsModal(true); + } else { + updateCurrentUser({ + isSignUpComplete: true, + hasAcceptedTos: true, + hasSubscribedToMarketingEmails: true, + }); + setShowTosAndMarketingEmailsModal(false); + } + } + } else { + setShowTosAndMarketingEmailsModal(false); + const lastSeenAt = new Date(user.lastActiveTimestamp); + const today = new Date(); + if (today.getTime() - lastSeenAt.getTime() > 5 * 60 * 1000) { + updateCurrentUser({ lastActiveTimestamp: today }); + } } } }, [user]); @@ -68,17 +104,33 @@ export default function App({ children }: { children: ReactNode }) {
{title}
+{loginFlow}
+ Before accessing the application, please confirm your agreement to + the Terms & Conditions, Privacy Policy, and consent to receiving + marketing emails by checking the boxes below +
+