feat: expand documents to include manuals

This commit is contained in:
Eric Gullickson
2025-12-25 12:54:00 -06:00
parent 0357ce391f
commit 2ab58267dd
8 changed files with 145 additions and 22 deletions

View File

@@ -36,6 +36,9 @@ export const DocumentForm: React.FC<DocumentFormProps> = ({ onSuccess, onCancel
const [registrationExpirationDate, setRegistrationExpirationDate] = React.useState<string>('');
const [registrationCost, setRegistrationCost] = React.useState<string>('');
// Manual fields
const [scanForMaintenance, setScanForMaintenance] = React.useState<boolean>(false);
const [file, setFile] = React.useState<File | null>(null);
const [uploadProgress, setUploadProgress] = React.useState<number>(0);
const [error, setError] = React.useState<string | null>(null);
@@ -57,6 +60,7 @@ export const DocumentForm: React.FC<DocumentFormProps> = ({ onSuccess, onCancel
setLicensePlate('');
setRegistrationExpirationDate('');
setRegistrationCost('');
setScanForMaintenance(false);
setFile(null);
setUploadProgress(0);
setError(null);
@@ -94,15 +98,17 @@ export const DocumentForm: React.FC<DocumentFormProps> = ({ onSuccess, onCancel
details.cost = registrationCost ? parseFloat(registrationCost) : undefined;
expiration_date = registrationExpirationDate || undefined;
}
// Manual type: no details or dates, just scanForMaintenance flag
const created = await create.mutateAsync({
vehicleId: vehicleID,
documentType: documentType,
title: title.trim(),
notes: notes.trim() || undefined,
details,
details: Object.keys(details).length > 0 ? details : undefined,
issuedDate: issued_date,
expirationDate: expiration_date,
scanForMaintenance: documentType === 'manual' ? scanForMaintenance : undefined,
});
if (file) {
@@ -175,6 +181,7 @@ export const DocumentForm: React.FC<DocumentFormProps> = ({ onSuccess, onCancel
>
<option value="insurance">Insurance</option>
<option value="registration">Registration</option>
<option value="manual">Manual</option>
</select>
</div>
@@ -184,7 +191,11 @@ export const DocumentForm: React.FC<DocumentFormProps> = ({ onSuccess, onCancel
className="h-11 min-h-[44px] rounded-lg border border-slate-300 px-3 focus:outline-none focus:ring-2 focus:ring-primary-500"
type="text"
value={title}
placeholder={documentType === 'insurance' ? 'e.g., Progressive Policy 2025' : 'e.g., Registration 2025'}
placeholder={
documentType === 'insurance' ? 'e.g., Progressive Policy 2025' :
documentType === 'registration' ? 'e.g., Registration 2025' :
'e.g., Honda CBR600RR Service Manual'
}
onChange={(e) => setTitle(e.target.value)}
required
/>
@@ -336,6 +347,23 @@ export const DocumentForm: React.FC<DocumentFormProps> = ({ onSuccess, onCancel
</>
)}
{documentType === 'manual' && (
<div className="flex items-center md:col-span-2">
<label className="flex items-center cursor-pointer">
<input
type="checkbox"
checked={scanForMaintenance}
onChange={(e) => setScanForMaintenance(e.target.checked)}
className="w-5 h-5 rounded border-slate-300 text-primary-600 focus:ring-primary-500"
/>
<span className="ml-2 text-sm font-medium text-slate-700">
Scan for Maintenance Schedule
</span>
</label>
<span className="ml-2 text-xs text-slate-500">(Coming soon)</span>
</div>
)}
<div className="flex flex-col md:col-span-2">
<label className="text-sm font-medium text-slate-700 mb-1">Notes</label>
<textarea