SignupComp.js 6.83 KB
Newer Older
Spark's avatar
Spark committed
1
2
3
4
5
6
import React, { useEffect, useState } from 'react'
import '../App.css'
import { Form, Modal, Button, Row, Col, Image, DropdownButton, ButtonGroup, Dropdown, Card } from 'react-bootstrap';
// import { KAKAO_AUTH_URL } from '../components/Oauth';
import { handleLogin } from '../utils/Auth';
import { isOauth } from '../utils/Auth';
Spark's avatar
Spark committed
7
import { LoginWithKakao } from '../utils/Oauth';
Spark's avatar
Spark committed
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

function SignupComp() {

    const noticestyled = {
        display: 'flex',
        justifyContent: 'center',
        color: 'gray',
        margin: 'auto',
        fontSize: '0.8em',
        visibility: 'hidden',
    }

    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',
Spark's avatar
Spark committed
36
        maxWidth: '80%',
Spark's avatar
Spark committed
37
38
39
40
41
42
        justifyContent: 'center',
        margin: 'auto',
        padding: '1rem'
    }

    const aftershow = {
Spark's avatar
Spark committed
43
        display: 'none'
Spark's avatar
Spark committed
44
45
46
    }

    const initValues = {
Spark's avatar
Spark committed
47
        email: ''
Spark's avatar
Spark committed
48
49
50
51
52
53
54
55
56
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
    }

    const [formValues, setFormValues] = useState(initValues)
    const [formError, setFormError] = useState({})
    const [validated, setValidated] = useState(false)

    function submitForm() {
        console.log('formValues', formValues);
        console.log(!formValues['username']);
        console.log('Error', formError)
    }

    function handleChange(event) {
        const { name, value } = event.target
        setFormValues({ ...formValues, [name]: value })
    }

    function handleSubmit(event) {
        const form = event.currentTarget;
        console.log('formValues', formValues);
        console.log('formValues.values', Object.values(formValues)[0].length);

        // console.log(form)
        // if (Object.values(formValues)[0].length !== 0) { //form.checkValidity() === false
        //     event.preventDefault();
        //     event.stopPropagation();
        // }
        console.log(validated)
        setValidated(true);
        // const form = event.current
        // setFormError(validate(formValues))
        // setIsSubmit(true)
    }



    const [emailSubm, setEmailSubm] = useState(false)
Spark's avatar
Spark committed
85
    
Spark's avatar
Spark committed
86
87
88
89
    function handleClickSubm() {
        // setEmailSubm(true);
        const subm = document.getElementById("subm-mailSent");
        subm.style.visibility = 'visible'
Spark's avatar
Spark committed
90
91
        // const aftermail = document.getElementById('AftermailSent');
        // aftermail.style.display = ''
Spark's avatar
Spark committed
92
    }
Spark's avatar
Spark committed
93
94
    
  
Spark's avatar
Spark committed
95
96
97
98
    console.log(emailSubm);


    return (
Spark's avatar
Spark committed
99

Spark's avatar
Spark committed
100
101
        <Row className='text-center w-100 my-2'>
            <Card style={cardstyled}>
Spark's avatar
Spark committed
102
                <Card.Title id='impactTitle'>
Spark's avatar
Spark committed
103
104
105
106
107
108
109
110
111
                    Create an Account
                </Card.Title>
                <Card.Subtitle style={{ fontWeight: 'lighter' }}>
                    Sign up with your social media account or email address
                </Card.Subtitle>
                <hr />
                <Card.Text>
                    <Form style={inboxstyled}
                        onSubmit={handleSubmit}>
Spark's avatar
Spark committed
112
113
114
115
116
117
118
119
120
121
122
                        <Form.Group controlId="userEmail" className='mb-1'>
                            <Row className='m-auto d-flex justify-content-center'>
                                <Form.Control
                                    type="email"
                                    name="email"
                                    placeholder="Email Address"
                                    value={formValues.email}
                                    onChange={handleChange}
                                    readOnly={emailSubm}
                                    required
                                />
Spark's avatar
Spark committed
123
                            </Row>
Spark's avatar
Spark committed
124
                        </Form.Group>
Spark's avatar
Spark committed
125
126


Spark's avatar
Spark committed
127
                        {/* 
Spark's avatar
Spark committed
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
                        <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%' }}>
                                {['도', '시군구', '읍면동'].map((localname) => (
                                    <DropdownButton
                                        variant='light'
                                        style={btnstyled2}
                                        title='지역코드'
                                        as={ButtonGroup}
                                        title={` ${localname} `}
                                    >
                                        <Dropdown.Item>Action</Dropdown.Item>
                                        <Dropdown.Item>Another action</Dropdown.Item>
                                        <Dropdown.Item>Something else here</Dropdown.Item>
                                        <Dropdown.Divider />
                                        <Dropdown.Item>Separated link</Dropdown.Item>
                                    </DropdownButton>
                                ))}
                                <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',
                                visibility: 'hidden',
                                transition: 'all 4s'
                            }}>
                                지역코드
                            </Col>
Spark's avatar
Spark committed
159
                        </Row> */}
Spark's avatar
Spark committed
160
161
162
163
164
165

                        <Button variant='light' className='mt-2' type="submit" id='formbtn'>
                            Sign Up
                        </Button>
                    </Form>

Spark's avatar
Spark committed
166
167
168
169
170
171
172
173
174
                    <Row className='d-flex align-items-center m-2'>
                        <Col>
                            <hr />
                        </Col>
                        OR
                        <Col>
                            <hr />
                        </Col>
                    </Row>
Spark's avatar
Spark committed
175
176

                    <Row style={{ margin: 'auto', marginBottom: '5px', display: 'flex', justifyContent: 'center' }}>
Spark's avatar
Spark committed
177
178
179
                        <a href="#;" onClick={LoginWithKakao} id='socialLink' >
                            {/* 세미콜론이 붙으면 최상단 이동 x */}
                            <img src='http://image.kmib.co.kr/online_image/2020/0626/611514110014734788_1.jpg' id='logpng' alt='KAKAO' />
Spark's avatar
Spark committed
180
181
182
183
184
185
186
187
188
                        </a>
                    </Row>
                </Card.Text>
            </Card>
        </Row>
    )
}

export default SignupComp;