diff --git a/package.json b/package.json index e39198a..55a0395 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "dependencies": { "classnames": "^2.2.5", "immutable": "^3.8.1", + "jquery": "^3.1.1", "lodash": "^4.17.2", "phoenix": "file:deps/phoenix", "phoenix_html": "file:deps/phoenix_html", diff --git a/web/controllers/game_controller.ex b/web/controllers/game_controller.ex new file mode 100644 index 0000000..3e46ecd --- /dev/null +++ b/web/controllers/game_controller.ex @@ -0,0 +1,9 @@ +defmodule Chess.GameController do + use Chess.Web, :controller + + alias Chess.Game + + def show(conn, _params) do + render conn, "show.json", id: 1 + end +end diff --git a/web/static/js/application.js b/web/static/js/application.js index fd5f611..c745ab1 100644 --- a/web/static/js/application.js +++ b/web/static/js/application.js @@ -16,7 +16,7 @@ class App extends React.Component { const { store } = this.props; return ( - + ); } } diff --git a/web/static/js/components/chess-board.js b/web/static/js/components/chess-board.js index e2e4b1a..7b81490 100644 --- a/web/static/js/components/chess-board.js +++ b/web/static/js/components/chess-board.js @@ -1,9 +1,17 @@ import React from "react"; +import $ from "jquery"; import { connect } from "react-redux"; import ChessBoardSquare from "./chess-board-square"; class ChessBoard extends React.Component { + componentWillMount() { + const { gameId } = this.props; + + $.ajax({ method: "GET", url: "/games/" + gameId }) + .then(() => console.log("Oh, hai!")); + } + getBoard() { const { store } = this.props; return store.getState().board; diff --git a/web/views/game_view.ex b/web/views/game_view.ex new file mode 100644 index 0000000..66172de --- /dev/null +++ b/web/views/game_view.ex @@ -0,0 +1,7 @@ +defmodule Chess.GameView do + use Chess.Web, :view + + def render("show.json", %{ id: 1 }) do + %{ foo: :bar } + end +end