| Product Name | +SKU | +SKU Code | +BR Code | +Bags | +
|---|---|---|---|---|
| {item.product_name_3 || item.product_category_3 || '-'} | +{item.sku_3 || '-'} | ++ + {skuCode} + + | +{item.br_code_3 || '-'} | +{item.bags_3 || '-'} | +
| {col.name} | + ))} + {(onEdit || onDelete) && ( +Actions | + )} +
|---|---|
| + {displayVal} + | + ); + })} + {(onEdit || onDelete) && ( +
+
+ {onEdit && (
+
+ )}
+ {onDelete && (
+
+ )}
+
+ |
+ )}
+
| Product | +Potential (Kgs) | + {!hideOrderDetails && ( + <> +Ordered (Kgs) | +Difference | + > + )} + {(onEdit || onDelete) && ( +Actions | + )} +
|---|---|---|---|---|
|
+
+ {item.productName}
+ {item.badge && (
+
+ {item.badge.label}
+
+ )}
+
+ |
+ + {item.potentialKgs} + | + {!hideOrderDetails && ( + <> ++ {item.orderedKgs} + | +
+
+
+
+
+
+ {isSurplus ? (
+
+
+ {isSurplus ? 'Surplus' : 'Shortfall'}
+
+ |
+ >
+ )}
+ {(onEdit || onDelete) && (
+
+
+ {onEdit && (
+
+ )}
+ {onDelete && (
+
+ )}
+
+ |
+ )}
+
+
+ {(tile.value as React.ReactNode) ?? "-"} +
+| onRowClick(row, i) : undefined} className={cn( - 'bg-surface border-b border-border-subtle transition-colors duration-150', - onRowClick && 'cursor-pointer hover:bg-slate-50', + 'bg-[var(--z-rv-table-bg)] border-b border-[var(--z-rv-table-border)] transition-colors duration-150', + onRowClick && 'cursor-pointer hover:bg-[var(--table-row-bg-select)]', )} > - {fields.map((f) => ( - | - {formatValue(row[f.field_key], f.field_key)} - | - ))} + {fields.map((f) => { + const lowerKey = f.field_key.toLowerCase(); + const isSku = lowerKey === 'sku_code'; + const isStatus = lowerKey.includes('status') || lowerKey.includes('state'); + const valStr = formatValue(row[f.field_key], f.field_key); + + let content = <>{valStr}>; + + if (valStr !== '—' && valStr !== '') { + if (isSku || isStatus) { + const palettes = [ + "bg-blue-50 text-blue-700 border-blue-200", + "bg-purple-50 text-purple-700 border-purple-200", + "bg-pink-50 text-pink-700 border-pink-200", + "bg-indigo-50 text-indigo-700 border-indigo-200", + "bg-cyan-50 text-cyan-700 border-cyan-200", + "bg-rose-50 text-rose-700 border-rose-200", + "bg-fuchsia-50 text-fuchsia-700 border-fuchsia-200", + "bg-teal-50 text-teal-700 border-teal-200", + ]; + + let hash = 0; + for (let i = 0; i < valStr.length; i++) { + hash = valStr.charCodeAt(i) + ((hash << 5) - hash); + } + const colorIndex = Math.abs(hash) % palettes.length; + let colorClass = palettes[colorIndex]; + + if (isSku) { + content = ( + + {valStr} + + ); + } else if (isStatus) { + const valLower = valStr.toLowerCase(); + const isSuccess = valLower.includes('approve') || valLower.includes('complete') || valLower.includes('success') || valLower.includes('active'); + const isWarning = valLower.includes('pending') || valLower.includes('draft') || valLower.includes('hold'); + const isDanger = valLower.includes('reject') || valLower.includes('fail') || valLower.includes('cancel'); + + if (isSuccess) colorClass = "bg-emerald-50 text-emerald-700 border-emerald-200"; + else if (isWarning) colorClass = "bg-amber-50 text-amber-700 border-amber-200"; + else if (isDanger) colorClass = "bg-red-50 text-red-700 border-red-200"; + + content = ( + + {valStr} + + ); + } + } + } + + return ( ++ {content} + | + ); + })} {rowActions && (
e.stopPropagation()}>
@@ -276,7 +335,16 @@ export function RecordView({
|
|---|