gendesign/frontend/src/lib/mock-toggle.ts
lekss361 3aaaaba5f9
Some checks failed
Deploy / changes (push) Successful in 6s
Deploy / build-backend (push) Has been skipped
Deploy / deploy (push) Has been skipped
Deploy / build-worker (push) Has been skipped
Deploy / build-frontend (push) Failing after 1m18s
feat(sf-fe-a1): routes shell — entry / analysis + _legacy/ backup + mock toggle (#340)
2026-05-17 22:01:49 +00:00

39 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Mock toggle — controls whether hooks return fixture data or call real backend.
*
* Usage in hooks:
* import { USE_MOCKS, MOCK_PARCELS_BBOX } from "@/lib/mock-toggle";
*
* // Coarse toggle: all mocks on/off
* if (USE_MOCKS) return fixtureParcels;
*
* // Fine-grained: per-endpoint (disable individually as B1-B6 ship to prod)
* if (MOCK_PARCELS_BBOX) return fixtureParcels;
*
* .env.local (dev):
* NEXT_PUBLIC_USE_MOCKS=true
*
* Production: unset or NEXT_PUBLIC_USE_MOCKS=false
*
* TODO: per-hook fine-grained flags below — flip to false as each backend
* endpoint (B1-B6) is confirmed deployed and smoke-tested in prod.
*/
/** Master switch — set NEXT_PUBLIC_USE_MOCKS=true in .env.local for dev */
export const USE_MOCKS = process.env.NEXT_PUBLIC_USE_MOCKS === "true";
/**
* Fine-grained feature flags (all derive from USE_MOCKS initially).
* Flip each to `false` once the corresponding backend endpoint is live.
*
* B1 — GET /api/v1/parcels/by-bbox → used by A2 EntryMap
* B2 — GET /api/v1/users/me/recent-parcels → used by A2 RecentParcels
* B4 — GET /api/v1/landing/stats → used by A12 Landing
* B5 — POST /api/v1/parcels/{cad}/analyze → used by A5A11 sections
* B6 — GET /api/v1/parcels/{cad}/poi-score → used by A5 PoiList2Gis
*/
export const MOCK_PARCELS_BBOX = USE_MOCKS; // B1
export const MOCK_RECENT_PARCELS = USE_MOCKS; // B2
export const MOCK_LANDING_STATS = USE_MOCKS; // B4
export const MOCK_ANALYZE = USE_MOCKS; // B5
export const MOCK_POI_SCORE = USE_MOCKS; // B6