Connect, collaborate, and grow with a community of TypeScript developers
load mocks locally (#426)
bautistaaaaa696e9f17d1
diff --git a/apps/web/src/app/feature-flag-provider.tsx b/apps/web/src/app/feature-flag-provider.tsxindex c48a0bea..558abf28 100644--- a/apps/web/src/app/feature-flag-provider.tsx+++ b/apps/web/src/app/feature-flag-provider.tsx@@ -6,10 +6,23 @@ export const FeatureFlagContext = createContext<Record<string, boolean>>({});interface Props {children: ReactNode;}++const mockFlags = {+ loginButton: true,+ exploreButton: true,+};++const isProd = process.env.NODE_ENV === 'production';export function FeatureFlagProvider({ children }: Props) {- const { data: featureFlags } = useQuery(['featureFlags'], () =>- fetch('/api/flags').then((res) => res.json()),- );+ const { data: featureFlags } = useQuery(['featureFlags'], () => getFeatureFlags());return <FeatureFlagContext.Provider value={featureFlags}>{children}</FeatureFlagContext.Provider>;}++async function getFeatureFlags() {+ if (isProd) {+ return fetch('/api/flags').then((res) => res.json());+ }++ return mockFlags;+}diff --git a/apps/web/src/components/ui/navigation.tsx b/apps/web/src/components/ui/navigation.tsxindex 71114a73..50d973ee 100644--- a/apps/web/src/components/ui/navigation.tsx+++ b/apps/web/src/components/ui/navigation.tsx@@ -31,7 +31,7 @@ export function Navigation() {}`}><div className="flex w-full items-center justify-between">- <div className="relative flex gap-3">+ <div className="relative flex items-center gap-3"><a className="flex items-center space-x-2 duration-300" href="/"><svgclassName="h-8 w-8 rounded-md bg-[#3178C6] p-[2px]"@@ -70,7 +70,9 @@ export function Navigation() {{featureFlags?.exploreButton ? (<Link href="/explore">- <span className={navigationMenuTriggerStyle()}>Explore</span>+ <div className="hover:text-foreground/80 text-foreground ml-4 transition-colors">+ Explore+ </div></Link>) : null}</div>diff --git a/apps/web/src/middleware.ts b/apps/web/src/middleware.tsindex 71baaa59..fb08d52d 100644--- a/apps/web/src/middleware.ts+++ b/apps/web/src/middleware.ts@@ -1,6 +1,9 @@import { type NextRequest, NextResponse } from 'next/server';export function middleware(req: NextRequest) {+ if (!process.env.VERCEL_ENV) {+ return NextResponse.next();+ }const path = req.nextUrl.pathname;// if path is /explore or /challenge/* and redirect to /waitlist