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:
@@ -2,12 +2,15 @@ import type { Metadata } from 'next';
|
||||
import { notFound } from 'next/navigation';
|
||||
import { DuAnDetailClient } from '@/components/du-an/du-an-detail-client';
|
||||
import { fetchProjectBySlug } from '@/lib/du-an-server';
|
||||
import { isResidentialProjectsEnabledServer } from '@/lib/hooks/use-residential-projects-flag';
|
||||
|
||||
interface PageProps {
|
||||
params: Promise<{ slug: string; locale: string }>;
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
|
||||
if (!isResidentialProjectsEnabledServer()) return { title: 'Không tìm thấy dự án' };
|
||||
|
||||
const { slug } = await params;
|
||||
const project = await fetchProjectBySlug(slug);
|
||||
if (!project) return { title: 'Không tìm thấy dự án' };
|
||||
@@ -27,6 +30,10 @@ export async function generateMetadata({ params }: PageProps): Promise<Metadata>
|
||||
}
|
||||
|
||||
export default async function DuAnDetailPage({ params }: PageProps) {
|
||||
if (!isResidentialProjectsEnabledServer()) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
const { slug } = await params;
|
||||
const project = await fetchProjectBySlug(slug);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user