GetLocFirst.js 2.85 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
import React, { useEffect, useState } from 'react'
import { Container, Row, Col, Modal } from 'react-bootstrap';
import MainLayer from '../components/MainLayer';
import TimeNow from './../components/TimeNow';
import '../App.css'
import EueSuggest from '../components/EueSuggest';
import ChartLine from '../components/ChartLine';
import ChartDoughnut from '../components/ChartDoughnut';
import Donation from '../components/Donation';
import LocCodeChange from '../components/LocCodeChange';
11
import { callUserInfo } from '../utils/CheckDB';
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

function GetLocFirst() {
    const constyled = {
        display: 'flex',
        justifyContent: 'space-evenly',
        width: '100%',
        position: 'relative'
    }

    const col1sty = {
        display: 'flex',
        justifyContent: 'start',
        alignItems: 'center'
    }

    const col2sty = {
        display: 'flex',
        justifyContent: 'center',
        alignItems: 'center',
        flexDirection: 'column',
        padding: '0'
    }

35
36
37
38
    const [existLoc, setExistLoc] = useState('')
    const [show, setShow] = useState(false)


39
    useEffect(() => {
40
41
42
        callUserInfo().then((res) => {
            setExistLoc(res[0]['loc_code'])
        })
43
44
    }, [])

45
46
47
48
49
50
51
52
53
54
55
56
    useEffect(() => {
        if (existLoc === '') {
            setTimeout(function () {
                setShow(true)
            }, 1500)
        }
        else {
            setShow(false)
            window.location.replace('/')
        }
    }, [existLoc])

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95

    return (
        <Container className='m-auto d-flex position-relative'
            style={{ flexDirection: 'column' }} fluid>
            <Row className='d-flex'>
                <Row style={constyled} className='m-auto'>
                    <Col xs={12} md={6} className='d-flex justify-content-center' id='stickyy'>
                        <Row style={col1sty} className='m-auto'>
                            <MainLayer />
                        </Row>
                    </Col>

                    <Col md={6} style={col2sty}>
                        <TimeNow />
                        <EueSuggest />
                        <ChartLine />
                        <ChartDoughnut />
                        <Donation />
                    </Col>

                    <Modal
                        show={show}
                        backdrop="static"
                        style={{ marginTop: '10%' }}>
                        <Modal.Header className='d-flex justify-content-center top-10'>
                            <Modal.Title>EUE에 오신걸 환영합니다</Modal.Title>
                        </Modal.Header>
                        <Modal.Body className='d-flex justify-content-center top-10'>
                            <LocCodeChange />
                        </Modal.Body>
                    </Modal>
                </Row>
            </Row>
        </Container>
    );
}


export default GetLocFirst;