initial implementation
This commit is contained in:
parent
1cf762254c
commit
262fa0636d
@ -17,7 +17,8 @@ export default function Create() {
|
|||||||
|
|
||||||
postData("/api/gameproposal", request)
|
postData("/api/gameproposal", request)
|
||||||
.then((responce) => {
|
.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() {
|
function Definitions() {
|
||||||
const [ctx] = React.useContext(AppContext)
|
const [ctx, dispatchCtx] = React.useContext(AppContext)
|
||||||
const [data] = React.useContext(AppData)
|
const [data] = React.useContext(AppData)
|
||||||
|
|
||||||
const isCurrentUser = data.isCurrentUser
|
const isCurrentUser = data.isCurrentUser
|
||||||
@ -54,7 +55,7 @@ function Definitions() {
|
|||||||
opponentName,
|
opponentName,
|
||||||
opponentColor,
|
opponentColor,
|
||||||
board: null,
|
board: null,
|
||||||
message: "let's play a game"
|
message: ctx.newGame.message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,6 +65,7 @@ function Definitions() {
|
|||||||
isEnabled,
|
isEnabled,
|
||||||
|
|
||||||
get_GameProposalRequest,
|
get_GameProposalRequest,
|
||||||
|
clear_Message2Opponent: () => { dispatchCtx({ update: "newGame", message: '' }) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +83,7 @@ function get_Opponent(isCurrentUser, whitePlayerName, blackPlayerName) {
|
|||||||
|
|
||||||
async function postData(url = "", data = {}) {
|
async function postData(url = "", data = {}) {
|
||||||
console.log("POST", url, data)
|
console.log("POST", url, data)
|
||||||
|
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
.message2opponent {
|
.message2opponent input{
|
||||||
border-radius: 3px;
|
width: 270px;
|
||||||
border-color: lightgray;
|
|
||||||
background-color:violet;
|
|
||||||
width: 70%;
|
|
||||||
}
|
}
|
@ -4,12 +4,20 @@ import React from 'react'
|
|||||||
import { AppContext } from '../../context/app'
|
import { AppContext } from '../../context/app'
|
||||||
|
|
||||||
export default function Message2Opponent() {
|
export default function Message2Opponent() {
|
||||||
|
const [ctx, dispatchCtx] = React.useContext(AppContext)
|
||||||
|
|
||||||
const [ctx] = React.useContext(AppContext)
|
const setMessage = (message) => {
|
||||||
|
dispatchCtx({ update: "newGame", message })
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='message2opponent'>
|
<div className='message2opponent'>
|
||||||
Message to opponent
|
<input
|
||||||
|
placeholder='Message to opponent'
|
||||||
|
value={ctx.newGame.message}
|
||||||
|
maxLength={150}
|
||||||
|
onChange={e => setMessage(e.target.value)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ export const initialState = {
|
|||||||
newGame: {
|
newGame: {
|
||||||
whitePlayer: '',
|
whitePlayer: '',
|
||||||
blackPlayer: '',
|
blackPlayer: '',
|
||||||
|
message: '',
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user