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,20 @@
|
||||
import { type PropertyType, type TransactionType, type Direction } from '@prisma/client';
|
||||
import { type PropertyType, type TransactionType, type Direction, type Furnishing, type PropertyCondition } from '@prisma/client';
|
||||
|
||||
/**
|
||||
* Optional "rich" property fields. Bundled so the command constructor does
|
||||
* not grow unbounded each time we add a field.
|
||||
*/
|
||||
export interface PropertyExtras {
|
||||
furnishing?: Furnishing;
|
||||
propertyCondition?: PropertyCondition;
|
||||
balconyDirection?: Direction;
|
||||
maintenanceFeeVND?: bigint;
|
||||
parkingSlots?: number;
|
||||
viewType?: string[];
|
||||
petFriendly?: boolean;
|
||||
suitableFor?: string[];
|
||||
whyThisLocation?: string;
|
||||
}
|
||||
|
||||
export class CreateListingCommand {
|
||||
constructor(
|
||||
@@ -34,5 +50,7 @@ export class CreateListingCommand {
|
||||
public readonly agentId?: string,
|
||||
public readonly rentPriceMonthly?: bigint,
|
||||
public readonly commissionPct?: number,
|
||||
// Rich property fields bundled as options object (keeps ctor scalable)
|
||||
public readonly extras?: PropertyExtras,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ export class CreateListingHandler implements ICommandHandler<CreateListingComman
|
||||
|
||||
// Create property
|
||||
const propertyId = createId();
|
||||
const extras = command.extras ?? {};
|
||||
const property = PropertyEntity.createNew(propertyId, {
|
||||
propertyType: command.propertyType,
|
||||
title: command.title,
|
||||
@@ -88,6 +89,15 @@ export class CreateListingHandler implements ICommandHandler<CreateListingComman
|
||||
nearbyPOIs: command.nearbyPOIs ?? null,
|
||||
metroDistanceM: command.metroDistanceM ?? null,
|
||||
projectName: command.projectName ?? null,
|
||||
furnishing: extras.furnishing ?? null,
|
||||
propertyCondition: extras.propertyCondition ?? null,
|
||||
balconyDirection: extras.balconyDirection ?? null,
|
||||
maintenanceFeeVND: extras.maintenanceFeeVND ?? null,
|
||||
parkingSlots: extras.parkingSlots ?? null,
|
||||
viewType: extras.viewType ?? [],
|
||||
petFriendly: extras.petFriendly ?? null,
|
||||
suitableFor: extras.suitableFor ?? [],
|
||||
whyThisLocation: extras.whyThisLocation ?? null,
|
||||
});
|
||||
|
||||
await this.propertyRepo.save(property);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { type PropertyExtras } from '../create-listing/create-listing.command';
|
||||
|
||||
export class UpdateListingCommand {
|
||||
constructor(
|
||||
public readonly listingId: string,
|
||||
@@ -9,5 +11,7 @@ export class UpdateListingCommand {
|
||||
public readonly amenities?: string[],
|
||||
public readonly mediaOrder?: { mediaId: string; order: number }[],
|
||||
public readonly userRole?: string,
|
||||
// Rich property fields bundled so ctor stays compact (all optional).
|
||||
public readonly extras?: PropertyExtras,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -51,10 +51,25 @@ export class UpdateListingHandler implements ICommandHandler<UpdateListingComman
|
||||
// 3. Validate no fields are being sent (empty update)
|
||||
const hasListingUpdates =
|
||||
command.priceVND !== undefined || command.rentPriceMonthly !== undefined;
|
||||
const extras = command.extras;
|
||||
const hasExtrasUpdates =
|
||||
extras !== undefined &&
|
||||
(
|
||||
extras.furnishing !== undefined ||
|
||||
extras.propertyCondition !== undefined ||
|
||||
extras.balconyDirection !== undefined ||
|
||||
extras.maintenanceFeeVND !== undefined ||
|
||||
extras.parkingSlots !== undefined ||
|
||||
extras.viewType !== undefined ||
|
||||
extras.petFriendly !== undefined ||
|
||||
extras.suitableFor !== undefined ||
|
||||
extras.whyThisLocation !== undefined
|
||||
);
|
||||
const hasPropertyUpdates =
|
||||
command.title !== undefined ||
|
||||
command.description !== undefined ||
|
||||
command.amenities !== undefined;
|
||||
command.amenities !== undefined ||
|
||||
hasExtrasUpdates;
|
||||
const hasMediaOrderUpdate =
|
||||
command.mediaOrder !== undefined && command.mediaOrder.length > 0;
|
||||
|
||||
@@ -81,12 +96,21 @@ export class UpdateListingHandler implements ICommandHandler<UpdateListingComman
|
||||
allUpdatedFields.push(...listingUpdated);
|
||||
}
|
||||
|
||||
// Update property fields (title, description, amenities)
|
||||
// Update property fields (title, description, amenities, rich fields)
|
||||
if (hasPropertyUpdates) {
|
||||
const propertyUpdated = property.updateContent({
|
||||
title: command.title,
|
||||
description: command.description,
|
||||
amenities: command.amenities,
|
||||
...(extras?.furnishing !== undefined && { furnishing: extras.furnishing }),
|
||||
...(extras?.propertyCondition !== undefined && { propertyCondition: extras.propertyCondition }),
|
||||
...(extras?.balconyDirection !== undefined && { balconyDirection: extras.balconyDirection }),
|
||||
...(extras?.maintenanceFeeVND !== undefined && { maintenanceFeeVND: extras.maintenanceFeeVND }),
|
||||
...(extras?.parkingSlots !== undefined && { parkingSlots: extras.parkingSlots }),
|
||||
...(extras?.viewType !== undefined && { viewType: extras.viewType }),
|
||||
...(extras?.petFriendly !== undefined && { petFriendly: extras.petFriendly }),
|
||||
...(extras?.suitableFor !== undefined && { suitableFor: extras.suitableFor }),
|
||||
...(extras?.whyThisLocation !== undefined && { whyThisLocation: extras.whyThisLocation }),
|
||||
});
|
||||
allUpdatedFields.push(...propertyUpdated);
|
||||
}
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -75,6 +75,15 @@ export async function findByIdWithProperty(
|
||||
nearbyPOIs: listing.property.nearbyPOIs,
|
||||
metroDistanceM: listing.property.metroDistanceM,
|
||||
projectName: listing.property.projectName,
|
||||
furnishing: listing.property.furnishing,
|
||||
propertyCondition: listing.property.propertyCondition,
|
||||
balconyDirection: listing.property.balconyDirection,
|
||||
maintenanceFeeVND: listing.property.maintenanceFeeVND?.toString() ?? null,
|
||||
parkingSlots: listing.property.parkingSlots,
|
||||
viewType: listing.property.viewType ?? [],
|
||||
petFriendly: listing.property.petFriendly,
|
||||
suitableFor: listing.property.suitableFor ?? [],
|
||||
whyThisLocation: listing.property.whyThisLocation,
|
||||
media: listing.property.media.map((m) => ({
|
||||
id: m.id,
|
||||
url: m.url,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { type Prisma, type PropertyMedia as PrismaMedia, type PropertyType, type Direction } from '@prisma/client';
|
||||
import { type Prisma, type PropertyMedia as PrismaMedia, type PropertyType, type Direction, type Furnishing, type PropertyCondition } from '@prisma/client';
|
||||
import { PrismaService } from '@modules/shared';
|
||||
import { PropertyMediaEntity, type PropertyMediaProps } from '../../domain/entities/property-media.entity';
|
||||
import { PropertyEntity, type PropertyProps } from '../../domain/entities/property.entity';
|
||||
@@ -33,6 +33,15 @@ interface PropertyWithGeo {
|
||||
nearbyPOIs: unknown;
|
||||
metroDistanceM: number | null;
|
||||
projectName: string | null;
|
||||
furnishing: Furnishing | null;
|
||||
propertyCondition: PropertyCondition | null;
|
||||
balconyDirection: Direction | null;
|
||||
maintenanceFeeVND: bigint | null;
|
||||
parkingSlots: number | null;
|
||||
viewType: string[] | null;
|
||||
petFriendly: boolean | null;
|
||||
suitableFor: string[] | null;
|
||||
whyThisLocation: string | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
@@ -52,7 +61,11 @@ export class PrismaPropertyRepository implements IPropertyRepository {
|
||||
"areaM2", "usableAreaM2", "bedrooms", "bathrooms",
|
||||
"floors", "floor", "totalFloors", "direction",
|
||||
"yearBuilt", "legalStatus", "amenities", "nearbyPOIs",
|
||||
"metroDistanceM", "projectName", "createdAt", "updatedAt"
|
||||
"metroDistanceM", "projectName",
|
||||
"furnishing", "propertyCondition", "balconyDirection",
|
||||
"maintenanceFeeVND", "parkingSlots", "viewType",
|
||||
"petFriendly", "suitableFor", "whyThisLocation",
|
||||
"createdAt", "updatedAt"
|
||||
FROM "Property"
|
||||
WHERE "id" = ${id}
|
||||
LIMIT 1
|
||||
@@ -67,7 +80,11 @@ export class PrismaPropertyRepository implements IPropertyRepository {
|
||||
"id", "propertyType", "title", "description", "address", "ward", "district", "city",
|
||||
"location", "areaM2", "usableAreaM2", "bedrooms", "bathrooms", "floors", "floor",
|
||||
"totalFloors", "direction", "yearBuilt", "legalStatus", "amenities", "nearbyPOIs",
|
||||
"metroDistanceM", "projectName", "createdAt", "updatedAt"
|
||||
"metroDistanceM", "projectName",
|
||||
"furnishing", "propertyCondition", "balconyDirection",
|
||||
"maintenanceFeeVND", "parkingSlots", "viewType",
|
||||
"petFriendly", "suitableFor", "whyThisLocation",
|
||||
"createdAt", "updatedAt"
|
||||
) VALUES (
|
||||
${entity.id}, ${entity.propertyType}::"PropertyType", ${entity.title}, ${entity.description},
|
||||
${entity.address.address}, ${entity.address.ward}, ${entity.address.district}, ${entity.address.city},
|
||||
@@ -78,6 +95,15 @@ export class PrismaPropertyRepository implements IPropertyRepository {
|
||||
${entity.amenities ? JSON.stringify(entity.amenities) : null}::jsonb,
|
||||
${entity.nearbyPOIs ? JSON.stringify(entity.nearbyPOIs) : null}::jsonb,
|
||||
${entity.metroDistanceM}, ${entity.projectName},
|
||||
${entity.furnishing}::"Furnishing",
|
||||
${entity.propertyCondition}::"PropertyCondition",
|
||||
${entity.balconyDirection}::"Direction",
|
||||
${entity.maintenanceFeeVND},
|
||||
${entity.parkingSlots},
|
||||
${entity.viewType}::text[],
|
||||
${entity.petFriendly},
|
||||
${entity.suitableFor}::text[],
|
||||
${entity.whyThisLocation},
|
||||
${entity.createdAt}, ${entity.updatedAt}
|
||||
)`;
|
||||
}
|
||||
@@ -107,6 +133,15 @@ export class PrismaPropertyRepository implements IPropertyRepository {
|
||||
"nearbyPOIs" = ${entity.nearbyPOIs ? JSON.stringify(entity.nearbyPOIs) : null}::jsonb,
|
||||
"metroDistanceM" = ${entity.metroDistanceM},
|
||||
"projectName" = ${entity.projectName},
|
||||
"furnishing" = ${entity.furnishing}::"Furnishing",
|
||||
"propertyCondition" = ${entity.propertyCondition}::"PropertyCondition",
|
||||
"balconyDirection" = ${entity.balconyDirection}::"Direction",
|
||||
"maintenanceFeeVND" = ${entity.maintenanceFeeVND},
|
||||
"parkingSlots" = ${entity.parkingSlots},
|
||||
"viewType" = ${entity.viewType}::text[],
|
||||
"petFriendly" = ${entity.petFriendly},
|
||||
"suitableFor" = ${entity.suitableFor}::text[],
|
||||
"whyThisLocation" = ${entity.whyThisLocation},
|
||||
"updatedAt" = NOW()
|
||||
WHERE "id" = ${entity.id}`;
|
||||
}
|
||||
@@ -177,6 +212,15 @@ export class PrismaPropertyRepository implements IPropertyRepository {
|
||||
nearbyPOIs: raw.nearbyPOIs,
|
||||
metroDistanceM: raw.metroDistanceM,
|
||||
projectName: raw.projectName,
|
||||
furnishing: raw.furnishing,
|
||||
propertyCondition: raw.propertyCondition,
|
||||
balconyDirection: raw.balconyDirection,
|
||||
maintenanceFeeVND: raw.maintenanceFeeVND,
|
||||
parkingSlots: raw.parkingSlots,
|
||||
viewType: raw.viewType ?? [],
|
||||
petFriendly: raw.petFriendly,
|
||||
suitableFor: raw.suitableFor ?? [],
|
||||
whyThisLocation: raw.whyThisLocation,
|
||||
};
|
||||
|
||||
return new PropertyEntity(raw.id, props, raw.createdAt, raw.updatedAt);
|
||||
|
||||
@@ -110,6 +110,17 @@ export class ListingsController {
|
||||
dto.agentId,
|
||||
dto.rentPriceMonthly,
|
||||
dto.commissionPct,
|
||||
{
|
||||
furnishing: dto.furnishing,
|
||||
propertyCondition: dto.propertyCondition,
|
||||
balconyDirection: dto.balconyDirection,
|
||||
maintenanceFeeVND: dto.maintenanceFeeVND,
|
||||
parkingSlots: dto.parkingSlots,
|
||||
viewType: dto.viewType,
|
||||
petFriendly: dto.petFriendly,
|
||||
suitableFor: dto.suitableFor,
|
||||
whyThisLocation: dto.whyThisLocation,
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -238,6 +249,17 @@ export class ListingsController {
|
||||
dto.amenities,
|
||||
dto.mediaOrder,
|
||||
user.role,
|
||||
{
|
||||
furnishing: dto.furnishing,
|
||||
propertyCondition: dto.propertyCondition,
|
||||
balconyDirection: dto.balconyDirection,
|
||||
maintenanceFeeVND: dto.maintenanceFeeVND,
|
||||
parkingSlots: dto.parkingSlots,
|
||||
viewType: dto.viewType,
|
||||
petFriendly: dto.petFriendly,
|
||||
suitableFor: dto.suitableFor,
|
||||
whyThisLocation: dto.whyThisLocation,
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { PropertyType, TransactionType, Direction } from '@prisma/client';
|
||||
import { PropertyType, TransactionType, Direction, Furnishing, PropertyCondition } from '@prisma/client';
|
||||
import { Type, Transform } from 'class-transformer';
|
||||
import {
|
||||
IsString,
|
||||
@@ -8,9 +8,11 @@ import {
|
||||
IsOptional,
|
||||
IsNotEmpty,
|
||||
MinLength,
|
||||
MaxLength,
|
||||
Min,
|
||||
Max,
|
||||
IsArray,
|
||||
IsBoolean,
|
||||
} from 'class-validator';
|
||||
|
||||
export class CreateListingDto {
|
||||
@@ -160,4 +162,54 @@ export class CreateListingDto {
|
||||
@IsNumber()
|
||||
@Type(() => Number)
|
||||
commissionPct?: number;
|
||||
|
||||
@ApiPropertyOptional({ enum: Furnishing, example: 'FULLY_FURNISHED', description: 'Furnishing level' })
|
||||
@IsOptional()
|
||||
@IsEnum(Furnishing)
|
||||
furnishing?: Furnishing;
|
||||
|
||||
@ApiPropertyOptional({ enum: PropertyCondition, example: 'NEW', description: 'Property condition' })
|
||||
@IsOptional()
|
||||
@IsEnum(PropertyCondition)
|
||||
propertyCondition?: PropertyCondition;
|
||||
|
||||
@ApiPropertyOptional({ enum: Direction, example: 'SOUTH', description: 'Balcony / terrace facing direction' })
|
||||
@IsOptional()
|
||||
@IsEnum(Direction)
|
||||
balconyDirection?: Direction;
|
||||
|
||||
@ApiPropertyOptional({ type: String, example: '2500000', description: 'Monthly maintenance fee in VND (as string to support bigint)' })
|
||||
@IsOptional()
|
||||
@Transform(({ value }) => (value != null && value !== '' ? BigInt(value) : undefined))
|
||||
maintenanceFeeVND?: bigint;
|
||||
|
||||
@ApiPropertyOptional({ example: 2, description: 'Number of parking slots' })
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@Type(() => Number)
|
||||
@Min(0)
|
||||
parkingSlots?: number;
|
||||
|
||||
@ApiPropertyOptional({ example: ['Sông', 'Thành phố'], description: 'View types (multi-select)' })
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
viewType?: string[];
|
||||
|
||||
@ApiPropertyOptional({ example: true, description: 'Whether pets are allowed (null = unknown)' })
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
petFriendly?: boolean;
|
||||
|
||||
@ApiPropertyOptional({ example: ['Gia đình có con nhỏ'], description: 'Personas selected by admin' })
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
suitableFor?: string[];
|
||||
|
||||
@ApiPropertyOptional({ example: 'Khu vực gần trường học, dễ di chuyển...', description: 'Admin narrative for why this location suits buyers' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(2000)
|
||||
whyThisLocation?: string;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { Direction, Furnishing, PropertyCondition } from '@prisma/client';
|
||||
import { Transform, Type } from 'class-transformer';
|
||||
import {
|
||||
IsString,
|
||||
IsOptional,
|
||||
MinLength,
|
||||
MaxLength,
|
||||
IsArray,
|
||||
ValidateNested,
|
||||
IsInt,
|
||||
Min,
|
||||
IsEnum,
|
||||
IsBoolean,
|
||||
IsNumber,
|
||||
} from 'class-validator';
|
||||
|
||||
export class MediaOrderItemDto {
|
||||
@@ -57,5 +62,56 @@ export class UpdateListingDto {
|
||||
@Type(() => MediaOrderItemDto)
|
||||
mediaOrder?: MediaOrderItemDto[];
|
||||
|
||||
// ─── Rich property fields ──────────────────────────────
|
||||
@ApiPropertyOptional({ enum: Furnishing })
|
||||
@IsOptional()
|
||||
@IsEnum(Furnishing)
|
||||
furnishing?: Furnishing;
|
||||
|
||||
@ApiPropertyOptional({ enum: PropertyCondition })
|
||||
@IsOptional()
|
||||
@IsEnum(PropertyCondition)
|
||||
propertyCondition?: PropertyCondition;
|
||||
|
||||
@ApiPropertyOptional({ enum: Direction })
|
||||
@IsOptional()
|
||||
@IsEnum(Direction)
|
||||
balconyDirection?: Direction;
|
||||
|
||||
@ApiPropertyOptional({ type: String, example: '2500000' })
|
||||
@IsOptional()
|
||||
@Transform(({ value }) => (value != null && value !== '' ? BigInt(value) : undefined))
|
||||
maintenanceFeeVND?: bigint;
|
||||
|
||||
@ApiPropertyOptional({ example: 2 })
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@Type(() => Number)
|
||||
@Min(0)
|
||||
parkingSlots?: number;
|
||||
|
||||
@ApiPropertyOptional({ example: ['Sông'] })
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
viewType?: string[];
|
||||
|
||||
@ApiPropertyOptional({ example: true })
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
petFriendly?: boolean;
|
||||
|
||||
@ApiPropertyOptional({ example: ['Gia đình có con nhỏ'] })
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
suitableFor?: string[];
|
||||
|
||||
@ApiPropertyOptional({ example: 'Vì sao khu vực này phù hợp...' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(2000)
|
||||
whyThisLocation?: string;
|
||||
|
||||
// propertyType, address, location CANNOT be changed after ACTIVE status.
|
||||
}
|
||||
|
||||
@@ -62,6 +62,20 @@ export default function EditListingPage() {
|
||||
priceVND: data.priceVND,
|
||||
rentPriceMonthly: data.rentPriceMonthly ?? '',
|
||||
commissionPct: data.commissionPct != null ? String(data.commissionPct) : '',
|
||||
furnishing: property.furnishing ?? '',
|
||||
propertyCondition: property.propertyCondition ?? '',
|
||||
balconyDirection: property.balconyDirection ?? '',
|
||||
maintenanceFeeVND: property.maintenanceFeeVND ?? '',
|
||||
parkingSlots: property.parkingSlots != null ? String(property.parkingSlots) : '',
|
||||
viewType: property.viewType?.join(', ') ?? '',
|
||||
petFriendly:
|
||||
property.petFriendly === true
|
||||
? 'true'
|
||||
: property.petFriendly === false
|
||||
? 'false'
|
||||
: '',
|
||||
suitableFor: property.suitableFor?.join(', ') ?? '',
|
||||
whyThisLocation: property.whyThisLocation ?? '',
|
||||
});
|
||||
})
|
||||
.catch(() => setListing(null))
|
||||
|
||||
@@ -13,7 +13,13 @@ import {
|
||||
} from '@/components/listings/listing-form-steps';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { listingsApi, type CreateListingPayload, type Direction } from '@/lib/listings-api';
|
||||
import {
|
||||
listingsApi,
|
||||
type CreateListingPayload,
|
||||
type Direction,
|
||||
type Furnishing,
|
||||
type PropertyCondition,
|
||||
} from '@/lib/listings-api';
|
||||
import { cn } from '@/lib/utils';
|
||||
import {
|
||||
createListingSchema,
|
||||
@@ -110,6 +116,25 @@ export default function CreateListingPage() {
|
||||
const commissionPct = toNum(data.commissionPct);
|
||||
if (commissionPct != null) payload.commissionPct = commissionPct;
|
||||
|
||||
// Rich property fields ----------------------------------
|
||||
if (data.furnishing) payload.furnishing = data.furnishing as Furnishing;
|
||||
if (data.propertyCondition) payload.propertyCondition = data.propertyCondition as PropertyCondition;
|
||||
if (data.balconyDirection) payload.balconyDirection = data.balconyDirection as Direction;
|
||||
if (data.maintenanceFeeVND) payload.maintenanceFeeVND = data.maintenanceFeeVND;
|
||||
const parkingSlots = toNum(data.parkingSlots);
|
||||
if (parkingSlots != null) payload.parkingSlots = parkingSlots;
|
||||
if (data.viewType) {
|
||||
const arr = data.viewType.split(',').map((s) => s.trim()).filter(Boolean);
|
||||
if (arr.length > 0) payload.viewType = arr;
|
||||
}
|
||||
if (data.petFriendly === 'true') payload.petFriendly = true;
|
||||
else if (data.petFriendly === 'false') payload.petFriendly = false;
|
||||
if (data.suitableFor) {
|
||||
const arr = data.suitableFor.split(',').map((s) => s.trim()).filter(Boolean);
|
||||
if (arr.length > 0) payload.suitableFor = arr;
|
||||
}
|
||||
if (data.whyThisLocation) payload.whyThisLocation = data.whyThisLocation;
|
||||
|
||||
const result = await listingsApi.create(payload);
|
||||
|
||||
for (const img of images) {
|
||||
|
||||
@@ -116,6 +116,15 @@ function makeListing(overrides: Partial<ListingDetail> = {}): ListingDetail {
|
||||
projectName: 'Vinhomes Central Park',
|
||||
latitude: 10.7975,
|
||||
longitude: 106.721,
|
||||
furnishing: null,
|
||||
propertyCondition: null,
|
||||
balconyDirection: null,
|
||||
maintenanceFeeVND: null,
|
||||
parkingSlots: null,
|
||||
viewType: [],
|
||||
petFriendly: null,
|
||||
suitableFor: [],
|
||||
whyThisLocation: null,
|
||||
media: [
|
||||
{ id: 'media-1', type: 'image', url: 'https://example.com/img1.jpg', order: 0, caption: null },
|
||||
],
|
||||
|
||||
@@ -148,9 +148,11 @@ describe('StepDetails', () => {
|
||||
|
||||
it('renders direction options', () => {
|
||||
render(<StepDetails register={mockRegister()} errors={noErrors} />);
|
||||
expect(screen.getByText('Bắc')).toBeInTheDocument();
|
||||
expect(screen.getByText('Nam')).toBeInTheDocument();
|
||||
expect(screen.getByText('Đông')).toBeInTheDocument();
|
||||
// "Direction" options appear in both `direction` and `balconyDirection`
|
||||
// selects, so they occur multiple times.
|
||||
expect(screen.getAllByText('Bắc').length).toBeGreaterThanOrEqual(1);
|
||||
expect(screen.getAllByText('Nam').length).toBeGreaterThanOrEqual(1);
|
||||
expect(screen.getAllByText('Đông').length).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('renders year built input', () => {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
TRANSACTION_TYPES,
|
||||
PROPERTY_TYPES,
|
||||
DIRECTIONS,
|
||||
FURNISHING_OPTIONS,
|
||||
PROPERTY_CONDITION_OPTIONS,
|
||||
type CreateListingFormData,
|
||||
} from '@/lib/validations/listings';
|
||||
|
||||
@@ -208,6 +210,96 @@ export function StepDetails({ register, errors }: StepProps) {
|
||||
<Label htmlFor="amenities">Tiện ích (cách nhau bởi dấu phẩy)</Label>
|
||||
<Input id="amenities" placeholder="VD: Hồ bơi, Gym, Công viên" {...register('amenities')} />
|
||||
</div>
|
||||
|
||||
<fieldset className="space-y-4 rounded-lg border p-4">
|
||||
<legend className="px-2 text-sm font-semibold">Nội thất & điều kiện</legend>
|
||||
|
||||
<div className="grid gap-4 sm:grid-cols-2 md:grid-cols-3">
|
||||
<div>
|
||||
<Label htmlFor="furnishing">Nội thất</Label>
|
||||
<Select id="furnishing" {...register('furnishing')}>
|
||||
<option value="">-- Không chọn --</option>
|
||||
{FURNISHING_OPTIONS.map((o) => (
|
||||
<option key={o.value} value={o.value}>
|
||||
{o.label}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="propertyCondition">Tình trạng</Label>
|
||||
<Select id="propertyCondition" {...register('propertyCondition')}>
|
||||
<option value="">-- Không chọn --</option>
|
||||
{PROPERTY_CONDITION_OPTIONS.map((o) => (
|
||||
<option key={o.value} value={o.value}>
|
||||
{o.label}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="balconyDirection">Hướng ban công</Label>
|
||||
<Select id="balconyDirection" {...register('balconyDirection')}>
|
||||
<option value="">-- Không chọn --</option>
|
||||
{DIRECTIONS.map((d) => (
|
||||
<option key={d.value} value={d.value}>
|
||||
{d.label}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="maintenanceFeeVND">Phí quản lý / tháng (VNĐ)</Label>
|
||||
<Input
|
||||
id="maintenanceFeeVND"
|
||||
type="text"
|
||||
inputMode="numeric"
|
||||
placeholder="VD: 2500000"
|
||||
{...register('maintenanceFeeVND')}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="parkingSlots">Chỗ để xe</Label>
|
||||
<Input id="parkingSlots" type="number" min="0" {...register('parkingSlots')} />
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="petFriendly">Cho phép thú cưng</Label>
|
||||
<Select id="petFriendly" {...register('petFriendly')}>
|
||||
<option value="">-- Không chọn --</option>
|
||||
<option value="true">Có</option>
|
||||
<option value="false">Không</option>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="viewType">View (cách nhau bởi dấu phẩy)</Label>
|
||||
<Input
|
||||
id="viewType"
|
||||
placeholder="VD: Sông, Thành phố, Công viên"
|
||||
{...register('viewType')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="suitableFor">Phù hợp với (cách nhau bởi dấu phẩy)</Label>
|
||||
<Input
|
||||
id="suitableFor"
|
||||
placeholder="VD: Gia đình có con nhỏ, Người đi làm xa"
|
||||
{...register('suitableFor')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="whyThisLocation">Vì sao khu vực này phù hợp</Label>
|
||||
<Textarea
|
||||
id="whyThisLocation"
|
||||
rows={3}
|
||||
placeholder="Mô tả ngắn lý do khu vực này phù hợp với người mua..."
|
||||
{...register('whyThisLocation')}
|
||||
/>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,9 @@ export type Direction =
|
||||
| 'SOUTHEAST'
|
||||
| 'SOUTHWEST';
|
||||
|
||||
export type Furnishing = 'FULLY_FURNISHED' | 'BASIC_FURNISHED' | 'UNFURNISHED';
|
||||
export type PropertyCondition = 'NEW' | 'LIKE_NEW' | 'RENOVATED' | 'USED';
|
||||
|
||||
// ─── Interfaces ──────────────────────────────────────────
|
||||
|
||||
export interface PropertyMedia {
|
||||
@@ -71,6 +74,15 @@ export interface ListingDetail {
|
||||
projectName: string | null;
|
||||
latitude: number | null;
|
||||
longitude: number | 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: PropertyMedia[];
|
||||
thumbnail?: string | null;
|
||||
};
|
||||
@@ -120,6 +132,16 @@ export interface CreateListingPayload {
|
||||
projectName?: string;
|
||||
rentPriceMonthly?: string;
|
||||
commissionPct?: number;
|
||||
// Rich property fields (Phase B)
|
||||
furnishing?: Furnishing;
|
||||
propertyCondition?: PropertyCondition;
|
||||
balconyDirection?: Direction;
|
||||
maintenanceFeeVND?: string;
|
||||
parkingSlots?: number;
|
||||
viewType?: string[];
|
||||
petFriendly?: boolean;
|
||||
suitableFor?: string[];
|
||||
whyThisLocation?: string;
|
||||
}
|
||||
|
||||
export interface SearchListingsParams {
|
||||
|
||||
@@ -25,6 +25,29 @@ export const DIRECTIONS = [
|
||||
{ value: 'SOUTHWEST', label: 'Tây Nam' },
|
||||
] as const;
|
||||
|
||||
export const FURNISHING_OPTIONS = [
|
||||
{ value: 'FULLY_FURNISHED', label: 'Đầy đủ nội thất' },
|
||||
{ value: 'BASIC_FURNISHED', label: 'Nội thất cơ bản' },
|
||||
{ value: 'UNFURNISHED', label: 'Bàn giao thô' },
|
||||
] as const;
|
||||
|
||||
export const PROPERTY_CONDITION_OPTIONS = [
|
||||
{ value: 'NEW', label: 'Mới' },
|
||||
{ value: 'LIKE_NEW', label: 'Như mới' },
|
||||
{ value: 'RENOVATED', label: 'Đã cải tạo' },
|
||||
{ value: 'USED', label: 'Đã qua sử dụng' },
|
||||
] as const;
|
||||
|
||||
export const VIEW_TYPE_OPTIONS = [
|
||||
{ value: 'Sông', label: 'Sông' },
|
||||
{ value: 'Thành phố', label: 'Thành phố' },
|
||||
{ value: 'Công viên', label: 'Công viên' },
|
||||
{ value: 'Hồ bơi', label: 'Hồ bơi' },
|
||||
{ value: 'Sân vườn', label: 'Sân vườn' },
|
||||
{ value: 'Biển', label: 'Biển' },
|
||||
{ value: 'Nội khu', label: 'Nội khu' },
|
||||
] as const;
|
||||
|
||||
export const LISTING_STATUSES = {
|
||||
DRAFT: { label: 'Nháp', variant: 'secondary' as const },
|
||||
PENDING_REVIEW: { label: 'Chờ duyệt', variant: 'warning' as const },
|
||||
@@ -75,6 +98,16 @@ export const listingDetailsSchema = z.object({
|
||||
legalStatus: z.string().optional(),
|
||||
amenities: z.string().optional(),
|
||||
projectName: z.string().optional(),
|
||||
// Rich property fields (Phase B)
|
||||
furnishing: z.string().optional(),
|
||||
propertyCondition: z.string().optional(),
|
||||
balconyDirection: z.string().optional(),
|
||||
maintenanceFeeVND: z.string().optional(),
|
||||
parkingSlots: z.string().optional(),
|
||||
viewType: z.string().optional(), // comma-separated
|
||||
petFriendly: z.string().optional(), // '' | 'true' | 'false'
|
||||
suitableFor: z.string().optional(), // comma-separated
|
||||
whyThisLocation: z.string().max(2000, 'Tối đa 2000 ký tự').optional(),
|
||||
});
|
||||
|
||||
// ─── Step 4: Pricing ─────────────────────────────────────
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "Furnishing" AS ENUM ('FULLY_FURNISHED', 'BASIC_FURNISHED', 'UNFURNISHED');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "PropertyCondition" AS ENUM ('NEW', 'LIKE_NEW', 'RENOVATED', 'USED');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Property"
|
||||
ADD COLUMN "furnishing" "Furnishing",
|
||||
ADD COLUMN "propertyCondition" "PropertyCondition",
|
||||
ADD COLUMN "balconyDirection" "Direction",
|
||||
ADD COLUMN "maintenanceFeeVND" BIGINT,
|
||||
ADD COLUMN "parkingSlots" INTEGER,
|
||||
ADD COLUMN "viewType" TEXT[] DEFAULT ARRAY[]::TEXT[],
|
||||
ADD COLUMN "petFriendly" BOOLEAN,
|
||||
ADD COLUMN "suitableFor" TEXT[] DEFAULT ARRAY[]::TEXT[],
|
||||
ADD COLUMN "whyThisLocation" TEXT;
|
||||
@@ -252,6 +252,19 @@ enum Direction {
|
||||
SOUTHWEST
|
||||
}
|
||||
|
||||
enum Furnishing {
|
||||
FULLY_FURNISHED
|
||||
BASIC_FURNISHED
|
||||
UNFURNISHED
|
||||
}
|
||||
|
||||
enum PropertyCondition {
|
||||
NEW
|
||||
LIKE_NEW
|
||||
RENOVATED
|
||||
USED
|
||||
}
|
||||
|
||||
model Property {
|
||||
id String @id @default(cuid())
|
||||
propertyType PropertyType
|
||||
@@ -278,6 +291,15 @@ model Property {
|
||||
projectName String?
|
||||
projectDevelopmentId String?
|
||||
projectDevelopment ProjectDevelopment? @relation(fields: [projectDevelopmentId], references: [id], onDelete: SetNull)
|
||||
furnishing Furnishing?
|
||||
propertyCondition PropertyCondition?
|
||||
balconyDirection Direction?
|
||||
maintenanceFeeVND BigInt?
|
||||
parkingSlots Int?
|
||||
viewType String[] @default([])
|
||||
petFriendly Boolean?
|
||||
suitableFor String[] @default([])
|
||||
whyThisLocation String? @db.Text
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
|
||||
Reference in New Issue
Block a user