diff --git a/webapp/src/components/Game/GameAction/Create.jsx b/webapp/src/components/Game/GameAction/Create.jsx index c78fff0..bbcc817 100644 --- a/webapp/src/components/Game/GameAction/Create.jsx +++ b/webapp/src/components/Game/GameAction/Create.jsx @@ -17,7 +17,8 @@ export default function Create() { postData("/api/gameproposal", request) .then((responce) => { - console.log("responce", responce); // JSON data parsed by `data.json()` call + console.log("responce", responce) // JSON data parsed by `data.json()` call + ctx.clear_Message2Opponent() }); } @@ -32,7 +33,7 @@ export default function Create() { } function Definitions() { - const [ctx] = React.useContext(AppContext) + const [ctx, dispatchCtx] = React.useContext(AppContext) const [data] = React.useContext(AppData) const isCurrentUser = data.isCurrentUser @@ -54,7 +55,7 @@ function Definitions() { opponentName, opponentColor, board: null, - message: "let's play a game" + message: ctx.newGame.message } } @@ -64,6 +65,7 @@ function Definitions() { isEnabled, get_GameProposalRequest, + clear_Message2Opponent: () => { dispatchCtx({ update: "newGame", message: '' }) } } } @@ -81,7 +83,7 @@ function get_Opponent(isCurrentUser, whitePlayerName, blackPlayerName) { async function postData(url = "", data = {}) { console.log("POST", url, data) - + const response = await fetch(url, { method: "POST", headers: { diff --git a/webapp/src/components/Game/Message2Opponent.css b/webapp/src/components/Game/Message2Opponent.css index 6110b41..cb2abb7 100644 --- a/webapp/src/components/Game/Message2Opponent.css +++ b/webapp/src/components/Game/Message2Opponent.css @@ -1,6 +1,3 @@ -.message2opponent { - border-radius: 3px; - border-color: lightgray; - background-color:violet; - width: 70%; +.message2opponent input{ + width: 270px; } \ No newline at end of file diff --git a/webapp/src/components/Game/Message2Opponent.jsx b/webapp/src/components/Game/Message2Opponent.jsx index 4bda210..f341afe 100644 --- a/webapp/src/components/Game/Message2Opponent.jsx +++ b/webapp/src/components/Game/Message2Opponent.jsx @@ -4,12 +4,20 @@ import React from 'react' import { AppContext } from '../../context/app' export default function Message2Opponent() { + const [ctx, dispatchCtx] = React.useContext(AppContext) - const [ctx] = React.useContext(AppContext) + const setMessage = (message) => { + dispatchCtx({ update: "newGame", message }) + } return (