fix: align Project status enum to Prisma + cascade child records on listing delete
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 10s
CI / E2E Tests (push) Has been skipped
CodeQL Analysis / CodeQL (javascript-typescript) (push) Failing after 31s
E2E Tests / Playwright E2E (push) Failing after 7s
Security Scanning / Dependency Audit (pnpm) (push) Failing after 3s
Security Scanning / Trivy Scan — API Image (push) Failing after 34s
Security Scanning / Trivy Scan — Web Image (push) Failing after 23s
Security Scanning / Trivy Scan — AI Services Image (push) Failing after 25s
Security Scanning / Trivy Filesystem Scan (push) Failing after 26s
Deploy / Smoke Test Staging (push) Has been skipped
Deploy / Deploy to Production (push) Has been skipped
Deploy / Build API Image (push) Failing after 16s
Deploy / Build Web Image (push) Failing after 9s
Deploy / Build AI Services Image (push) Failing after 8s
Deploy / Deploy to Staging (push) Has been skipped
Deploy / Smoke Test Production (push) Has been skipped
Security Scanning / Security Gate (push) Failing after 0s
Deploy / Rollback Staging (push) Has been skipped
Deploy / Rollback Production (push) Has been skipped
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 10s
CI / E2E Tests (push) Has been skipped
CodeQL Analysis / CodeQL (javascript-typescript) (push) Failing after 31s
E2E Tests / Playwright E2E (push) Failing after 7s
Security Scanning / Dependency Audit (pnpm) (push) Failing after 3s
Security Scanning / Trivy Scan — API Image (push) Failing after 34s
Security Scanning / Trivy Scan — Web Image (push) Failing after 23s
Security Scanning / Trivy Scan — AI Services Image (push) Failing after 25s
Security Scanning / Trivy Filesystem Scan (push) Failing after 26s
Deploy / Smoke Test Staging (push) Has been skipped
Deploy / Deploy to Production (push) Has been skipped
Deploy / Build API Image (push) Failing after 16s
Deploy / Build Web Image (push) Failing after 9s
Deploy / Build AI Services Image (push) Failing after 8s
Deploy / Deploy to Staging (push) Has been skipped
Deploy / Smoke Test Production (push) Has been skipped
Security Scanning / Security Gate (push) Failing after 0s
Deploy / Rollback Staging (push) Has been skipped
Deploy / Rollback Production (push) Has been skipped
Project status was declared on the frontend as UPCOMING/SELLING/HANDOVER/COMPLETED but the Prisma enum ProjectDevelopmentStatus is PLANNING/UNDER_CONSTRUCTION/HANDOVER/ COMPLETED — CREATE failed with "status must be one of …". Aligned the TypeScript union + PROJECT_STATUS_LABELS/COLORS, filter options on /projects list, and both new + edit forms. Updated the normalizeProjectDetail fallback and the du-an test spec to match. Listings DELETE was blocked by FK references (Inquiry, SavedListing, PriceHistory, Order, Transaction have no onDelete: Cascade in schema). Wrapped the Prisma listing delete in a $transaction that removes the child rows first, then the listing itself, so CRUD from the dashboard actually lands instead of returning "Referenced record does not exist". Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -31,7 +31,7 @@ const editSchema = z.object({
|
||||
'URL không hợp lệ',
|
||||
),
|
||||
status: z
|
||||
.enum(['UPCOMING', 'SELLING', 'HANDOVER', 'COMPLETED'])
|
||||
.enum(['PLANNING', 'UNDER_CONSTRUCTION', 'HANDOVER', 'COMPLETED'])
|
||||
.optional()
|
||||
.or(z.literal('')),
|
||||
totalUnits: z
|
||||
@@ -281,8 +281,8 @@ export default function EditProjectPage() {
|
||||
<Label htmlFor="status">Trạng thái</Label>
|
||||
<Select id="status" {...register('status')}>
|
||||
<option value="">-- Giữ nguyên --</option>
|
||||
<option value="UPCOMING">Sắp mở bán</option>
|
||||
<option value="SELLING">Đang bán</option>
|
||||
<option value="PLANNING">Đang quy hoạch</option>
|
||||
<option value="UNDER_CONSTRUCTION">Đang xây dựng</option>
|
||||
<option value="HANDOVER">Đang bàn giao</option>
|
||||
<option value="COMPLETED">Đã hoàn thành</option>
|
||||
</Select>
|
||||
|
||||
@@ -31,7 +31,7 @@ const projectSchema = z.object({
|
||||
(v) => !v || /^https?:\/\//.test(v),
|
||||
'URL không hợp lệ',
|
||||
),
|
||||
status: z.enum(['UPCOMING', 'SELLING', 'HANDOVER', 'COMPLETED']),
|
||||
status: z.enum(['PLANNING', 'UNDER_CONSTRUCTION', 'HANDOVER', 'COMPLETED']),
|
||||
totalUnits: z
|
||||
.string()
|
||||
.min(1, 'Bắt buộc')
|
||||
@@ -125,7 +125,7 @@ export default function CreateProjectPage() {
|
||||
resolver: zodResolver(projectSchema),
|
||||
mode: 'onTouched',
|
||||
defaultValues: {
|
||||
status: 'UPCOMING',
|
||||
status: 'PLANNING',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -252,8 +252,8 @@ export default function CreateProjectPage() {
|
||||
Trạng thái <span className="text-destructive">*</span>
|
||||
</Label>
|
||||
<Select id="status" {...register('status')}>
|
||||
<option value="UPCOMING">Sắp mở bán</option>
|
||||
<option value="SELLING">Đang bán</option>
|
||||
<option value="PLANNING">Đang quy hoạch</option>
|
||||
<option value="UNDER_CONSTRUCTION">Đang xây dựng</option>
|
||||
<option value="HANDOVER">Đang bàn giao</option>
|
||||
<option value="COMPLETED">Đã hoàn thành</option>
|
||||
</Select>
|
||||
|
||||
@@ -21,8 +21,8 @@ import {
|
||||
import { shimmerBlurDataURL } from '@/lib/image-blur';
|
||||
|
||||
const STATUS_OPTIONS: { value: ProjectStatus; label: string }[] = [
|
||||
{ value: 'UPCOMING', label: PROJECT_STATUS_LABELS.UPCOMING },
|
||||
{ value: 'SELLING', label: PROJECT_STATUS_LABELS.SELLING },
|
||||
{ value: 'PLANNING', label: PROJECT_STATUS_LABELS.PLANNING },
|
||||
{ value: 'UNDER_CONSTRUCTION', label: PROJECT_STATUS_LABELS.UNDER_CONSTRUCTION },
|
||||
{ value: 'HANDOVER', label: PROJECT_STATUS_LABELS.HANDOVER },
|
||||
{ value: 'COMPLETED', label: PROJECT_STATUS_LABELS.COMPLETED },
|
||||
];
|
||||
|
||||
@@ -61,7 +61,7 @@ const mockSearchData = {
|
||||
id: 'proj-1',
|
||||
slug: 'vinhomes-grand-park',
|
||||
name: 'Vinhomes Grand Park',
|
||||
status: 'SELLING' as const,
|
||||
status: 'UNDER_CONSTRUCTION' as const,
|
||||
developer: { id: 'dev-1', name: 'Vingroup', logoUrl: null, totalProjects: 10 },
|
||||
city: 'Hồ Chí Minh',
|
||||
district: 'Quận 9',
|
||||
|
||||
Reference in New Issue
Block a user