HomePage.js 2.46 KB
Newer Older
Ha YeaJin's avatar
pages    
Ha YeaJin committed
1
2
import React, { useState, useEffect } from 'react';
import Menu from '../Components/Menu';
Lee Jin Ju's avatar
Lee Jin Ju committed
3
import Calendar from '../Components/Calendar';
Lee Jin Ju's avatar
Lee Jin Ju committed
4
import styled from 'styled-components';
Kim, Subin's avatar
기간    
Kim, Subin committed
5
6
7
8
9
10
11
12
import moment from 'moment';
import "moment/locale/ko";

moment.locale("ko", {
    week: {
        dow: 1
    }
});
Lee Jin Ju's avatar
Lee Jin Ju committed
13

Lee Jin Ju's avatar
Lee Jin Ju committed
14
15
16
17
18
19
const Drop = styled.div`
    & button {
        border solid 1px;
    }
`

Kim, Subin's avatar
Home    
Kim, Subin committed
20
21
22
23
24
const Schedule = styled.div`
    & ul {
        list-style-type: none;
    }
`
Kim, Subin's avatar
Kim, Subin committed
25

Ha YeaJin's avatar
pages    
Ha YeaJin committed
26
function Home() {
Kim, Subin's avatar
기간    
Kim, Subin committed
27
28
29
30
31
32
33
34
35
    const [show, setShow] = useState(false);
    const [weeks, setWeeks] = useState([]);

    useEffect(() => {
        Dateform();
    }, []);

    function Dateform() {
        let today = moment();
36
        let weeks = [];
Kim, Subin's avatar
기간    
Kim, Subin committed
37
38
39
40
41
        let dates = { start: null, end: null };
        for (let i = 0; i < 6; i++) {
            if (i !== 0) {
                today.add(7, 'd');
            }
42

Kim, Subin's avatar
기간    
Kim, Subin committed
43
44
45
46
47
48
49
            dates.start = today.startOf('week').format("MMM Do");
            dates.end = today.endOf('week').weekday(4).format("MMM Do");
            const week = dates.start + "  ~  " + dates.end;
            weeks.push(week);
        };
        setWeeks([...weeks])
    };
Lee Jin Ju's avatar
Lee Jin Ju committed
50

Ha YeaJin's avatar
pages    
Ha YeaJin committed
51
52
53
    return (
        <div>
            <Menu />
Lee Jin Ju's avatar
Lee Jin Ju committed
54
            <div className="container mt-3">
Lee Jin Ju's avatar
Lee Jin Ju committed
55
56
57
58
59
60
61
62
63
64

                <h2>대관 현황</h2>
                <p>
                    <strong>대관 가능 시간</strong>
                    <ul>
                        <li>평일: 9 - 22/ 예약가능 시간 이후 폐쇄</li>
                        <li>주말: 이용 불가</li>
                    </ul>
                </p>

Lee Jin Ju's avatar
Lee Jin Ju committed
65
                <Drop className="row dropdown mt-1 mb-2">
66
67
68
69
                    <div className="container">
                        <Drop className="row dropdown mt-5 mb-5">
                            <button className="btn btn-lg dropdown-toggle mx-auto col-5" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                기간을 선택해주십시오.
Lee Jin Ju's avatar
Lee Jin Ju committed
70
                    </button>
71
72
73
74
75
76
                            <div className="dropdown-menu col-5" aria-labelledby="dropdownMenuButton">
                                {weeks.map((week, index) => (
                                    <a className="dropdown-item" href="#" onClick={() => setShow(true)}>{week}</a>
                                ))}
                            </div>
                        </Drop>
Lee Jin Ju's avatar
Lee Jin Ju committed
77
78
                    </div>
                </Drop>
Ha YeaJin's avatar
pages    
Ha YeaJin committed
79
80
81
82
83
            </div>
        </div>
    )
}

Lee Jin Ju's avatar
Lee Jin Ju committed
84
export default Home;