ScheduleItem.js 2.19 KB
Newer Older
Kim, Subin's avatar
Kim, Subin committed
1
2
3
import { Link } from "react-router-dom";
import styles from "./schedule.module.scss";

Kim, Subin's avatar
Kim, Subin committed
4
const ScheduleItem = ({ index, curDate, schedule, handleClick }) => {
Kim, Subin's avatar
Kim, Subin committed
5
6
    return (
        <div className="accordion-item border-bottom-0">
Kim, Subin's avatar
Kim, Subin committed
7
8
9
10
11
12
13
14
            <button className={`d-flex flex-column align-items-start accordion-button collapsed bg-white shadow-none px-0 ${styles.activeBtn}`} type="button" data-bs-toggle="collapse" data-bs-target={"#collapse" + index} aria-expanded="false" aria-controls={"collapse" + index}>
                <h5 className={`accordion-header ${styles.title}`} id={"heading" + index}>{schedule.title}</h5>
                <p className={`text-secondary mb-0 ${styles.time}`}>
                    {(schedule.allDay) ? "하루 종일" : (curDate === schedule.startDate ? schedule.startTime + " ~" : (curDate === schedule.endDate ? "~ " + schedule.endTime : "하루 종일"))}
                </p>
                <p className={`mb-0 ${styles.period}`}>
                    {schedule.allDay ? schedule.startDate + " ~ " + schedule.endDate : schedule.startDate + " " + schedule.startTime + " ~ " + schedule.endDate + " " + schedule.endTime}
                </p>
Kim, Subin's avatar
Kim, Subin committed
15
            </button>
Kim, Subin's avatar
Kim, Subin committed
16
            <div id={"collapse" + index} className="accordion-collapse collapse" aria-labelledby={"heading" + index} data-bs-parent="#scheduleList">
Kim, Subin's avatar
Kim, Subin committed
17
                <div className={`accordion-body px-0 pt-2 pb-0 mb-3 ${styles.textBox}`}>
Kim, Subin's avatar
context    
Kim, Subin committed
18
                    {schedule.location ? <div className="d-flex align-items-start">
Kim, Subin's avatar
Kim, Subin committed
19
                        <i className="col bi bi-geo-alt fs-5"></i>
Kim, Subin's avatar
context    
Kim, Subin committed
20
21
22
                        <div className="col-11">{schedule.location}</div>
                    </div> : null}
                    {schedule.memo}
Kim, Subin's avatar
Kim, Subin committed
23
                    <div className={"d-flex justify-content-end " + ((schedule.location || schedule.memo) ? "mt-3" : null)}>
Kim, Subin's avatar
context    
Kim, Subin committed
24
                        <Link className="btn btn-light btn-sm border-dark" to={`/schedule/edit/${schedule.id}`}>수정</Link>
Kim, Subin's avatar
Kim, Subin committed
25
                        <button type="button" className="btn btn-crimson btn-sm ms-2" onClick={() => handleClick(schedule.id)}>삭제</button>
Kim, Subin's avatar
Kim, Subin committed
26
27
28
29
30
31
32
33
                    </div>
                </div>
            </div>
        </div>
    )
}

export default ScheduleItem