-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEditTask.js
57 lines (43 loc) · 1.51 KB
/
EditTask.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
import {Row,Modal,Form, Button} from "react-bootstrap"
import {useState} from "react"
const EditTask = ({saveTask,showModal,showEditTask,setEditedTask}) => {
const inicialState = ("")
const [newTask, setNewTask]= useState(inicialState)
const handleClose = (e) => {
showModal()
}
const handleInput = (e) => {
const {value} = e.target
setNewTask(value)
}
const handleSaveEdit = (e) =>{
const newObjt = {
...saveTask,
task: newTask
};
showModal()
setEditedTask(newObjt)
console.log(newObjt)
setNewTask(inicialState)
}
return (
<Row className="modal-container">
{showEditTask &&
<Modal.Dialog >
<Modal.Header closeButton onClick={handleClose}>
<Modal.Title>Edita tu tarea</Modal.Title>
</Modal.Header>
<Modal.Body>
<Form.Group>
<input type="text" name="task" placeholder="Edita tu tarea" onChange={handleInput} autoFocus/>
</Form.Group>
</Modal.Body>
<Modal.Footer>
<Button variant="secondary" onClick={handleClose}>Cancelar</Button>
<Button variant="primary" onClick={handleSaveEdit}>Guardar</Button>
</Modal.Footer>
</Modal.Dialog>}
</Row>
)
}
export default EditTask;