forked from nikhilpim/Radio
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNewSpeaker.js
More file actions
68 lines (62 loc) · 1.58 KB
/
NewSpeaker.js
File metadata and controls
68 lines (62 loc) · 1.58 KB
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
import React, { Component } from 'react';
import styled from 'styled-components'
import {SpeakingTimes, Times} from "../../constants/times";
const Styles = styled.div`
padding: 1rem;
margin-bottom: 200px;
table {
border-spacing: 0;
border: 1px solid black;
tr {
:last-child {
td {
border-bottom: 0;
}
}
}
th,
td {
margin: 0;
padding: 0.5rem;
border-bottom: 1px solid black;
border-right: 1px solid black;
:last-child {
border-right: 0;
}
}
}
`
class NewSpeaker extends Component {
constructor(props) {
super(props);
this.state = {
speaker: ""
}
}
onChange = event => {
this.setState({ [event.target.name]: event.target.value });
}
render () {
const {speaker} = this.state
const isInvalid = speaker === '';
return (
<Styles>
<div className="box">
<h3>New Speaker</h3>
<form onSubmit={event => this.props.addSpeaker(event, speaker)}>
<div className="form-group">
<input
name="speaker"
value={speaker}
onChange={this.onChange}
type="text"
placeholder="New Speaker"/>
</div>
<button disabled={isInvalid} type="submit"> Add </button>
</form>
</div>
</Styles>
);
}
}
export default NewSpeaker