-
Notifications
You must be signed in to change notification settings - Fork 0
/
TaskForm.js
41 lines (36 loc) · 1.1 KB
/
TaskForm.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
import React, { useState } from 'react';
const TaskForm = ({ handleSubmit, buttonText }) => {
const [name, setName] = useState('');
const [description, setDescription] = useState('');
const [dueDate, setDueDate] = useState('');
const handleSubmitForm = (event) => {
event.preventDefault();
const task = {
name: name,
description: description,
dueDate: dueDate,
};
handleSubmit(task);
setName('');
setDescription('');
setDueDate('');
};
return (
<form onSubmit={handleSubmitForm}>
<label>
Task name:
<input type="text" value={name} onChange={(event) => setName(event.target.value)} />
</label>
<label>
Task description:
<textarea value={description} onChange={(event) => setDescription(event.target.value)} />
</label>
<label>
Due date:
<input type="date" value={dueDate} onChange={(event) => setDueDate(event.target.value)} />
</label>
<button type="submit">{buttonText}</button>
</form>
);
};
export default TaskForm;