NicknameChange.js 2.28 KB
Newer Older
1
2
import axios from 'axios';
import React, { useEffect, useState } from 'react'
Spark's avatar
Spark committed
3
import { Row, Card, Col, Form, Button, FloatingLabel } from 'react-bootstrap';
4
import { callUserInfo } from '../utils/CheckDB';
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

function NicknameChange() {

    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: '0.5em',
        color: 'black'
    }

30
    const [inputname, setInputname] = useState('')
Spark's avatar
Spark committed
31

32
33
    function handleChange({ target: { value } }) {
        setInputname(value)
Spark's avatar
Spark committed
34
    }
35
    console.log(inputname)
Spark's avatar
Spark committed
36

37
    async function handleSubmit(event) {
Spark's avatar
Spark committed
38
        event.preventDefault();
39
40
41
42
43
44
45
        await axios.post('/api/edit-profile', { nick_name: inputname })
            .then(function (response) {
                console.log(response);
            })
            callUserInfo().then((res) => {
                console.log('11', res[0])
            })
Spark's avatar
Spark committed
46

47
48
        // window.location.reload();
    };
Spark's avatar
Spark committed
49
50
51
52
53
54
55
56
57
58

    return (
        <Row className='text-center w-100 my-2'>
            <Card style={cardstyled}>
                <Card.Title id='impactTitle'>
                    닉네임 변경
                </Card.Title>
                <Card.Subtitle style={{ fontWeight: 'lighter' }}>
                    새로운 닉네임으로 변경해보세요
                </Card.Subtitle>
59

Spark's avatar
Spark committed
60
61
                <hr />

62
                <Card.Text className='m-0'>
Spark's avatar
Spark committed
63
                    <Form style={inboxstyled} onSubmit={handleSubmit}>
64
                        <FloatingLabel label="Nickname">
Spark's avatar
Spark committed
65
66
67
68
69
70
71
72
73
74
75
76
77
                            <Form.Control type="text" placeholder="닉네임 변경" id='nickname' onChange={handleChange} />
                        </FloatingLabel>
                        <Button variant='light' className='mt-3' id='formbtn' type='submit'>
                             
                        </Button>
                    </Form>
                </Card.Text>
            </Card>
        </Row>
    )
}

export default NicknameChange;