- Next.js SPA mit Bun Runtime - Prisma mit SQLite Datenbank - Vollständige CRUD-Operationen für Fahrräder, Verschleißteile und Wartungshistorie - Warnsystem für bevorstehende Wartungen - Statistik-Features (Gesamtkosten, durchschnittliche Lebensdauer) - Zod-Validierung für alle API-Requests - Umfassende Test-Suite (41 Tests)
72 lines
1.7 KiB
TypeScript
72 lines
1.7 KiB
TypeScript
import { z } from 'zod'
|
|
|
|
export const WearPartType = z.enum([
|
|
'CHAIN',
|
|
'BRAKE_PADS',
|
|
'TIRE',
|
|
'CASSETTE',
|
|
'CHAINRING',
|
|
'DERAILLEUR',
|
|
'BRAKE_CABLE',
|
|
'SHIFT_CABLE',
|
|
'BRAKE_ROTOR',
|
|
'PEDAL',
|
|
'CRANKSET',
|
|
'BOTTOM_BRACKET',
|
|
'HEADSET',
|
|
'WHEEL',
|
|
'HUB',
|
|
'SPOKE',
|
|
'OTHER',
|
|
])
|
|
|
|
export const WearPartStatus = z.enum([
|
|
'ACTIVE',
|
|
'NEEDS_SERVICE',
|
|
'REPLACED',
|
|
'INACTIVE',
|
|
])
|
|
|
|
export const MaintenanceAction = z.enum([
|
|
'INSTALL',
|
|
'REPLACE',
|
|
'SERVICE',
|
|
'CHECK',
|
|
'ADJUST',
|
|
])
|
|
|
|
export const bikeSchema = z.object({
|
|
name: z.string().min(1, 'Name ist erforderlich'),
|
|
brand: z.string().optional(),
|
|
model: z.string().optional(),
|
|
purchaseDate: z.string().datetime().optional().or(z.date().optional()),
|
|
notes: z.string().optional(),
|
|
})
|
|
|
|
export const wearPartSchema = z.object({
|
|
bikeId: z.string().min(1, 'Fahrrad-ID ist erforderlich'),
|
|
type: WearPartType,
|
|
brand: z.string().optional(),
|
|
model: z.string().optional(),
|
|
installDate: z.string().datetime().or(z.date()),
|
|
installMileage: z.number().int().min(0).default(0),
|
|
serviceInterval: z.number().int().min(1, 'Service-Intervall muss mindestens 1 km sein'),
|
|
status: WearPartStatus.default('ACTIVE'),
|
|
cost: z.number().positive().optional(),
|
|
notes: z.string().optional(),
|
|
})
|
|
|
|
export const maintenanceHistorySchema = z.object({
|
|
wearPartId: z.string().min(1, 'Verschleißteil-ID ist erforderlich'),
|
|
date: z.string().datetime().or(z.date()),
|
|
mileage: z.number().int().min(0),
|
|
action: MaintenanceAction,
|
|
notes: z.string().optional(),
|
|
cost: z.number().positive().optional(),
|
|
})
|
|
|
|
export type BikeInput = z.infer<typeof bikeSchema>
|
|
export type WearPartInput = z.infer<typeof wearPartSchema>
|
|
export type MaintenanceHistoryInput = z.infer<typeof maintenanceHistorySchema>
|
|
|