RecordList.tsx 802 B

12345678910111213141516171819202122232425262728293031
  1. import { compactValue } from "@/lib/status/status";
  2. export function RecordList({
  3. items,
  4. empty,
  5. primaryKey = "id",
  6. fields
  7. }: {
  8. items: Array<Record<string, unknown>>;
  9. empty: string;
  10. primaryKey?: string;
  11. fields: string[];
  12. }) {
  13. if (!items.length) {
  14. return <div className="empty-state">{empty}</div>;
  15. }
  16. return (
  17. <div className="record-list">
  18. {items.slice(0, 20).map((item, index) => (
  19. <div className="record-row" key={String(item[primaryKey] || index)}>
  20. <strong>{compactValue(item[primaryKey] || item.title || item.search_query || `#${index + 1}`)}</strong>
  21. {fields.map((field) => (
  22. <span key={field}>
  23. {field}: {compactValue(item[field])}
  24. </span>
  25. ))}
  26. </div>
  27. ))}
  28. </div>
  29. );
  30. }