From 9641b120e4a4f4551653b603162f83a9f0cfaced Mon Sep 17 00:00:00 2001 From: masongga Date: Sat, 23 May 2026 19:05:25 -0600 Subject: [PATCH] fixed my test page so quizzes are behind login page --- app/{ => (app)}/daily/quiz/page.tsx | 0 app/{ => (app)}/habits/page.tsx | 0 components/layout/app-auth-gate.tsx | 5 +++- components/layout/global-bottom-nav.tsx | 33 +++++++++++++++++++++++++ lib/routes.ts | 17 +------------ 5 files changed, 38 insertions(+), 17 deletions(-) rename app/{ => (app)}/daily/quiz/page.tsx (100%) rename app/{ => (app)}/habits/page.tsx (100%) diff --git a/app/daily/quiz/page.tsx b/app/(app)/daily/quiz/page.tsx similarity index 100% rename from app/daily/quiz/page.tsx rename to app/(app)/daily/quiz/page.tsx diff --git a/app/habits/page.tsx b/app/(app)/habits/page.tsx similarity index 100% rename from app/habits/page.tsx rename to app/(app)/habits/page.tsx diff --git a/components/layout/app-auth-gate.tsx b/components/layout/app-auth-gate.tsx index 7f466f5..9d3931c 100644 --- a/components/layout/app-auth-gate.tsx +++ b/components/layout/app-auth-gate.tsx @@ -1,7 +1,10 @@ +import { requireOnboardingComplete } from "@/lib/auth-helpers"; + type AppAuthGateProps = { children: React.ReactNode; }; + export async function AppAuthGate({ children }: AppAuthGateProps) { - // Temporary: allow guest access while testing app pages from the bottom nav. + await requireOnboardingComplete(); return children; } diff --git a/components/layout/global-bottom-nav.tsx b/components/layout/global-bottom-nav.tsx index 23bb5c2..a380b89 100644 --- a/components/layout/global-bottom-nav.tsx +++ b/components/layout/global-bottom-nav.tsx @@ -1,7 +1,40 @@ "use client"; +import { useEffect, useState } from "react"; + import { AppNav } from "@/components/layout/app-nav"; +import { createClient } from "@/lib/supabase/client"; export function GlobalBottomNav() { + const [showNav, setShowNav] = useState(false); + + useEffect(() => { + const supabase = createClient(); + + async function syncNavState() { + const { + data: { user }, + } = await supabase.auth.getUser(); + + setShowNav( + !!user && user.user_metadata?.onboarding_completed === true, + ); + } + + void syncNavState(); + + const { + data: { subscription }, + } = supabase.auth.onAuthStateChange(() => { + void syncNavState(); + }); + + return () => subscription.unsubscribe(); + }, []); + + if (!showNav) { + return null; + } + return ; } diff --git a/lib/routes.ts b/lib/routes.ts index 06055f6..905eefd 100644 --- a/lib/routes.ts +++ b/lib/routes.ts @@ -23,25 +23,10 @@ export const appNavItems = [ export type NavItem = (typeof appNavItems)[number]; -const appPaths = [ - routes.avatar, - routes.habits, - routes.dailyQuiz, - routes.shop, - routes.profile, - routes.onboardingQuiz, -] as const; - export function isAuthPath(pathname: string) { return pathname.startsWith("/auth"); } export function isPublicPath(pathname: string) { - return ( - pathname === routes.home || - isAuthPath(pathname) || - appPaths.some( - (path) => pathname === path || pathname.startsWith(`${path}/`), - ) - ); + return pathname === routes.home || isAuthPath(pathname); }