Board.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { SettingsSvg } from '../_shared/svg/SettingsSvg';
  2. import { SearchInput } from '../_shared/SearchInput';
  3. import { useDatabase } from '../_shared/Database.hooks';
  4. import { BoardBlock } from './BoardBlock';
  5. import { NewBoardBlock } from './NewBoardBlock';
  6. import { IDatabaseRow } from '../../stores/reducers/database/slice';
  7. import { useBoard } from './Board.hooks';
  8. export const Board = () => {
  9. const { database, newField, renameField, newRow } = useDatabase();
  10. const {
  11. title,
  12. boardColumns,
  13. groupingFieldId,
  14. changeGroupingField,
  15. startMove,
  16. endMove,
  17. onGhostItemMove,
  18. movingRowId,
  19. ghostLocation,
  20. } = useBoard();
  21. return (
  22. <>
  23. <div className='flex w-full items-center justify-between'>
  24. <div className={'flex items-center text-xl font-semibold'}>
  25. <div>{title}</div>
  26. <button className={'ml-2 h-5 w-5'}>
  27. <SettingsSvg></SettingsSvg>
  28. </button>
  29. </div>
  30. <div className='flex shrink-0 items-center gap-4'>
  31. <SearchInput />
  32. </div>
  33. </div>
  34. <div className={'relative w-full flex-1 overflow-auto'}>
  35. <div className={'absolute flex h-full flex-shrink-0 items-start justify-start gap-4'}>
  36. {database &&
  37. boardColumns?.map((column, index) => (
  38. <BoardBlock
  39. key={index}
  40. title={column.title}
  41. groupingFieldId={groupingFieldId}
  42. count={column.rows.length}
  43. fields={database.fields}
  44. columns={database.columns}
  45. rows={column.rows}
  46. startMove={startMove}
  47. endMove={endMove}
  48. />
  49. ))}
  50. <NewBoardBlock onClick={() => console.log('new block')}></NewBoardBlock>
  51. </div>
  52. </div>
  53. </>
  54. );
  55. };