'use client' import { MaintenanceHistory } from '@prisma/client' import { formatDate, formatCurrency } from '@/lib/utils' import { useState } from 'react' import MaintenanceForm from './MaintenanceForm' interface MaintenanceTimelineProps { partId: string history: MaintenanceHistory[] onUpdate: () => void } const actionLabels: Record = { INSTALL: 'Installiert', REPLACE: 'Ersetzt', SERVICE: 'Gewartet', CHECK: 'Geprüft', ADJUST: 'Eingestellt', } export default function MaintenanceTimeline({ partId, history, onUpdate, }: MaintenanceTimelineProps) { const [showForm, setShowForm] = useState(false) return (

Wartungshistorie

{showForm && (
{ setShowForm(false) onUpdate() }} onCancel={() => setShowForm(false)} />
)} {history.length === 0 ? (

Noch keine Wartungseinträge.

) : (
{history.map((entry) => (
{actionLabels[entry.action] || entry.action} {formatDate(entry.date)}
Kilometerstand: {entry.mileage} km {entry.cost && ( Kosten: {formatCurrency(entry.cost)} )}
{entry.notes && (

{entry.notes}

)}
))}
)}
) }