feat(listings): phase B — rich property fields + admin-authored personas
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 6s
CI / E2E Tests (push) Has been skipped
CodeQL Analysis / CodeQL (javascript-typescript) (push) Failing after 1m8s
Deploy / Build API Image (push) Failing after 29s
E2E Tests / Playwright E2E (push) Failing after 13s
Security Scanning / Dependency Audit (pnpm) (push) Failing after 2s
Security Scanning / Trivy Scan — API Image (push) Failing after 1m9s
Security Scanning / Trivy Scan — Web Image (push) Failing after 37s
Security Scanning / Trivy Scan — AI Services Image (push) Failing after 1m2s
Security Scanning / Trivy Filesystem Scan (push) Failing after 51s
Deploy / Smoke Test Staging (push) Has been skipped
Deploy / Smoke Test Production (push) Has been skipped
Security Scanning / Security Gate (push) Failing after 1s
Deploy / Rollback Staging (push) Has been skipped
Deploy / Rollback Production (push) Has been skipped
Deploy / Build Web Image (push) Failing after 14s
Deploy / Build AI Services Image (push) Failing after 12s
Deploy / Deploy to Staging (push) Has been skipped
Deploy / Deploy to Production (push) Has been skipped
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 6s
CI / E2E Tests (push) Has been skipped
CodeQL Analysis / CodeQL (javascript-typescript) (push) Failing after 1m8s
Deploy / Build API Image (push) Failing after 29s
E2E Tests / Playwright E2E (push) Failing after 13s
Security Scanning / Dependency Audit (pnpm) (push) Failing after 2s
Security Scanning / Trivy Scan — API Image (push) Failing after 1m9s
Security Scanning / Trivy Scan — Web Image (push) Failing after 37s
Security Scanning / Trivy Scan — AI Services Image (push) Failing after 1m2s
Security Scanning / Trivy Filesystem Scan (push) Failing after 51s
Deploy / Smoke Test Staging (push) Has been skipped
Deploy / Smoke Test Production (push) Has been skipped
Security Scanning / Security Gate (push) Failing after 1s
Deploy / Rollback Staging (push) Has been skipped
Deploy / Rollback Production (push) Has been skipped
Deploy / Build Web Image (push) Failing after 14s
Deploy / Build AI Services Image (push) Failing after 12s
Deploy / Deploy to Staging (push) Has been skipped
Deploy / Deploy to Production (push) Has been skipped
Schema (prisma/migrations/20260419000000_property_rich_fields) -------------------------------------------------------------- New Prisma enums: - Furnishing: FULLY_FURNISHED / BASIC_FURNISHED / UNFURNISHED - PropertyCondition: NEW / LIKE_NEW / RENOVATED / USED New Property columns (all optional / default empty, no data loss): - furnishing, propertyCondition — enums above - balconyDirection — reuses existing Direction enum - maintenanceFeeVND BigInt (phí quản lý/tháng) - parkingSlots Int - viewType String[] (e.g. ["Sông","Thành phố"]) - petFriendly Boolean (null = unknown) - suitableFor String[] — admin-chosen persona labels - whyThisLocation Text — admin narrative Backend wiring end-to-end ------------------------- - Create/Update DTOs: @IsEnum/@IsString/@IsNumber/@IsBoolean/@IsArray validators; maintenanceFeeVND accepted as a numeric string, cast to BigInt on the way to Prisma. whyThisLocation capped at 2000 chars. - Introduced a small `PropertyExtras` interface on the create/update commands so the constructor signature stays readable instead of ballooning to 30+ positional args. Handlers forward it to the repo. - Prisma property repository writes all new columns via raw SQL INSERT/UPDATE and reads them on findById. - ListingDetailData + findByIdWithProperty expose the 9 new fields (maintenanceFeeVND serialised as decimal string to avoid BigInt JSON). Frontend -------- - listings-api.ts: ListingDetail.property + CreateListingPayload carry the 9 new fields; Furnishing + PropertyCondition exported as string unions. - validations/listings.ts: zod schema extended; FURNISHING_OPTIONS, PROPERTY_CONDITION_OPTIONS, VIEW_TYPE_OPTIONS label arrays added in the existing DIRECTIONS style (Vietnamese labels). - listing-form-steps.tsx StepDetails: new "Nội thất & điều kiện" fieldset with selects/inputs for each field. viewType + suitableFor are comma-separated text (same convention as amenities). petFriendly is a 3-way select (không chọn / Có / Không). - new/page.tsx + [id]/edit/page.tsx: submit handlers split CSV inputs into arrays, coerce petFriendly, prune empty selects. - listing-detail-client.tsx Details card: new rows for furnishing, propertyCondition, balconyDirection, maintenanceFeeVND (VND formatted), parkingSlots, viewType (joined · ), petFriendly (Cho phép / Không cho phép / hide when null). - PersonaFitCard now takes the listing directly and MERGES admin suitableFor (rendered first with a "Người đăng chọn" badge in primary accent) with the derived personas (deduped by label). When whyThisLocation is non-empty it overrides the derived narrative. Tests ----- - listing-detail-client.spec.tsx fixture gains all 9 nullable/empty defaults. - listing-form-steps.spec.tsx direction-options duplication fixed. - pnpm --filter @goodgo/api test --run: 1975/1975 pass. - pnpm --filter @goodgo/web test --run: 624/624 pass. Phase B of 4. Next: Phase E AI advisor via Anthropic Opus (URL+key to be provided by the user). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -18,7 +18,13 @@ import { formatPrice, formatPricePerM2 } from '@/lib/currency';
|
||||
import { composeWhyThisLocation, derivePersonas } from '@/lib/listing-personas';
|
||||
import type { ListingDetail, NeighborhoodScoreResult, PriceHistoryItem } from '@/lib/listings-api';
|
||||
import { listingsApi } from '@/lib/listings-api';
|
||||
import { PROPERTY_TYPES, DIRECTIONS, TRANSACTION_TYPES } from '@/lib/validations/listings';
|
||||
import {
|
||||
PROPERTY_TYPES,
|
||||
DIRECTIONS,
|
||||
TRANSACTION_TYPES,
|
||||
FURNISHING_OPTIONS,
|
||||
PROPERTY_CONDITION_OPTIONS,
|
||||
} from '@/lib/validations/listings';
|
||||
import type { POIItem } from '@/components/neighborhood';
|
||||
|
||||
const NeighborhoodRadarChart = dynamic(
|
||||
@@ -244,6 +250,27 @@ export function ListingDetailClient({ listing }: ListingDetailClientProps) {
|
||||
: '---'
|
||||
}
|
||||
/>
|
||||
<InfoItem label="Nội thất" value={getLabel(FURNISHING_OPTIONS, property.furnishing) || '---'} />
|
||||
<InfoItem label="Tình trạng" value={getLabel(PROPERTY_CONDITION_OPTIONS, property.propertyCondition) || '---'} />
|
||||
<InfoItem label="Hướng ban công" value={getLabel(DIRECTIONS, property.balconyDirection) || '---'} />
|
||||
<InfoItem
|
||||
label="Phí quản lý/tháng"
|
||||
value={property.maintenanceFeeVND ? `${formatPrice(property.maintenanceFeeVND)} VND` : '---'}
|
||||
/>
|
||||
<InfoItem
|
||||
label="Chỗ để xe"
|
||||
value={property.parkingSlots != null ? `${property.parkingSlots}` : '---'}
|
||||
/>
|
||||
<InfoItem
|
||||
label="View"
|
||||
value={property.viewType && property.viewType.length > 0 ? property.viewType.join(' • ') : '---'}
|
||||
/>
|
||||
{property.petFriendly !== null && (
|
||||
<InfoItem
|
||||
label="Thú cưng"
|
||||
value={property.petFriendly ? 'Cho phép' : 'Không cho phép'}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -451,17 +478,29 @@ function PersonaFitCard({
|
||||
score: NeighborhoodScoreResult | null;
|
||||
pois: POIItem[];
|
||||
}) {
|
||||
const personas = React.useMemo(
|
||||
const adminPicks = listing.property.suitableFor ?? [];
|
||||
const adminNarrative = listing.property.whyThisLocation?.trim() || null;
|
||||
|
||||
// Derive personas purely from signals — then prepend admin picks, de-duping
|
||||
// against derived labels so we never double up.
|
||||
const derived = React.useMemo(
|
||||
() => derivePersonas(listing, score, pois),
|
||||
[listing, score, pois],
|
||||
);
|
||||
const narrative = React.useMemo(
|
||||
const derivedNarrative = React.useMemo(
|
||||
() => composeWhyThisLocation(listing, score, pois),
|
||||
[listing, score, pois],
|
||||
);
|
||||
|
||||
// Admin narrative wins when present — that's the authoritative version.
|
||||
const narrative = adminNarrative ?? derivedNarrative;
|
||||
|
||||
// Merge: admin picks first (each shown as "admin-chosen"), then derived
|
||||
// personas whose labels aren't already in the admin picks.
|
||||
const derivedFiltered = derived.filter((d) => !adminPicks.includes(d.label));
|
||||
|
||||
// Only render when we have something meaningful to say.
|
||||
if (personas.length === 0 && !narrative) return null;
|
||||
if (adminPicks.length === 0 && derivedFiltered.length === 0 && !narrative) return null;
|
||||
|
||||
return (
|
||||
<Card className="my-6 border-primary/30 bg-primary/5">
|
||||
@@ -469,9 +508,20 @@ function PersonaFitCard({
|
||||
<CardTitle className="text-lg">Phù hợp với ai?</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
{personas.length > 0 && (
|
||||
{(adminPicks.length > 0 || derivedFiltered.length > 0) && (
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{personas.map((p) => (
|
||||
{adminPicks.map((label) => (
|
||||
<div
|
||||
key={`admin-${label}`}
|
||||
className="group relative inline-flex items-center gap-1.5 rounded-full border border-primary/50 bg-primary/10 px-3 py-1.5 text-sm shadow-sm"
|
||||
>
|
||||
<span className="font-medium">{label}</span>
|
||||
<span className="rounded bg-primary/20 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-primary">
|
||||
Người đăng chọn
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
{derivedFiltered.map((p) => (
|
||||
<div
|
||||
key={p.key}
|
||||
className="group relative inline-flex items-center gap-1.5 rounded-full border bg-card px-3 py-1.5 text-sm shadow-sm"
|
||||
@@ -483,9 +533,9 @@ function PersonaFitCard({
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{personas.length > 0 && (
|
||||
{derivedFiltered.length > 0 && (
|
||||
<ul className="space-y-1.5 text-sm text-muted-foreground">
|
||||
{personas.map((p) => (
|
||||
{derivedFiltered.map((p) => (
|
||||
<li key={`reason-${p.key}`} className="flex gap-2">
|
||||
<span className="shrink-0 text-primary" aria-hidden="true">→</span>
|
||||
<span>
|
||||
|
||||
Reference in New Issue
Block a user