forked from jeffbski/redux-logic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
component.js
56 lines (55 loc) · 1.4 KB
/
component.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
import React from 'react';
export default function Users({ fields, errors, valid, message, list,
onFieldChange, onSubmit }) {
return (
<div>
<h2>New User</h2>
<form onSubmit={onSubmit}>
<div className="message">{ message }</div>
<div className="error">
<ul>
{ errors.map(error => (
<li key={error}>{error}</li>)) }
</ul>
</div>
<table>
<tbody>
<tr>
<td>
<label>First name</label>
</td>
<td>
<input name='first_name' value={fields.first_name}
onChange={ onFieldChange }/>
</td>
</tr>
<tr>
<td>
<label>Last name</label>
</td>
<td>
<input name='last_name' value={fields.last_name}
onChange={ onFieldChange }/>
</td>
</tr>
<tr>
<td>
</td>
<td>
<button type='submit' disabled={!valid} >Submit</button>
</td>
</tr>
</tbody>
</table>
</form>
<div className="list">
<h2>Users</h2>
<ul>
{ list.map(user => (
<li key={user.id}>{user.first_name} {user.last_name}</li>)) }
</ul>
</div>
</div>
);
}