Some checks failed
CI / E2E Tests (push) Has been skipped
CodeQL Analysis / CodeQL (javascript-typescript) (push) Failing after 1m28s
Deploy / Build API Image (push) Failing after 26s
Deploy / Build Web Image (push) Failing after 16s
Deploy / Build AI Services Image (push) Failing after 11s
E2E Tests / Playwright E2E (push) Failing after 23s
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 11s
Security Scanning / Dependency Audit (pnpm) (push) Failing after 3s
Deploy / Smoke Test Staging (push) Has been cancelled
Deploy / Deploy to Production (push) Has been cancelled
Deploy / Deploy to Staging (push) Has been cancelled
Deploy / Rollback Staging (push) Has been cancelled
Deploy / Smoke Test Production (push) Has been cancelled
Deploy / Rollback Production (push) Has been cancelled
Security Scanning / Trivy Scan — Web Image (push) Has been cancelled
Security Scanning / Trivy Scan — AI Services Image (push) Has been cancelled
Security Scanning / Trivy Filesystem Scan (push) Has been cancelled
Security Scanning / Security Gate (push) Has been cancelled
Security Scanning / Trivy Scan — API Image (push) Has been cancelled
- Split `isResidentialProjectsEnabledServer` out of the `'use client'` hook file into `lib/feature-flags/residential-projects.ts` so Server Components can import it without Next.js treating it as a client ref. - Detail endpoint preserves `media` via new `shapeProjectDetail` instead of stripping it in `shapeProject`. - `fetchProjectBySlug` now normalizes the response: fills missing arrays (media, blocks, amenities, priceRanges, priceHistory, neighborhoodScores, pois, documents) with `[]`, remaps `developer.logo` → `logoUrl`, defaults `totalProjects` to 0. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
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/feature-flags/residential-projects';
|
|
|
|
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' };
|
|
|
|
return {
|
|
title: `${project.name} — ${project.developer.name}`,
|
|
description: project.description?.slice(0, 160),
|
|
openGraph: {
|
|
title: project.name,
|
|
description: project.description?.slice(0, 160),
|
|
images: project.media
|
|
.filter((m) => m.type === 'image')
|
|
.slice(0, 1)
|
|
.map((m) => ({ url: m.url })),
|
|
},
|
|
};
|
|
}
|
|
|
|
export default async function DuAnDetailPage({ params }: PageProps) {
|
|
if (!isResidentialProjectsEnabledServer()) {
|
|
notFound();
|
|
}
|
|
|
|
const { slug } = await params;
|
|
const project = await fetchProjectBySlug(slug);
|
|
|
|
if (!project) {
|
|
notFound();
|
|
}
|
|
|
|
return <DuAnDetailClient project={project} />;
|
|
}
|