fix: display purchase info and fix validation on vehicle detail (refs #41)
All checks were successful
Deploy to Staging / Build Images (pull_request) Successful in 2m47s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 38s
Deploy to Staging / Verify Staging (pull_request) Successful in 7s
Deploy to Staging / Notify Staging Ready (pull_request) Successful in 6s
Deploy to Staging / Notify Staging Failure (pull_request) Has been skipped
All checks were successful
Deploy to Staging / Build Images (pull_request) Successful in 2m47s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 38s
Deploy to Staging / Verify Staging (pull_request) Successful in 7s
Deploy to Staging / Notify Staging Ready (pull_request) Successful in 6s
Deploy to Staging / Notify Staging Failure (pull_request) Has been skipped
- Add purchase price and purchase date display to vehicle detail page - Fix form validation to handle NaN from empty number inputs using z.preprocess 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,10 +13,13 @@ import { VehicleImageUpload } from './VehicleImageUpload';
|
||||
import { useTierAccess } from '../../../core/hooks/useTierAccess';
|
||||
import { UpgradeRequiredDialog } from '../../../shared-minimal/components/UpgradeRequiredDialog';
|
||||
|
||||
// Helper to convert NaN (from empty number inputs) to null
|
||||
const nanToNull = (val: unknown) => (typeof val === 'number' && isNaN(val) ? null : val);
|
||||
|
||||
const vehicleSchema = z
|
||||
.object({
|
||||
vin: z.string().max(17).nullable().optional().transform(val => val ?? undefined),
|
||||
year: z.number().min(1950).max(new Date().getFullYear() + 1).nullable().optional(),
|
||||
year: z.preprocess(nanToNull, z.number().min(1950).max(new Date().getFullYear() + 1).nullable().optional()),
|
||||
make: z.string().nullable().optional(),
|
||||
model: z.string().nullable().optional(),
|
||||
engine: z.string().nullable().optional(),
|
||||
@@ -27,8 +30,8 @@ const vehicleSchema = z
|
||||
nickname: z.string().nullable().optional(),
|
||||
color: z.string().nullable().optional(),
|
||||
licensePlate: z.string().nullable().optional(),
|
||||
odometerReading: z.number().min(0).nullable().optional(),
|
||||
purchasePrice: z.number().min(0).nullable().optional(),
|
||||
odometerReading: z.preprocess(nanToNull, z.number().min(0).nullable().optional()),
|
||||
purchasePrice: z.preprocess(nanToNull, z.number().min(0).nullable().optional()),
|
||||
purchaseDate: z.string().nullable().optional(),
|
||||
})
|
||||
.refine(
|
||||
|
||||
Reference in New Issue
Block a user