Newer
Older
Ari-Pekka Kauppinen
committed
import React, { Component } from 'react';
import "../styles/Start.css"
import Cookies from 'universal-cookie';
class Start extends Component {
constructor(props) {
super(props);
this.state = {
startWindow: false,
};
this.closeWindow = this.closeWindow.bind(this);
this.createTable = this.createTable.bind(this);
this.getCity = this.getCity.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleSubmit(e){
//When submit is clicked
//TODO: check if fields are correctly filled + city verification
e.preventDefault();
const cookies = new Cookies();
//cookie expires in the year 2050
const date = new Date(2070, 1, 1);
Ari-Pekka Kauppinen
committed
//Set cookie
cookies.set('firstPage', 'true', { path: '/', expires: date });
Ari-Pekka Kauppinen
committed
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
console.log(cookies.get('firstPage'))
}
closeWindow(){
//show welcome window once
this.setState({startWindow: true})
//console.log(this.state.startWindow)
}
createTable = () => {
//loop numbers from 6 - 100 and set to array
let age = []
for (let i = 6; i < 101; i++) {
age.push(<option> { i }</option>)
}
//return array and set to dropdown menu
return age
}
getCity(){
//TODO: Get cities from database
return <option>Jyväskylä</option>
}
render() {
//states
const {startWindow } = this.state
//if start window is already shown
if(startWindow) {
return (
//Create profile form
<div className="FirstProfile">
<h3>Luo profiili:</h3>
{/*TODO: form action to open main view and dont show this view again*/}
<div className="container">
<form className="form" onSubmit={this.handleSubmit}>
<label>Nimimerkki:</label>
<input type="text" name="name"></input>
<br />
<label>Ikä:</label>
<select className="field">
{this.createTable()}
</select>
<br />
<label> Sukupuoli:</label>
<select className="field">
<option>Mies</option>
<option>Nainen</option>
</select>
<br/>
<label>Kaupunki:</label>
<select className="field">
{this.getCity()}
</select>
<br/> <br />
<input type="submit" value="Luo profiili"></input>
</form>
</div>
</div>
);
}
else{
return (
//show startwindow first
<div className="StartWindow">
<h1>Tervetuloa käyttämään Wear Right -palvelua!</h1>
<p>Pukeutuminen ei ole koskaan ollut näin helppoa! Oli ulkona mikä sää tahansa, Wear Rightin avulla tiedät täsmälleen, miten pukeutua eri säätiloihin.
Saat säätilat suoraan laitteeseesi reaaliajassa, sekä sään mukaiset pukeutumisehdotukset. Voit lisätä palveluun eri profiileja, joten saat
pukeutumisehdotukset koko perheelle! Palveluun voi lisätä myös suosikkikaupunkisi, jolloin saat säätiedot haluamastasi paikasta.
</p>
<p>
Ennen, kun voit aloittaa, sinun täytyy luoda ensimmäinen profiili palveluun. Voit muokata profiileja myöhemmin milloin tahansa. Wear Right ei
tallenna henkilötietoja minnekään, vaan suosikkiprofiilisi näkyvät vain tässä laitteeessa.
</p>
<button onClick={ () => this.closeWindow()}>Asia kunnossa!</button>
</div>
);
}
}
}
export default Start;