Skip to content

Commit

Permalink
Add API board if is not on the store
Browse files Browse the repository at this point in the history
  • Loading branch information
tomivm committed Jul 4, 2024
1 parent d16d574 commit f8638f2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/components/Board/Board.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -1541,6 +1541,17 @@ export class BoardContainer extends Component {
}
};

handleAddApiBoard = async boardId => {
if (!this.props.boards.find(board => board.id === boardId)) {
try {
const board = await API.getBoard(boardId);
this.props.addBoards([board]);
} catch (err) {
console.log(err.message);
}
}
};

render() {
const {
navHistory,
Expand Down Expand Up @@ -1696,6 +1707,7 @@ export class BoardContainer extends Component {
)}
userData={this.props.userData}
folders={this.props.boards}
onAddApiBoard={this.handleAddApiBoard}
/>
</Fragment>
);
Expand Down
4 changes: 3 additions & 1 deletion src/components/Board/TileEditor/TileEditor.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ export class TileEditor extends Component {
onAddSubmit: PropTypes.func.isRequired,
boards: PropTypes.array,
userData: PropTypes.object,
folders: PropTypes.array
folders: PropTypes.array,
onAddApiBoard: PropTypes.func
};

static defaultProps = {
Expand Down Expand Up @@ -430,6 +431,7 @@ export class TileEditor extends Component {

handleLoadBoardChange = ({ boardId }) => {
if (boardId) {
this.props.onAddApiBoard(boardId);
this.updateTileProperty('loadBoard', boardId);
}
};
Expand Down

0 comments on commit f8638f2

Please sign in to comment.