MCPcopy Create free account
hub / github.com/dailydotdev/apps / PlusLayout

Function PlusLayout

packages/webapp/components/layouts/PlusLayout/PlusLayout.tsx:17–60  ·  view source on GitHub ↗
({
  children,
}: MainFeedPageProps)

Source from the content-addressed store, hash-verified

15import { PlusHeader } from './PlusHeader';
16
17export 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.

Callers

nothing calls this directly

Calls 5

useAuthContextFunction · 0.90
useGrowthBookContextFunction · 0.90
useSettingsContextFunction · 0.90
pushMethod · 0.80
useRouterFunction · 0.50

Tested by

no test coverage detected