Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ehasa-frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WIMMA Lab 2019
Overflow
ehasa-frontend
Commits
d58dd0b9
Commit
d58dd0b9
authored
5 years ago
by
Taneli Riihimäki
Browse files
Options
Downloads
Plain Diff
Merged join game update fix
parents
46736d13
1304a31e
No related branches found
No related tags found
2 merge requests
!46
Development to testing
,
!38
Join game update fix
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/GameView.js
+22
-15
22 additions, 15 deletions
src/components/GameView.js
src/components/JoinGameForm.js
+1
-1
1 addition, 1 deletion
src/components/JoinGameForm.js
with
23 additions
and
16 deletions
src/components/GameView.js
+
22
−
15
View file @
d58dd0b9
...
@@ -23,8 +23,27 @@ export default class GameView extends React.Component {
...
@@ -23,8 +23,27 @@ export default class GameView extends React.Component {
componentDidMount
()
{
componentDidMount
()
{
let
gameId
=
new
URL
(
window
.
location
.
href
).
searchParams
.
get
(
"
id
"
);
let
gameId
=
new
URL
(
window
.
location
.
href
).
searchParams
.
get
(
"
id
"
);
this
.
getGameInfo
(
gameId
);
this
.
getPlayerRole
(
gameId
);
}
getPlayerRole
(
gameId
)
{
let
token
=
sessionStorage
.
getItem
(
"
token
"
);
let
token
=
sessionStorage
.
getItem
(
"
token
"
);
fetch
(
`
${
process
.
env
.
REACT_APP_API_URL
}
/faction/check-faction/
${
gameId
}
`
,
{
method
:
"
GET
"
,
headers
:
{
Authorization
:
"
Bearer
"
+
token
}
})
.
then
(
res
=>
res
.
json
())
.
then
(
res
=>
{
this
.
setState
({
role
:
res
.
role
});
})
.
catch
(
error
=>
console
.
log
(
error
));
}
getGameInfo
(
gameId
)
{
fetch
(
`
${
process
.
env
.
REACT_APP_API_URL
}
/game/
${
gameId
}
`
)
fetch
(
`
${
process
.
env
.
REACT_APP_API_URL
}
/game/
${
gameId
}
`
)
.
then
(
res
=>
{
.
then
(
res
=>
{
if
(
!
res
.
ok
)
{
if
(
!
res
.
ok
)
{
...
@@ -42,19 +61,6 @@ export default class GameView extends React.Component {
...
@@ -42,19 +61,6 @@ export default class GameView extends React.Component {
alert
(
"
Game not found
"
);
alert
(
"
Game not found
"
);
window
.
document
.
location
.
href
=
"
/
"
;
window
.
document
.
location
.
href
=
"
/
"
;
});
});
// Get Role
fetch
(
`
${
process
.
env
.
REACT_APP_API_URL
}
/faction/check-faction/
${
gameId
}
`
,
{
method
:
"
GET
"
,
headers
:
{
Authorization
:
"
Bearer
"
+
token
}
})
.
then
(
res
=>
res
.
json
())
.
then
(
res
=>
{
this
.
setState
({
role
:
res
.
role
});
})
.
catch
(
error
=>
console
.
log
(
error
));
}
}
handleLeaveFaction
=
e
=>
{
handleLeaveFaction
=
e
=>
{
...
@@ -79,6 +85,7 @@ export default class GameView extends React.Component {
...
@@ -79,6 +85,7 @@ export default class GameView extends React.Component {
})
})
.
then
(
res
=>
{
.
then
(
res
=>
{
alert
(
res
.
message
);
alert
(
res
.
message
);
this
.
getPlayerRole
(
this
.
state
.
gameInfo
.
id
);
})
})
.
catch
(
error
=>
console
.
log
(
error
));
.
catch
(
error
=>
console
.
log
(
error
));
};
};
...
@@ -182,7 +189,7 @@ export default class GameView extends React.Component {
...
@@ -182,7 +189,7 @@ export default class GameView extends React.Component {
gameId={this.state.gameInfo.id}
gameId={this.state.gameInfo.id}
toggleView={() => this.setState({ form: "" })}
toggleView={() => this.setState({ form: "" })}
onEditSave={() => {
onEditSave={() => {
this.getGameInfo();
this.getGameInfo(
this.state.gameInfo.id
);
}}
}}
/>
/>
)}
)}
...
@@ -190,7 +197,7 @@ export default class GameView extends React.Component {
...
@@ -190,7 +197,7 @@ export default class GameView extends React.Component {
<JoinGameForm
<JoinGameForm
gameId={this.state.gameInfo.id}
gameId={this.state.gameInfo.id}
toggleView={() => this.setState({ form: "" })}
toggleView={() => this.setState({ form: "" })}
onJoin={() =>
console.log("joinde"
)}
onJoin={() =>
this.getPlayerRole(this.state.gameInfo.id
)}
/>
/>
)}
)}
{this.state.form === "players" && (
{this.state.form === "players" && (
...
...
This diff is collapsed.
Click to expand it.
src/components/JoinGameForm.js
+
1
−
1
View file @
d58dd0b9
...
@@ -14,7 +14,7 @@ export default class JoinGameForm extends React.Component {
...
@@ -14,7 +14,7 @@ export default class JoinGameForm extends React.Component {
}
}
// Get game info
// Get game info
//TODO: from props
//TODO:
gameinfo
from props
componentDidMount
()
{
componentDidMount
()
{
if
(
this
.
props
.
gameId
===
undefined
)
{
if
(
this
.
props
.
gameId
===
undefined
)
{
alert
(
"
game not selected
"
);
alert
(
"
game not selected
"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment