BoardCard.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { Details2Svg } from '../_shared/svg/Details2Svg';
  2. import { RowInfo } from '$app/stores/effects/database/row/row_cache';
  3. import { useRow } from '../_shared/database-hooks/useRow';
  4. import { DatabaseController } from '$app/stores/effects/database/database_controller';
  5. import { BoardCell } from './BoardCell';
  6. import { Draggable } from 'react-beautiful-dnd';
  7. import { MouseEventHandler } from 'react';
  8. export const BoardCard = ({
  9. index,
  10. viewId,
  11. controller,
  12. rowInfo,
  13. groupByFieldId,
  14. onOpenRow,
  15. }: {
  16. index: number;
  17. viewId: string;
  18. controller: DatabaseController;
  19. rowInfo: RowInfo;
  20. groupByFieldId: string;
  21. onOpenRow: (rowId: RowInfo) => void;
  22. }) => {
  23. const { cells } = useRow(viewId, controller, rowInfo);
  24. const onDetailClick: MouseEventHandler = (e) => {
  25. e.stopPropagation();
  26. // onOpenRow(rowInfo);
  27. };
  28. return (
  29. <Draggable draggableId={rowInfo.row.id} index={index}>
  30. {(provided) => (
  31. <div
  32. ref={provided.innerRef}
  33. {...provided.draggableProps}
  34. {...provided.dragHandleProps}
  35. onClick={() => onOpenRow(rowInfo)}
  36. className={`relative cursor-pointer select-none rounded-lg border border-shade-6 bg-white px-3 py-2 transition-transform duration-100 hover:bg-main-selector `}
  37. >
  38. <button onClick={onDetailClick} className={'absolute right-4 top-2.5 h-5 w-5 rounded hover:bg-surface-2'}>
  39. <Details2Svg></Details2Svg>
  40. </button>
  41. <div className={'flex flex-col gap-3'}>
  42. {cells
  43. .filter((cell) => cell.fieldId !== groupByFieldId)
  44. .map((cell, cellIndex) => (
  45. <BoardCell
  46. key={cellIndex}
  47. cellIdentifier={cell.cellIdentifier}
  48. cellCache={controller.databaseViewCache.getRowCache().getCellCache()}
  49. fieldController={controller.fieldController}
  50. ></BoardCell>
  51. ))}
  52. </div>
  53. </div>
  54. )}
  55. </Draggable>
  56. );
  57. };