-
Notifications
You must be signed in to change notification settings - Fork 0
/
Profile.js
101 lines (91 loc) · 1.91 KB
/
Profile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
import React from 'react';
import {
Dropdown,
Form,
Button,
} from 'semantic-ui-react';
import { connect } from 'react-redux';
//reducer function
import { getProfile } from '../reducers/codapi';
class Profile extends React.Component {
state = {
title: '',
platform: '',
username: '',
days: '',
type: '',
time: '',
mode: '',
}
//handle change of inputs and setting state
handleChange = (e) => {
const { name, value } = e.target
this.setState({
[name]: value
})
}
//calls the reducer function and is stored in props
handleSubmit = (e) => {
const { dispatch } = this.props
dispatch(getProfile(this.state))
}
render() {
const platforms =
[
{
text: 'PlayStation',
value: 'psn'
},
{
text: 'XBOX',
value: 'xbl'
},
{
text: 'PC (Steam)',
value: 'steam'
},
]
const titles =
[
{
text: 'Black Ops 3',
value: 'bo3'
},
{
text: 'WWII',
value: 'wwii'
},
{
text: 'Infinite Warfare',
value: 'iw'
},
]
return (
<>
<Dropdown
placeholder="Select Platform"
options={platforms}
onChange={(e, data) => this.setState({ platform: data.value })}
/>
<Form.Input
value={this.state.username}
name='username'
placeholder='Username'
onChange={this.handleChange}
>
</Form.Input>
<Dropdown
placeholder="Select Title"
options={titles}
onChange={(e, data) => this.setState({ title: data.value })}
/>
<Button onClick={this.handleSubmit}>Submit</Button>
</>
)
}
}
//maps redux state to props
const mapStateToProps = (state) => {
return { data: state.codapi }
}
export default connect(mapStateToProps)(Profile)