-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddTask.js
More file actions
55 lines (47 loc) · 1.46 KB
/
AddTask.js
File metadata and controls
55 lines (47 loc) · 1.46 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
import { useState } from 'react'
const AddTask = ({ onAdd }) => {
const [text, SetText] = useState('')
const [day, SetDay] = useState('')
const [reminder, SetReminder] = useState(false)
const onSubmit = (e) => {
e.preventDefault()
if(!text) {
alert('Please add a task')
return
}
onAdd({ text, day, reminder})
SetText('')
SetDay('')
SetReminder(false)
}
return (
<form className='add-form' onSubmit={onSubmit}>
<div className='form-control'>
<label>Task</label>
<input
type='text'
placeholder='Add Task'
value={text}
onChange={(e) => SetText(e.target.value)}/>
</div>
<div className='form-control'>
<label>Day & Time</label>
<input
type='text'
placeholder='Add Day & Time'
value={day}
onChange={(e) => SetDay(e.target.value)}/>
</div>
<div className='form-control form-control-check'>
<label>Set Reminder</label>
<input
type='checkbox'
checked={reminder}
value={reminder}
onChange={(e) => SetReminder(e.currentTarget.checked)}/>
</div>
<input type='submit' value='Save Task' className='btn btn-block' />
</form>
)
}
export default AddTask