import React from 'react'; import { Page } from '../Page'; import { connect } from 'react-redux'; import Board from '@lourenci/react-kanban'; import { fetchIssues } from '../../store/actions/issues'; import { fetchBoards } from '../../store/actions/boards'; import { buildKanboard, moveCard } from '../../store/actions/kanboards'; import { Loader } from '../Loader'; export class BoardPage extends React.Component { render() { return (
{this.renderBoard()}
); } renderBoard() { const { kanboard } = this.props; if (!kanboard) { return } return (
{kanboard}
); } renderCard(card) { return (
{card.title}
); } renderLaneHeader(lane) { return (

{lane.title}

) } onCardDragEnd(source, dest) { const { board } = this.props; this.props.dispatch(moveCard( board.id, source.fromLaneId, source.fromPosition, dest.toLaneId, dest.toPosition )); } componentDidMount() { const { board } = this.props; if (!board) { this.requestBoardsUpdate(); return } this.requestBuildKanboard(); } componentDidUpdate(prevProps) { if (prevProps.board !== this.props.board) this.requestBuildKanboard(); } requestBoardsUpdate() { this.props.dispatch(fetchBoards()); } requestBuildKanboard() { const { board } = this.props; if (!board) return; this.props.dispatch(buildKanboard(board)); } } export const ConnectedBoardPage = connect(function(state, props) { const boardID = props.match.params.id; return { board: state.boards.byID[boardID], kanboard: state.kanboards.byID[boardID] }; })(BoardPage);