({
children,
}: MainFeedPageProps)
| 15 | import { PlusHeader } from './PlusHeader'; |
| 16 | |
| 17 | export default function PlusLayout({ |
| 18 | children, |
| 19 | }: MainFeedPageProps): ReactElement | null { |
| 20 | const { user, isAuthReady } = useAuthContext(); |
| 21 | const { growthbook } = useGrowthBookContext(); |
| 22 | const router = useRouter(); |
| 23 | const { applyThemeMode } = useSettingsContext(); |
| 24 | |
| 25 | const isPageReady = growthbook?.ready && router?.isReady && isAuthReady; |
| 26 | |
| 27 | const shouldRedirectOnboarding = !user && isPageReady; |
| 28 | |
| 29 | useEffect(() => { |
| 30 | if (!shouldRedirectOnboarding) { |
| 31 | return; |
| 32 | } |
| 33 | |
| 34 | router.push(`${onboardingUrl}`); |
| 35 | }, [router, shouldRedirectOnboarding]); |
| 36 | |
| 37 | useEffect(() => { |
| 38 | applyThemeMode(ThemeMode.Dark); |
| 39 | return () => { |
| 40 | applyThemeMode(); |
| 41 | }; |
| 42 | }, [applyThemeMode]); |
| 43 | |
| 44 | if (!isPageReady || shouldRedirectOnboarding) { |
| 45 | return null; |
| 46 | } |
| 47 | |
| 48 | return ( |
| 49 | <main className="relative flex min-h-dvh flex-col"> |
| 50 | <img |
| 51 | src={cloudinaryPlusBackground} |
| 52 | alt="Plus background" |
| 53 | className="absolute inset-0 -z-1 h-full w-full object-cover" |
| 54 | aria-hidden |
| 55 | /> |
| 56 | <PlusHeader /> |
| 57 | {children} |
| 58 | </main> |
| 59 | ); |
| 60 | } |
| 61 | |
| 62 | // The sale reaches Paddle only through the Plus routes; the onboarding funnel |
| 63 | // mounts its own provider and must stay free of promos. |
nothing calls this directly
no test coverage detected