HomePage.js 2.52 KB
Newer Older
Yoon, Daeki's avatar
Yoon, Daeki committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import React, { useState, useEffect } from 'react';
import { Redirect } from 'react-router-dom';
import axios from 'axios';
import Menu from '../Components/Menu';
import Schedule from '../Components/Schedule';
import { Container, Tabs, Tab } from 'react-bootstrap';

function Home() {
    const [key, setKey] = useState('9-116');
    const [state, setState] = useState()

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

    if (state) return <Redirect to="/" />;

    function tcheck() {
Yoon, Daeki's avatar
Yoon, Daeki committed
19
        axios.get(`/app/rental/api/users/${localStorage.getItem('_id')}`, {
Yoon, Daeki's avatar
Yoon, Daeki committed
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
            headers: { authorization: localStorage.getItem('token') },
        })
            .then(res => {
                if (res.status !== 201) {
                    alert(res.data.error);
                    localStorage.clear();
                    setState(true);
                }
            }).catch(err => {
                alert(err.error)
            });
    }

    return (
        <div>
            <Menu />
            <Container className="col-md-10 mt-3">
                <h2>대관 현황</h2>
                <p>
                    <strong>대관 가능 시간</strong>
                    <ul className="pl-4">
                        <li>평일: 9 - 22/ 예약가능 시간 이후 폐쇄</li>
                        <li>주말: 이용 불가</li>
                    </ul>
                </p>
                <p>
                    <strong>유의사항</strong>
                    <ul className="pl-4">
                        <li>강의실 사용시 최소인원 수에 맞춰서 명단 작성이 필요합니다.</li>
                        <li>1 대관시 최대 3시간까지 이용이 가능합니다. (1시간 단위로 대관 가능)</li>
                        <li><strong style={{ color: "red" }}>대관 시간 이외 강의실을 이용하다 적발될 경우 한달  강의실 이용이 불가합니다.</strong></li>
                    </ul>
                </p>
                <Tabs defaultActiveKey="9-116" id="uncontrolled-tab-example" onSelect={(k) => setKey(k)}>
                    <Tab eventKey="9-116" title="9-116">
                        <Schedule room={key} />
                    </Tab>
                    <Tab eventKey="7-234" title="7-234">
                        <Schedule room={key} />
                    </Tab>
                    <Tab eventKey="25-101" title="25-101">
                        <Schedule room={key} />
                    </Tab>
                </Tabs>
            </Container>
        </div>
    )
}

export default Home