import { observer } from 'mobx-react-lite';
import React from 'react';
import * as DashboardStoreNs from '../dashboard-store';
import * as IssuesListBoardsNs from '../../issues-list-board/issues-list-boards';
import * as KanbanBoardStoreNs from '../../kanban-board/store';
import { onSnapshot } from 'mobx-state-tree';

export type Props = {
  store: DashboardStoreNs.IWidget;
};

export const IssuesList = observer((props: Props): JSX.Element => {
  const store = KanbanBoardStoreNs.PageStore.create({ loaded: false });
  onSnapshot(props.store, (state) => {
    if (state?.data) store.setData(state?.data);
  });
  return <IssuesListBoardsNs.IssuesListBoards store={store} />;
});
