From 73389ad516af4cb49873cc19c2dc65efc77d6eb8 Mon Sep 17 00:00:00 2001 From: Joffrey BION Date: Sat, 9 Jun 2018 13:36:45 +0200 Subject: Split GameBrowser into multiple connected components --- frontend/src/components/game-browser/GameList.jsx | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 frontend/src/components/game-browser/GameList.jsx (limited to 'frontend/src/components/game-browser/GameList.jsx') diff --git a/frontend/src/components/game-browser/GameList.jsx b/frontend/src/components/game-browser/GameList.jsx new file mode 100644 index 00000000..e3601d51 --- /dev/null +++ b/frontend/src/components/game-browser/GameList.jsx @@ -0,0 +1,37 @@ +// @flow +import { Button, Text } from '@blueprintjs/core'; +import type { List } from 'immutable'; +import React from 'react'; +import { connect } from 'react-redux'; +import { Flex } from 'reflexbox'; +import type { Game } from '../../models/games'; +import { actions, getAllGames } from '../../redux/games'; + +type GameListProps = { + games: List, + joinGame: (gameId: string) => void, +}; + +const GameListPresenter = ({ games, joinGame }: GameListProps) => ( +
+ {games.map((game: Game, index: number) => { + return ( + + {game.name} + + + ); + })} +
+); + +const mapStateToProps = state => ({ + games: getAllGames(state.get('games')), +}); + +const mapDispatchToProps = { + joinGame: actions.requestJoinGame, +}; + +export const GameList = connect(mapStateToProps, mapDispatchToProps)(GameListPresenter); + -- cgit