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:
@@ -1,4 +1,4 @@
|
||||
import { type PropertyType, type Direction } from '@prisma/client';
|
||||
import { type PropertyType, type Direction, type Furnishing, type PropertyCondition } from '@prisma/client';
|
||||
import { AggregateRoot } from '@modules/shared';
|
||||
import { type Address } from '../value-objects/address.vo';
|
||||
import { type GeoPoint } from '../value-objects/geo-point.vo';
|
||||
@@ -23,6 +23,16 @@ export interface PropertyProps {
|
||||
nearbyPOIs: unknown;
|
||||
metroDistanceM: number | null;
|
||||
projectName: string | null;
|
||||
// --- Rich fields (Phase B) -----------------------------
|
||||
furnishing?: Furnishing | null;
|
||||
propertyCondition?: PropertyCondition | null;
|
||||
balconyDirection?: Direction | null;
|
||||
maintenanceFeeVND?: bigint | null;
|
||||
parkingSlots?: number | null;
|
||||
viewType?: string[];
|
||||
petFriendly?: boolean | null;
|
||||
suitableFor?: string[];
|
||||
whyThisLocation?: string | null;
|
||||
}
|
||||
|
||||
export class PropertyEntity extends AggregateRoot<string> {
|
||||
@@ -45,6 +55,15 @@ export class PropertyEntity extends AggregateRoot<string> {
|
||||
private _nearbyPOIs: unknown;
|
||||
private _metroDistanceM: number | null;
|
||||
private _projectName: string | null;
|
||||
private _furnishing: Furnishing | null;
|
||||
private _propertyCondition: PropertyCondition | null;
|
||||
private _balconyDirection: Direction | null;
|
||||
private _maintenanceFeeVND: bigint | null;
|
||||
private _parkingSlots: number | null;
|
||||
private _viewType: string[];
|
||||
private _petFriendly: boolean | null;
|
||||
private _suitableFor: string[];
|
||||
private _whyThisLocation: string | null;
|
||||
|
||||
constructor(id: string, props: PropertyProps, createdAt?: Date, updatedAt?: Date) {
|
||||
super(id, createdAt, updatedAt);
|
||||
@@ -67,6 +86,15 @@ export class PropertyEntity extends AggregateRoot<string> {
|
||||
this._nearbyPOIs = props.nearbyPOIs;
|
||||
this._metroDistanceM = props.metroDistanceM;
|
||||
this._projectName = props.projectName;
|
||||
this._furnishing = props.furnishing ?? null;
|
||||
this._propertyCondition = props.propertyCondition ?? null;
|
||||
this._balconyDirection = props.balconyDirection ?? null;
|
||||
this._maintenanceFeeVND = props.maintenanceFeeVND ?? null;
|
||||
this._parkingSlots = props.parkingSlots ?? null;
|
||||
this._viewType = props.viewType ?? [];
|
||||
this._petFriendly = props.petFriendly ?? null;
|
||||
this._suitableFor = props.suitableFor ?? [];
|
||||
this._whyThisLocation = props.whyThisLocation ?? null;
|
||||
}
|
||||
|
||||
get propertyType(): PropertyType { return this._propertyType; }
|
||||
@@ -88,6 +116,15 @@ export class PropertyEntity extends AggregateRoot<string> {
|
||||
get nearbyPOIs(): unknown { return this._nearbyPOIs; }
|
||||
get metroDistanceM(): number | null { return this._metroDistanceM; }
|
||||
get projectName(): string | null { return this._projectName; }
|
||||
get furnishing(): Furnishing | null { return this._furnishing; }
|
||||
get propertyCondition(): PropertyCondition | null { return this._propertyCondition; }
|
||||
get balconyDirection(): Direction | null { return this._balconyDirection; }
|
||||
get maintenanceFeeVND(): bigint | null { return this._maintenanceFeeVND; }
|
||||
get parkingSlots(): number | null { return this._parkingSlots; }
|
||||
get viewType(): string[] { return this._viewType; }
|
||||
get petFriendly(): boolean | null { return this._petFriendly; }
|
||||
get suitableFor(): string[] { return this._suitableFor; }
|
||||
get whyThisLocation(): string | null { return this._whyThisLocation; }
|
||||
|
||||
static createNew(id: string, props: PropertyProps): PropertyEntity {
|
||||
return new PropertyEntity(id, props);
|
||||
@@ -101,6 +138,15 @@ export class PropertyEntity extends AggregateRoot<string> {
|
||||
title?: string;
|
||||
description?: string;
|
||||
amenities?: unknown;
|
||||
furnishing?: Furnishing | null;
|
||||
propertyCondition?: PropertyCondition | null;
|
||||
balconyDirection?: Direction | null;
|
||||
maintenanceFeeVND?: bigint | null;
|
||||
parkingSlots?: number | null;
|
||||
viewType?: string[];
|
||||
petFriendly?: boolean | null;
|
||||
suitableFor?: string[];
|
||||
whyThisLocation?: string | null;
|
||||
}): string[] {
|
||||
const updatedFields: string[] = [];
|
||||
|
||||
@@ -119,6 +165,43 @@ export class PropertyEntity extends AggregateRoot<string> {
|
||||
updatedFields.push('amenities');
|
||||
}
|
||||
|
||||
if (fields.furnishing !== undefined) {
|
||||
this._furnishing = fields.furnishing;
|
||||
updatedFields.push('furnishing');
|
||||
}
|
||||
if (fields.propertyCondition !== undefined) {
|
||||
this._propertyCondition = fields.propertyCondition;
|
||||
updatedFields.push('propertyCondition');
|
||||
}
|
||||
if (fields.balconyDirection !== undefined) {
|
||||
this._balconyDirection = fields.balconyDirection;
|
||||
updatedFields.push('balconyDirection');
|
||||
}
|
||||
if (fields.maintenanceFeeVND !== undefined) {
|
||||
this._maintenanceFeeVND = fields.maintenanceFeeVND;
|
||||
updatedFields.push('maintenanceFeeVND');
|
||||
}
|
||||
if (fields.parkingSlots !== undefined) {
|
||||
this._parkingSlots = fields.parkingSlots;
|
||||
updatedFields.push('parkingSlots');
|
||||
}
|
||||
if (fields.viewType !== undefined) {
|
||||
this._viewType = fields.viewType;
|
||||
updatedFields.push('viewType');
|
||||
}
|
||||
if (fields.petFriendly !== undefined) {
|
||||
this._petFriendly = fields.petFriendly;
|
||||
updatedFields.push('petFriendly');
|
||||
}
|
||||
if (fields.suitableFor !== undefined) {
|
||||
this._suitableFor = fields.suitableFor;
|
||||
updatedFields.push('suitableFor');
|
||||
}
|
||||
if (fields.whyThisLocation !== undefined) {
|
||||
this._whyThisLocation = fields.whyThisLocation;
|
||||
updatedFields.push('whyThisLocation');
|
||||
}
|
||||
|
||||
if (updatedFields.length > 0) {
|
||||
this.updatedAt = new Date();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type ListingStatus, type TransactionType, type PropertyType, type Direction } from '@prisma/client';
|
||||
import { type ListingStatus, type TransactionType, type PropertyType, type Direction, type Furnishing, type PropertyCondition } from '@prisma/client';
|
||||
|
||||
/** Returned by findByIdWithProperty — full listing detail with property, seller, agent */
|
||||
export interface ListingDetailData {
|
||||
@@ -41,6 +41,15 @@ export interface ListingDetailData {
|
||||
nearbyPOIs: unknown;
|
||||
metroDistanceM: number | null;
|
||||
projectName: string | null;
|
||||
furnishing: Furnishing | null;
|
||||
propertyCondition: PropertyCondition | null;
|
||||
balconyDirection: Direction | null;
|
||||
maintenanceFeeVND: string | null;
|
||||
parkingSlots: number | null;
|
||||
viewType: string[];
|
||||
petFriendly: boolean | null;
|
||||
suitableFor: string[];
|
||||
whyThisLocation: string | null;
|
||||
media: ListingMediaData[];
|
||||
};
|
||||
seller: {
|
||||
|
||||
Reference in New Issue
Block a user