HomePage.js 5.56 KB
Newer Older
Soo Hyun Kim's avatar
Soo Hyun Kim committed
1
import React, { useState } from 'react';
Soo Hyun Kim's avatar
Soo Hyun Kim committed
2
import { ListGroup, Col, Row, Modal, Button, Form, Alert } from 'react-bootstrap';
Soo Hyun Kim's avatar
Soo Hyun Kim committed
3
import 'bootstrap/dist/css/bootstrap.min.css';
Soo Hyun Kim's avatar
Soo Hyun Kim committed
4
5
import randCode from '../randCode'
// import randomN from './RandomN';
Soo Hyun Kim's avatar
Soo Hyun Kim committed
6
7
8
9
10
11
12
13
14
15
16
17

function Home() {
    const [list, setList] = useState([
        { room: '테스트 방1', memnum: 5, admin: '가영' },
        { room: '테스트 방2', memnum: 4, admin: '수현' }]
    );

    const [show, setShow] = useState(false);

    const handleClose = () => setShow(false);
    const handleShow = () => setShow(true);

Soo Hyun Kim's avatar
Soo Hyun Kim committed
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
    const [show2, setShow2] = useState(false);

    const handleClose2 = () => setShow2(false);
    const handleShow2 = () => setShow2(true);

    const [checkedI, setCheckedI] = useState(false);

    const codeClose = () => setCheckedI(false);
    const codeShow = () => setCheckedI(true);

    const [showCode, setCode] = useState(false);

    const handleCloseCode = () => setCode(false);
    const handleShowCode = () => setCode(true);

Soo Hyun Kim's avatar
Soo Hyun Kim committed
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

    return (
        <div className="container">
            <div className="list">
                <Col md={6}>
                    {list.map(list =>
                        <ListGroup>
                            <ListGroup.Item action>
                                <h2>{list.room}</h2>
                                <p></p>
                            </ListGroup.Item>
                        </ListGroup>
                    )}
                </Col>
            </div>
            <div className="right">
                <button variant="primary" onClick={handleShow}>
                    생성
                </button>

Soo Hyun Kim's avatar
Soo Hyun Kim committed
53
54
55
56
                <button variant="primary" onClick={handleShow2}>
                    참가
                </button>

Soo Hyun Kim's avatar
Soo Hyun Kim committed
57
58
59
60
61
                <Modal show={show} onHide={handleClose}>
                    <Modal.Header closeButton>
                        <Modal.Title> 생성</Modal.Title>
                    </Modal.Header>
                    <Modal.Body>
Soo Hyun Kim's avatar
Soo Hyun Kim committed
62
                        <Form onSubmit = {handleShowCode}>
Soo Hyun Kim's avatar
Soo Hyun Kim committed
63
64
65
                            <Form.Group as={Row} controlId="formChatTitle">
                                <Form.Label column sm={4}> 이름</Form.Label>
                                <Col>
Soo Hyun Kim's avatar
Soo Hyun Kim committed
66
                                    <Form.Control type="text" />
Soo Hyun Kim's avatar
Soo Hyun Kim committed
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
                                </Col>
                            </Form.Group>
                            <Form.Group as={Row} controlId="formInterest">
                                <Form.Label column sm={4}>관심 분야</Form.Label>
                                <Col>
                                    <Form.Control as="select" defaultValue="Choose...">
                                        <option>Choose...</option>
                                        <option>과학</option>
                                        <option>수학</option>
                                        <option>예술</option>
                                        <option>언어</option>
                                        <option>취미</option>
                                    </Form.Control>
                                </Col>
                            </Form.Group>
                            <Form.Group as={Row} controlId="formBasicCheckbox">
                                <Form.Label column sm={4}>공개방</Form.Label>
                                <Col>
Soo Hyun Kim's avatar
Soo Hyun Kim committed
85
86
87
88
                                    <Form.Check
                                        type="checkbox"
                                        checked={checkedI}
                                        onChange={() => setCheckedI(!checkedI)} />
Soo Hyun Kim's avatar
Soo Hyun Kim committed
89
90
                                </Col>
                            </Form.Group>
Soo Hyun Kim's avatar
Soo Hyun Kim committed
91
92
93
94
95
                            {
                                (checkedI)
                                    ? (<p><b>공개방</b>으로 개설되어 공개방 목록에 공개되며, 코드를 공유하여 참가할 수도 있습니다.</p>)
                                    : (<p><b>비밀방</b>으로 개설되며, 참여자들에게 코드를 공유해야합니다.</p>)
                            }
Soo Hyun Kim's avatar
Soo Hyun Kim committed
96
97
                            <Form.Group as={Row}>
                                <Col sm={{ span: 5, offset: 4 }}>
Soo Hyun Kim's avatar
Soo Hyun Kim committed
98
                                    <Button type="submit" > 생성</Button>
Soo Hyun Kim's avatar
Soo Hyun Kim committed
99
100
101
102
103
104
                                </Col>
                            </Form.Group>
                        </Form>
                    </Modal.Body>
                </Modal>

Soo Hyun Kim's avatar
Soo Hyun Kim committed
105
                {(showCode)? (alert('참여코드'), setCode(false)):null}
Soo Hyun Kim's avatar
Soo Hyun Kim committed
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126

                <Modal show={show2} onHide={handleClose2}>
                    <Modal.Header closeButton>
                        <Modal.Title>참여 코드로 채팅 참가</Modal.Title>
                    </Modal.Header>
                    <Modal.Body>
                        <Form onSubmit={() => { console.log('제출') }}>
                            <Form.Group as={Row} controlId="formCodeE">
                                <Form.Label column sm={4}>참여 코드</Form.Label>
                                <Col>
                                    <Form.Control type="text" />
                                </Col>
                            </Form.Group>
                            <Form.Group as={Row}>
                                <Col sm={{ span: 5, offset: 4 }}>
                                    <Button type="submit">참가</Button>
                                </Col>
                            </Form.Group>
                        </Form>
                    </Modal.Body>
                </Modal>
Soo Hyun Kim's avatar
Soo Hyun Kim committed
127
            </div>
Soo Hyun Kim's avatar
Soo Hyun Kim committed
128
        </div >
Soo Hyun Kim's avatar
Soo Hyun Kim committed
129
130
131
132
    );
}

export default Home;