SignupComp.js 6.17 KB
Newer Older
Spark's avatar
Spark committed
1
import React, { useState } from 'react'
Spark's avatar
Spark committed
2
import '../App.css'
Spark's avatar
Spark committed
3
import { Form, Button, Row, Col, Card, Alert } from 'react-bootstrap';
Spark's avatar
Spark committed
4
import { LoginWithKakao } from '../utils/Oauth';
Spark's avatar
Spark committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

function SignupComp() {

    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
23
        maxWidth: '80%',
Spark's avatar
Spark committed
24
25
26
27
28
29
        justifyContent: 'center',
        margin: 'auto',
        padding: '1rem'
    }

    const initValues = {
Spark's avatar
Spark committed
30
31
        email: '',
        name: ''
Spark's avatar
Spark committed
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
    }

    const [formValues, setFormValues] = useState(initValues)
    const [validated, setValidated] = useState(false)

    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
59

Spark's avatar
Spark committed
60
61
62
63
    function handleClickSubm() {
        // setEmailSubm(true);
        const subm = document.getElementById("subm-mailSent");
        subm.style.visibility = 'visible'
Spark's avatar
Spark committed
64
65
        // const aftermail = document.getElementById('AftermailSent');
        // aftermail.style.display = ''
Spark's avatar
Spark committed
66
    }
Spark's avatar
Spark committed
67
68


Spark's avatar
Spark committed
69
70
71
72
73
74
    const [userExist, setUserExist] = useState(false)
    const [alertShow, setAlertShow] = useState(true)

    function CheckUserExist() {
        setUserExist(!userExist)
    }
Spark's avatar
Spark committed
75
76
77


    return (
Spark's avatar
Spark committed
78

Spark's avatar
Spark committed
79
80
        <Row className='text-center w-100 my-2'>
            <Card style={cardstyled}>
Spark's avatar
Spark committed
81
                <Card.Title id='impactTitle'>
Spark's avatar
Spark committed
82
83
84
85
86
87
88
                    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>
Spark's avatar
Spark committed
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
                    <Row className='m-auto d-flex justify-content-center' style={{ width: '80%' }}>
                        {!userExist ?
                            <Alert show={alertShow} variant={'success'}>
                                <Col>
                                    😊 계정 생성이 완료 되었습니다.
                                </Col>
                                <Alert.Link href='/login' style={{ fontSize: '0.8em' }}>
                                    로그인 하러가기 
                                </Alert.Link>
                            </Alert>
                            :
                            <Alert show={alertShow} variant={'danger'}>
                                <Col>
                                    🤔 이미 존재하는 계정입니다.
                                </Col>
                                <Alert.Link href='/login' style={{ fontSize: '0.8em' }}>
                                    로그인 하러가기 
                                </Alert.Link>
                            </Alert>
                        }
                        <Button onClick={() => setAlertShow(true)}>보여주고</Button>
                        <Button onClick={() => setAlertShow(false)}>안보여주고</Button>
                    </Row>
Spark's avatar
Spark committed
112

Spark's avatar
Spark committed
113
114
                    <Form style={inboxstyled}
                        onSubmit={handleSubmit}>
Spark's avatar
Spark committed
115
116
117
118
119
120
121
122
123
124
125
126
127
128
                        <Form.Group controlId="userEmail">
                            <Row className='m-auto mb-1 d-flex justify-content-center'>
                                <Form.Control
                                    type="text"
                                    name="name"
                                    placeholder="Name"
                                    value={formValues.name}
                                    onChange={handleChange}
                                    required
                                />
                            </Row>
                            <Row>
                                <p></p>
                            </Row>
Spark's avatar
Spark committed
129
130
131
132
133
134
135
136
137
                            <Row className='m-auto d-flex justify-content-center'>
                                <Form.Control
                                    type="email"
                                    name="email"
                                    placeholder="Email Address"
                                    value={formValues.email}
                                    onChange={handleChange}
                                    required
                                />
Spark's avatar
Spark committed
138
                            </Row>
Spark's avatar
Spark committed
139
                        </Form.Group>
Spark's avatar
Spark committed
140

Spark's avatar
Spark committed
141
142
                        <Button variant='light' className='mt-2' id='formbtn' onClick={CheckUserExist}>
                        {/* type="submit" */}
Spark's avatar
Spark committed
143
144
145
146
                            Sign Up
                        </Button>
                    </Form>

Spark's avatar
Spark committed
147
148
149
150
151
152
153
154
155
                    <Row className='d-flex align-items-center m-2'>
                        <Col>
                            <hr />
                        </Col>
                        OR
                        <Col>
                            <hr />
                        </Col>
                    </Row>
Spark's avatar
Spark committed
156
157

                    <Row style={{ margin: 'auto', marginBottom: '5px', display: 'flex', justifyContent: 'center' }}>
Spark's avatar
Spark committed
158
159
                        <a href="#;" onClick={LoginWithKakao} id='socialLink' >
                            <img src='http://image.kmib.co.kr/online_image/2020/0626/611514110014734788_1.jpg' id='logpng' alt='KAKAO' />
Spark's avatar
Spark committed
160
161
162
163
164
165
166
167
168
                        </a>
                    </Row>
                </Card.Text>
            </Card>
        </Row>
    )
}

export default SignupComp;