fix: rename Open to View Details and hide empty Details section (refs #43)
All checks were successful
Deploy to Staging / Build Images (pull_request) Successful in 2m45s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 37s
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 2m45s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 37s
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
- Rename "Open" button to "View Details" on desktop and mobile document lists - Add hasDisplayableMetadata helper to check if document has metadata to display - Conditionally render Details section only when metadata exists - Prevents showing empty "Details" header for documents without metadata 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -200,7 +200,7 @@ export const DocumentsMobileScreen: React.FC = () => {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-2 items-center flex-wrap">
|
<div className="flex gap-2 items-center flex-wrap">
|
||||||
<Button onClick={() => navigate(`/garage/documents/${doc.id}`)}>Open</Button>
|
<Button onClick={() => navigate(`/garage/documents/${doc.id}`)}>View Details</Button>
|
||||||
<Button onClick={() => triggerUpload(doc.id)}>Upload</Button>
|
<Button onClick={() => triggerUpload(doc.id)}>Upload</Button>
|
||||||
{upload.isPending && currentId === doc.id && (
|
{upload.isPending && currentId === doc.id && (
|
||||||
<span className="text-xs text-slate-500">{upload.progress}%</span>
|
<span className="text-xs text-slate-500">{upload.progress}%</span>
|
||||||
|
|||||||
@@ -27,6 +27,25 @@ export const DocumentDetailPage: React.FC = () => {
|
|||||||
|
|
||||||
const vehiclesMap = useMemo(() => new Map(vehicles?.map(v => [v.id, v]) || []), [vehicles]);
|
const vehiclesMap = useMemo(() => new Map(vehicles?.map(v => [v.id, v]) || []), [vehicles]);
|
||||||
|
|
||||||
|
// Check if document has displayable metadata
|
||||||
|
const hasDisplayableMetadata = useMemo(() => {
|
||||||
|
if (!doc) return false;
|
||||||
|
const details = doc.details || {};
|
||||||
|
|
||||||
|
if (doc.documentType === 'insurance') {
|
||||||
|
return !!(doc.expirationDate || details.policyNumber || details.insuranceCompany ||
|
||||||
|
doc.issuedDate || details.bodilyInjuryPerson || details.bodilyInjuryIncident ||
|
||||||
|
details.propertyDamage || details.premium);
|
||||||
|
}
|
||||||
|
if (doc.documentType === 'registration') {
|
||||||
|
return !!(doc.expirationDate || details.licensePlate || details.cost);
|
||||||
|
}
|
||||||
|
if (doc.documentType === 'manual') {
|
||||||
|
return !!(doc.issuedDate || doc.notes);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}, [doc]);
|
||||||
|
|
||||||
const handleDownload = async () => {
|
const handleDownload = async () => {
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
const blob = await documentsApi.download(id);
|
const blob = await documentsApi.download(id);
|
||||||
@@ -167,7 +186,7 @@ export const DocumentDetailPage: React.FC = () => {
|
|||||||
{getVehicleLabel(vehicle)}
|
{getVehicleLabel(vehicle)}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<DocumentCardMetadata doc={doc} variant="mobile" />
|
{hasDisplayableMetadata && <DocumentCardMetadata doc={doc} variant="mobile" />}
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
@@ -262,11 +281,13 @@ export const DocumentDetailPage: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Type-specific Metadata */}
|
{/* Type-specific Metadata - only show if there's data */}
|
||||||
<div>
|
{hasDisplayableMetadata && (
|
||||||
<div className="text-sm text-slate-500 dark:text-titanio mb-2">Details</div>
|
<div>
|
||||||
<DocumentCardMetadata doc={doc} variant="detail" />
|
<div className="text-sm text-slate-500 dark:text-titanio mb-2">Details</div>
|
||||||
</div>
|
<DocumentCardMetadata doc={doc} variant="detail" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Actions */}
|
{/* Actions */}
|
||||||
<div className="pt-2 border-t border-slate-200 dark:border-silverstone">
|
<div className="pt-2 border-t border-slate-200 dark:border-silverstone">
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ export const DocumentsPage: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="flex gap-2 pt-2">
|
<div className="flex gap-2 pt-2">
|
||||||
<Button onClick={() => navigate(`/garage/documents/${doc.id}`)}>Open</Button>
|
<Button onClick={() => navigate(`/garage/documents/${doc.id}`)}>View Details</Button>
|
||||||
<Button variant="danger" onClick={() => removeDoc.mutate(doc.id)}>Delete</Button>
|
<Button variant="danger" onClick={() => removeDoc.mutate(doc.id)}>Delete</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user