LocCodeChange.js 5.02 KB
Newer Older
Spark's avatar
Spark committed
1
import React, { useEffect, useState } from 'react'
Spark's avatar
Spark committed
2
import '../App.css'
Spark's avatar
Spark committed
3
import { Form, Button, Row, Col, Card, DropdownButton, Dropdown, ButtonGroup } from 'react-bootstrap';
Spark's avatar
Spark committed
4
import axios from 'axios';
Spark's avatar
Spark committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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

function LocCodeChange() {

    const cardstyled = {
        margin: 'auto',
        padding: '1em',
        display: 'flex',
        justifyContent: 'center',
        width: '100%',
        borderWidth: '3px',
        borderRadius: '20px',
        borderColor: 'rgb(110, 189, 142)',
        color: '#04AB70'
    }

    const inboxstyled = {
        display: 'flex',
        flexDirection: 'column',
        maxWidth: '80%',
        justifyContent: 'center',
        margin: 'auto',
        padding: '10px'
    }

    const btnstyled2 = {
        background: 'white',
        margin: '1px',
        maxWidth: 'fit-content',
        borderWidth: '2px',
        color: 'rgb(110, 189, 142)',
        borderColor: 'rgba(195, 195, 195, 0.753)',
        borderRadius: '20px'
    }

    const [locCodeShow, setLocCodeShow] = useState(false)

    function handleClickLoc() {
        setLocCodeShow(true);
        const auth = document.getElementById('loc-code')
        auth.style.visibility = 'visible'
    }

Spark's avatar
Spark committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
    const [does, setDoes] = useState([])
    const [sggs, setSggs] = useState([])
    // const [emds, setEmds] = useState([])

    const does_array = []
    const sggs_array = []
    // const emds_array = []
    does.map((doesObj) => does_array.push(doesObj['name_doe']))
    sggs.map((sggsObj) => console.log(sggsObj['sgg']))
    console.log('does :: ', does)
    console.log('does_array:::', does_array)

    async function getLocCode() {
        const res = await axios.get("http://localhost:4500/api/data/loccode")
        const local_codes = res.data.locCodes
        console.log('local_codes::: ', local_codes)
        setDoes(local_codes.DOE)
        setSggs(local_codes.SGG)
    }
Spark's avatar
Spark committed
66

Spark's avatar
Spark committed
67
68
69
    useEffect(() => {
        getLocCode()
    }, [])
Spark's avatar
Spark committed
70

Spark's avatar
Spark committed
71
72
73
74
75
76
77
    return (
        <Row className='text-center w-100 my-2'>
            <Card style={cardstyled}>
                <Card.Title id='impactTitle'>
                    Local Code
                </Card.Title>
                <Card.Subtitle style={{ fontWeight: 'lighter' }}>
Spark's avatar
Spark committed
78
                    Please select a your region
Spark's avatar
Spark committed
79
80
81
                </Card.Subtitle>
                <hr />
                <Card.Text>
Spark's avatar
Spark committed
82

Spark's avatar
Spark committed
83
84
85
                    <Form style={inboxstyled}>
                        <Row className='m-auto w-100 d-flex justify-content-center'>
                            <Col md={12} xs={12} style={{ padding: '0', display: 'flex', justifyContent: 'center', width: '100%' }}>
Spark's avatar
Spark committed
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
                                <Form.Group style={btnstyled2}>
                                    <Form.Control as='select' aria-label="Floating label select example">
                                        <option></option>
                                        {does.map((doe) => (
                                            <option value={`${doe["code_doe"]}`}>
                                                {`${doe["name_doe"]}`}</option>
                                        ))}
                                    </Form.Control>
                                    <Form.Control as='select' aria-label="Floating label select example">
                                        <option>시군구</option>
                                        {does.map((doe) => (
                                            <option value={`${doe["code_doe"]}`}>
                                                {`${doe["name_doe"]}`}</option>
                                        ))}
                                    </Form.Control>
                                    <Form.Control as='select' aria-label="Floating label select example">
                                        <option>읍면동</option>
                                        {does.map((doe) => (
                                            <option value={`${doe["code_doe"]}`}>
                                                {`${doe["name_doe"]}`}</option>
                                        ))}
                                    </Form.Control>

                                </Form.Group>
Spark's avatar
Spark committed
110
111
112
113
114
115
116
117
118
                                <Button variant='light' style={btnstyled2} onClick={!locCodeShow && handleClickLoc}>확인</Button>
                            </Col>
                            <Col md={6} xs={4} id='loc-code' style={{
                                margin: '5px',
                                border: 'solid',
                                borderColor: 'rgb(110, 189, 142)',
                                display: 'flex',
                                justifyContent: 'center',
                                padding: '2px',
Spark's avatar
Spark committed
119
120
                                // visibility: 'hidden',
                                transition: 'all 2s'
Spark's avatar
Spark committed
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
                            }}>
                                지역코드
                            </Col>
                        </Row>

                    </Form>

                </Card.Text>
            </Card>

        </Row>
    )
}

export default LocCodeChange;