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

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'
    }

34
35
36
    const [show, setShow] = useState(false)


37
    useEffect(() => {
38
        callUserInfo().then((res) => {
39
40
41
42
43
44
45
46
47
48
49
50
            if (isLogined()) {
                const existLoc = res[0]['loc_code']
                if (existLoc === null) {
                    setTimeout(function () {
                        setShow(true)
                    }, 1000)
                }
                else {
                    console.log('Already has Loc_code')
                    window.location.replace('/')
                }
            }
51
        })
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
    }, [])


    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}>
                        <EueSuggest />
Spark's avatar
chartjs    
Spark committed
68
                        <ChartTemp />
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
                        <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;