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
  const [todo, setTodo] = useState({
    todoTitle: "",
    todoDate: moment().format("YYYY-MM-DD")
  })

  const handleChange = (e) => {
    const { name, value } = e.target
    setTodo({ ...todo, [name]: value })
  }
15

Choi Ga Young's avatar
Choi Ga Young committed
16
17
18
19
20
21
  const handleClick = () => {
    setTodo({
      todoTitle: "",
      todoDate: moment().format("YYYY-MM-DD")
    })
  }
22

Choi Ga Young's avatar
Choi Ga Young committed
23
  return (
Choi Ga Young's avatar
Choi Ga Young committed
24
    <div className="modal fade" id="todomodal" data-bs-backdrop="static" data-bs-keyboard="false" tabIndex="-1" aria-labelledby="todoLabel" aria-hidden="true">
Kim, Subin's avatar
Kim, Subin committed
25
26
27
      <div className="modal-dialog modal-dialog-centered">
        <div className="modal-content" style={{ backgroundColor: "crimson" }}>
          <div className="modal-header px-2 py-1" >
Choi Ga Young's avatar
Choi Ga Young committed
28
            <h5 className="modal-title text-white" id="todoLabel">To-do</h5>
Kim, Subin's avatar
Kim, Subin committed
29
30
            <button type="button" className="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
          </div>
Choi Ga Young's avatar
Choi Ga Young committed
31
          <div className="modal-body bg-white">
Kim, Subin's avatar
Kim, Subin committed
32
33
            <input type="text" name="todoTitle"
              className={`form-control border-top-0 border-end-0 border-start-0 shadow-none rounded-0 ${styles.textInput}`}
Choi Ga Young's avatar
Choi Ga Young committed
34
35
36
37
38
39
              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
40
            </div>
Kim, Subin's avatar
Kim, Subin committed
41
          </div>
Choi Ga Young's avatar
Choi Ga Young committed
42
          <div className="modal-footer bg-white p-1" >
Kim, Subin's avatar
Kim, Subin committed
43
            <button type="button" className="btn btn-secondary btn-sm"
Choi Ga Young's avatar
Choi Ga Young committed
44
              data-bs-dismiss="modal" onClick={handleClick}>취소</button>
Kim, Subin's avatar
Kim, Subin committed
45
            <button type="button" className="btn btn-crimson btn-sm">확인</button>
Choi Ga Young's avatar
Choi Ga Young committed
46
47
48
          </div>
        </div>
      </div>
Kim, Subin's avatar
Kim, Subin committed
49
    </div>
Choi Ga Young's avatar
Choi Ga Young committed
50
51
52
53
  )
}

export default TodoModal;