import { Instance, onSnapshot } from 'mobx-state-tree';
import * as DashboardStoreNs from '../dashboard-store';
import { observer } from 'mobx-react-lite';
import * as KanbanBoardsNs from '../../kanban-board/kanban-boards';
import * as KanbanBoardsStoreNs from '../../kanban-board/store';

export type Props = {
  store: Instance<typeof DashboardStoreNs.Widget>;
};

export const KanbanByTree = observer((props: Props): JSX.Element => {
  const store = KanbanBoardsStoreNs.PageStore.create({ loaded: false });
  onSnapshot(props.store, (state) => {
    store.setData(state.data.data);
  });
  return <KanbanBoardsNs.KanbanBoards store={store} />;
});
