PlaylistTableRows.tsx 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import React, { FC } from 'react';
  2. import { PlaylistTableRow } from './PlaylistTableRow';
  3. import { PlaylistItem } from './types';
  4. interface PlaylistTableRowsProps {
  5. items: PlaylistItem[];
  6. onMoveUp: (item: PlaylistItem) => void;
  7. onMoveDown: (item: PlaylistItem) => void;
  8. onDelete: (item: PlaylistItem) => void;
  9. }
  10. export const PlaylistTableRows: FC<PlaylistTableRowsProps> = ({ items, onMoveUp, onMoveDown, onDelete }) => {
  11. if (items.length === 0) {
  12. return (
  13. <tr>
  14. <td>
  15. <em>Playlist is empty. Add dashboards below.</em>
  16. </td>
  17. </tr>
  18. );
  19. }
  20. return (
  21. <>
  22. {items.map((item, index) => {
  23. const first = index === 0;
  24. const last = index === items.length - 1;
  25. return (
  26. <PlaylistTableRow
  27. first={first}
  28. last={last}
  29. item={item}
  30. onDelete={onDelete}
  31. onMoveDown={onMoveDown}
  32. onMoveUp={onMoveUp}
  33. key={item.title}
  34. />
  35. );
  36. })}
  37. </>
  38. );
  39. };