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
9bb3a45f
Commit
9bb3a45f
authored
5 years ago
by
Joni Laukka
Browse files
Options
Downloads
Patches
Plain Diff
New game form is now a portal. It does not send any data to server.
parent
210a4e6c
No related branches found
No related tags found
3 merge requests
!21
Development
,
!15
Get game creation to user-marker-database-interactions
,
!13
Resolve "Pelinluontilomake"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
public/index.html
+1
-0
1 addition, 0 deletions
public/index.html
src/App.css
+18
-1
18 additions, 1 deletion
src/App.css
src/components/NewGameForm.js
+38
-33
38 additions, 33 deletions
src/components/NewGameForm.js
with
57 additions
and
34 deletions
public/index.html
+
1
−
0
View file @
9bb3a45f
...
...
@@ -23,6 +23,7 @@
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div
id=
"form"
></div>
<div
id=
"root"
></div>
<!--
This HTML file is a template.
...
...
This diff is collapsed.
Click to expand it.
src/App.css
+
18
−
1
View file @
9bb3a45f
...
...
@@ -51,7 +51,7 @@ div.header button:hover {
div
.fade-main
{
position
:
fixed
;
top
:
0
;
z-index
:
10
0
0
;
z-index
:
10
2
0
;
height
:
100vh
;
width
:
100vw
;
margin
:
auto
;
...
...
@@ -138,3 +138,20 @@ div.login button:hover {
background-color
:
darkblue
;
cursor
:
pointer
;
}
.login
.formDate
{
width
:
30%
;
}
.login
label
.formDate
{
color
:
white
;
width
:
10%
;
margin-left
:
10%
;
font-size
:
180%
;
}
.login
.formTime
{
width
:
30%
;
margin-right
:
20%
;
}
This diff is collapsed.
Click to expand it.
src/components/NewGameForm.js
+
38
−
33
View file @
9bb3a45f
import
React
from
'
react
'
;
import
ReactDOM
from
'
react-dom
'
;
export
class
NewGameForm
extends
React
.
Component
{
constructor
(
props
){
...
...
@@ -21,7 +22,6 @@ export class NewGameForm extends React.Component{
handleChange
=
e
=>
{
const
{
name
,
value
}
=
e
.
target
;
console
.
log
(
value
,
name
);
this
.
setState
({
[
name
]:
value
});
};
...
...
@@ -43,34 +43,34 @@ export class NewGameForm extends React.Component{
e
.
preventDefault
();
// Send Game info to the server
fetch
(
'
http://localhost:5000/user/login
'
,
{
method
:
'
POST
'
,
headers
:
{
Accept
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
},
body
:
JSON
.
stringify
({
name
:
name
,
password
:
password
})
})
.
then
(
res
=>
res
.
json
())
.
then
(
result
=>
{
if
(
result
.
name
)
{
this
.
props
.
handleState
(
result
);
this
.
handleView
();
}
else
{
this
.
handleError
(
result
.
errorResponse
.
message
);
}
},
// Note: it's important to handle errors here
// instead of a catch() block so that we don't swallow
// exceptions from actual bugs in components.
error
=>
{
console
.
log
(
error
);
}
);
//
fetch('http://localhost:5000/user/login', {
//
method: 'POST',
//
headers: {
//
Accept: 'application/json',
//
'Content-Type': 'application/json'
//
},
//
body: JSON.stringify({
//
name: name,
//
password: password
//
})
//
})
//
.then(res => res.json())
//
.then(
//
result => {
//
if (result.name) {
//
this.props.handleState(result);
//
this.handleView();
//
} else {
//
this.handleError(result.errorResponse.message);
//
}
//
},
//
// Note: it's important to handle errors here
//
// instead of a catch() block so that we don't swallow
//
// exceptions from actual bugs in components.
//
error => {
//
console.log(error);
//
}
//
);
};
componentDidMount
()
{
...
...
@@ -82,7 +82,7 @@ export class NewGameForm extends React.Component{
}
render
()
{
return
(
return
ReactDOM
.
createPortal
(
<
div
className
=
'
fade-main
'
>
<
div
className
=
'
sticky
'
>
<
span
className
=
'
close
'
onClick
=
{
this
.
handleView
}
>
...
...
@@ -110,22 +110,26 @@ export class NewGameForm extends React.Component{
required
/>
<
br
/>
<
label
className
=
'
formDate
'
>
Start
:
<
/label
>
<
input
className
=
'
formDate
'
type
=
'
date
'
name
=
'
startDate
'
value
=
{
this
.
state
.
startDate
}
onChange
=
{
this
.
handleChange
}
required
/>
<
br
/>
<
input
className
=
'
formTime
'
type
=
'
time
'
name
=
'
startTime
'
onChange
=
{
this
.
handleChange
}
required
/>
<
br
/>
<
label
className
=
'
formDate
'
>
End
:
<
/label
>
<
input
className
=
'
formDate
'
type
=
'
date
'
name
=
'
endDate
'
value
=
{
this
.
state
.
endDate
}
...
...
@@ -133,8 +137,8 @@ export class NewGameForm extends React.Component{
min
=
{
this
.
state
.
startDate
}
required
/>
<
br
/>
<
input
className
=
'
formTime
'
type
=
'
time
'
name
=
'
endTime
'
onChange
=
{
this
.
handleChange
}
...
...
@@ -145,7 +149,8 @@ export class NewGameForm extends React.Component{
<
h2
>
{
this
.
state
.
errorMsg
}
<
/h2
>
<
/form
>
<
/div
>
<
/div
>
<
/div>
,
document
.
getElementById
(
'
form
'
)
);
}
}
...
...
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