feat(web): residential_projects feature flag for /du-an routes (TEC-2757)
- Add useResidentialProjectsFlag hook with NEXT_PUBLIC_FEATURE_RESIDENTIAL_PROJECTS env + URL/localStorage override (mirrors AVM v2 pattern) - Gate /du-an index (client) and /du-an/[slug] detail (server) routes via notFound() when flag disabled - Add component tests for index page including disabled-flag notFound branch Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { Building2, LayoutGrid, List, Map, MapPin } from 'lucide-react';
|
||||
import dynamic from 'next/dynamic';
|
||||
import Image from 'next/image';
|
||||
import { notFound } from 'next/navigation';
|
||||
import * as React from 'react';
|
||||
import { ProjectCard } from '@/components/du-an/project-card';
|
||||
import { ProjectFilterBar } from '@/components/du-an/project-filter-bar';
|
||||
@@ -19,6 +20,7 @@ import {
|
||||
type SearchProjectsParams,
|
||||
} from '@/lib/du-an-api';
|
||||
import { useProjectsSearch } from '@/lib/hooks/use-du-an';
|
||||
import { useResidentialProjectsFlag } from '@/lib/hooks/use-residential-projects-flag';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const ProjectMap = dynamic(
|
||||
@@ -31,6 +33,7 @@ const PAGE_SIZE = 12;
|
||||
type ViewMode = 'grid' | 'list' | 'map';
|
||||
|
||||
export default function DuAnPage() {
|
||||
const flagEnabled = useResidentialProjectsFlag();
|
||||
const [filters, setFilters] = React.useState<SearchProjectsParams>({
|
||||
page: 1,
|
||||
limit: PAGE_SIZE,
|
||||
@@ -39,6 +42,10 @@ export default function DuAnPage() {
|
||||
|
||||
const { data, isLoading, isError } = useProjectsSearch(filters);
|
||||
|
||||
if (!flagEnabled) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
const handleFilterChange = (newFilters: SearchProjectsParams) => {
|
||||
setFilters({ ...newFilters, limit: PAGE_SIZE });
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
|
||||
Reference in New Issue
Block a user