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

moment.locale("ko", {
    week: {
        dow: 1
    }
});
Kim, Subin's avatar
Home    
Kim, Subin committed
12
13
14
15
16
17
18
19
20
21
22
23

const Drop = styled.div`
    & button {
        border solid 1px;
    }
`

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

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

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

    function Dateform() {
        let today = moment();
35
        let weeks = [];
Kim, Subin's avatar
기간    
Kim, Subin committed
36
37
38
39
40
41
42
43
44
45
46
47
48
        let dates = { start: null, end: null };
        for (let i = 0; i < 6; i++) {
            if (i !== 0) {
                today.add(7, 'd');
            }
            
            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])
    };
Kim, Subin's avatar
Home    
Kim, Subin committed
49

Kim, Subin's avatar
Kim, Subin committed
50
51
52
53
    return (
        <div>
            <Menu />
            <div className="container">
Kim, Subin's avatar
Kim, Subin committed
54
                <Drop className="row dropdown mt-5 mb-5">
Kim, Subin's avatar
Home    
Kim, Subin committed
55
                    <button className="btn btn-lg dropdown-toggle mx-auto col-5" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Kim, Subin's avatar
기간    
Kim, Subin committed
56
                        기간을 선택해주십시오.
Kim, Subin's avatar
Home    
Kim, Subin committed
57
58
                    </button>
                    <div className="dropdown-menu col-5" aria-labelledby="dropdownMenuButton">
Kim, Subin's avatar
기간    
Kim, Subin committed
59
60
61
                        {weeks.map((week, index) => (
                            <a className="dropdown-item" href="#" onClick={() => setShow(true)}>{week}</a>
                        ))}
Kim, Subin's avatar
Home    
Kim, Subin committed
62
63
                    </div>
                </Drop>
Kim, Subin's avatar
Kim, Subin committed
64
65
66
67
68
69
            </div>
        </div>
    )
}

export default Home