TodoModal.js 2.09 KB
Newer Older
Choi Ga Young's avatar
Choi Ga Young committed
1
2
import { useState } from "react";
import moment from "moment";
3
4
import styles from "./modal.module.scss";

Choi Ga Young's avatar
Choi Ga Young committed
5
const TodoModal = () => {
Choi Ga Young's avatar
Choi Ga Young committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  const [todo, setTodo] = useState({
    todoTitle: "",
    todoDate: moment().format("YYYY-MM-DD")
  })

  const handleChange = (e) => {
    const { name, value } = e.target
    setTodo({ ...todo, [name]: value })
  }
  const handleClick = () => {
    setTodo({
      todoTitle: "",
      todoDate: moment().format("YYYY-MM-DD")
    })
  }
  
Choi Ga Young's avatar
Choi Ga Young committed
22
  return (
Choi Ga Young's avatar
Choi Ga Young committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
    <div className="modal fade" id="todomodal" data-bs-backdrop="static" data-bs-keyboard="false" tabIndex="-1" aria-labelledby="todoLabel" aria-hidden="true">
      <div className="modal-dialog modal-dialog-centered">
        <div className="modal-content" style={{ backgroundColor: "crimson" }}>
          <div className="modal-header px-2 py-1" >
            <h5 className="modal-title text-white" id="todoLabel">To-do</h5>
            <button type="button" className="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
          </div>
          <div className="modal-body bg-white">
            <input type="text" name="todoTitle"
              className={`form-control border-top-0 border-end-0 border-start-0 shadow-none rounded-0 ${styles.textInput}`}
              placeholder="제목" onChange={handleChange} value={todo.todoTitle} />
            <div className="d-flex justify-content-between mt-4">
              <label className="col-2 col-form-label ms-2">날짜</label>
              <div className="col-6 d-flex align-items-center">
                <input type="date" className="form-control form-control-sm" name="todoDate" onChange={handleChange} value={todo.todoDate} />
              </div>
Choi Ga Young's avatar
Choi Ga Young committed
39
40
            </div>
          </div>
Choi Ga Young's avatar
Choi Ga Young committed
41
42
43
44
45
          <div className="modal-footer bg-white p-1" >
            <button type="button" className="btn btn-secondary btn-sm"
              data-bs-dismiss="modal" onClick={handleClick}>취소</button>
            <button type="button" className="btn btn-crimson btn-sm">확인</button>
          </div>
Choi Ga Young's avatar
Choi Ga Young committed
46
47
        </div>
      </div>
Choi Ga Young's avatar
Choi Ga Young committed
48
    </div>
Choi Ga Young's avatar
Choi Ga Young committed
49
50
51
52
  )
}

export default TodoModal;