fixed my test page so quizzes are behind login page

This commit is contained in:
masongga
2026-05-23 19:05:25 -06:00
parent 2ed978197c
commit 9641b120e4
5 changed files with 38 additions and 17 deletions

View File

@@ -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;
}

View File

@@ -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 <AppNav />;
}

View File

@@ -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);
}