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 Kanban = observer((props: Props): JSX.Element => {
  const store = KanbanBoardsStoreNs.PageStore.create({ loaded: false });
  onSnapshot(props.store, (state) => {
    if (state?.data) store.setData(state?.data);
  });
  return <KanbanBoardsNs.KanbanBoards store={store} />;
});
