{/* Header */} setExpanded(!expanded)} aria-expanded={expanded} aria-controls={`item-${item.id}-details`} > {/* Type icon */} {itemType.icon} {/* Main content */} {description} {/* PO and Order numbers — always visible in compact mode */} {compact && (poNumber || orderNumber) && ( {poNumber && ( PO: {poNumber} )} {poNumber && orderNumber && ( · )} {orderNumber && ( Order: {orderNumber} )} )} {/* If the customer-facing description differs from the supplier-facing one we just rendered, surface the customer one as a smaller sub-line so the driver can spot a discrepancy on pickup. */} {item.description && item.po_description && item.description.trim() !== item.po_description.trim() && ( customer line: {item.description} )} {itemType.label} Qty: {expectedQty} {item.sku && ( #{item.sku} )} {item.assigned_at && ( assigned {formatDate(item.assigned_at)} )} {supplier?.suppliername && !compact && ( {supplier.suppliername} )} {/* Right side — tooltip buttons always visible in compact mode */} {compact ? ( {/* Price + chevron row */} {item.selling_price && expectedQty > 0 && ( {formatCurrency(item.selling_price * expectedQty)} )} {expanded ? ( ) : ( )} {/* Always-visible tooltip buttons — shown as a row of 2 */} {/* PO tooltip button */} { e.stopPropagation(); measurePoPlacement(); setShowPoTooltip(v => !v); setShowNotesTooltip(false); }} aria-label="Show PO details" aria-expanded={showPoTooltip} className="w-6 h-6 rounded-md flex items-center justify-center bg-[#6c5a99] text-white active:bg-[#4a3d6b] transition-colors" > {/* PO tooltip popover */} {showPoTooltip && ( {po ? ( <> Purchase Order { e.stopPropagation(); setShowPoTooltip(false); }} aria-label="Close" className="w-5 h-5 rounded flex items-center justify-center hover:bg-[rgba(38,37,30,0.08)]" > × PO Number {po.po_number} {po.status && ( Status {po.status} )} {po.total_amount != null && ( Total R{(po.total_amount / 100).toFixed(2)} )} {orderNumber && ( Order {orderNumber} )} { e.stopPropagation(); setShowPoTooltip(false); onShowDetails(item); }} className="mt-3 w-full flex items-center justify-center gap-2 py-2 rounded-lg bg-[#6c5a99] text-white text-[12px] font-semibold active:bg-[#4a3d6b] transition-colors" > View PO & Document > ) : ( No PO attached { e.stopPropagation(); setShowPoTooltip(false); onShowDetails(item); }} className="mt-2 text-[11px] text-[#6c5a99] font-medium hover:underline" > View details )} )} {/* Notes tooltip button */} {hasAnyNotes && ( { e.stopPropagation(); measureNotesPlacement(); setShowNotesTooltip(v => !v); setShowPoTooltip(false); }} aria-label="Show notes" aria-expanded={showNotesTooltip} className="w-6 h-6 rounded-md flex items-center justify-center bg-[#8a5a02] text-white active:bg-[#6b4501] transition-colors" > {/* Notes tooltip popover */} {showNotesTooltip && ( Buyer Notes { e.stopPropagation(); setShowNotesTooltip(false); }} aria-label="Close" className="w-5 h-5 rounded flex items-center justify-center hover:bg-[rgba(38,37,30,0.08)]" > × {hasNotes ? ( <> {item.notes} {hasProblemNotes && ( Problem: {item.problem_notes} )} > ) : hasProblemNotes ? ( {item.problem_notes} ) : ( No notes )} )} )} ) : ( /* Full/non-compact right side */ {item.selling_price && expectedQty > 0 && ( {formatCurrency(item.selling_price * expectedQty)} )} {expanded ? ( ) : ( )} )} {/* Expanded Details */} {expanded && ( {/* Notes */} {item.notes && ( {item.notes} )} {item.problem_notes && ( {item.problem_notes} )} {/* Details grid */} {orderNumber && ( Order {orderNumber} )} {poNumber && ( PO {poNumber} )} {supplier?.supplieraddress && ( Address {supplier.supplieraddress} )} {/* Action Buttons */} {/* Row 1 — core workflow */} onCollect(item)} aria-label={`Mark ${description} as collected`} className="flex flex-col items-center justify-center gap-1 py-3 rounded-xl bg-[#1f8a65] text-white active:bg-[#125a3e] transition-colors touch-manipulation press-feedback-sm min-h-[56px]" > Collect onProblem(item)} aria-label={`Report problem with ${description}`} className="flex flex-col items-center justify-center gap-1 py-3 rounded-xl bg-[#cf2d56] text-white active:bg-[#8a1b3a] transition-colors touch-manipulation press-feedback-sm min-h-[56px]" > Problem {hasCoords && coords && supplier ? ( onNavigate(coords.latitude, coords.longitude, supplier.suppliername)} aria-label={`Navigate to ${supplier.suppliername}`} className="flex flex-col items-center justify-center gap-1 py-3 rounded-xl bg-[#f54e00] text-white active:bg-[#d44200] transition-colors touch-manipulation press-feedback-sm min-h-[56px]" > Navigate ) : ( No GPS )} {/* Row 2 — PO document and buyer notes */} onShowDetails(item)} aria-label={`View PO document for ${description}`} className="flex flex-col items-center justify-center gap-1 py-3 rounded-xl bg-[#6c5a99] text-white active:bg-[#4a3d6b] transition-colors touch-manipulation press-feedback-sm min-h-[56px]" > View PO onShowDetails(item)} aria-label={`View buyer notes for ${description}`} className="flex flex-col items-center justify-center gap-1 py-3 rounded-xl bg-[#8a5a02] text-white active:bg-[#6b4501] transition-colors touch-manipulation press-feedback-sm min-h-[56px]" > Buyer Notes )}