Skip to content

Commit

Permalink
Create group page (#7)
Browse files Browse the repository at this point in the history
* 완료버튼 추가

* 그룹생성 페이지 수정

* ci: 설정 파일 수정

* feat: 헤더 영역 추가

* remove: 버튼 삭제

* feat: dummy 데이터 파일 생성

* docs: import styled-component 삭제

* feat: tab 생성

---------

Co-authored-by: 조준호 <[email protected]>
  • Loading branch information
dassasa and 조준호 authored Apr 15, 2024
1 parent 28c306d commit bf3fb54
Show file tree
Hide file tree
Showing 7 changed files with 264 additions and 17 deletions.
26 changes: 24 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
module.exports = {
env: {
browser: true,
es2021: true,
node: true,
jest: true,
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:jsx-a11y/recommended',
'plugin:react-hooks/recommended',
],
overrides: [],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
plugins: ['react', 'react-hooks', 'jsx-a11y'],
rules: {
'react/react-in-jsx-scope': 'off',
},
settings: {
react: { version: 'detect' },
},
extends: ['eslint:recommended', 'plugin:react/recommended'],
plugins: ['react'],
}
8 changes: 4 additions & 4 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ import NavBar from './Components/NavBar/NavBar'

function App() {
return (
<div className="App">
<BrowserRouter>
<BrowserRouter>
<div className="App">
<NavBar />
<Routes>
<Route path="/createGroup" element={<CreateGroup />} />
<Route path="/showGroupList" element={<ShowGroupList />} />
<Route path="/showGroupDetails" element={<ShowGroupDetails />} />
</Routes>
</BrowserRouter>
</div>
</div>
</BrowserRouter>
)
}

Expand Down
144 changes: 144 additions & 0 deletions src/Components/Forms/CreateForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import React from 'react'
import { PlusOutlined } from '@ant-design/icons'
import { Form, Input, Button, Upload } from 'antd'
import styled from 'styled-components'

// 폼 전송 성공 시 실행되는 함수
/* Create 구현 필요 */
const onFinish = async (values) => {
try {
const formData = new FormData()
formData.append('groupname', values.groupname)
formData.append('groupdescription', values.groupdescription)
if (values.fileList && values.fileList.length > 0) {
formData.append('file', values.fileList[0].originFileObj)
}

const response = await fetch('http://localhost:3001/groups', {
method: 'POST',
body: formData,
})

if (!response.ok) {
throw new Error('서버 응답이 실패하였습니다.')
}

console.log('폼 데이터 전송 성공:', values.groupname)
} catch (error) {
console.error('폼 데이터 전송 실패:', error)
}
}

// 폼 전송 실패 시 실행되는 함수
const onFinishFailed = (errorInfo) => {
console.log('Failed:', errorInfo)
}

// 파일 업로드 시 실행되는 함수
const normFile = (e) => {
console.log('Upload event:', e)
if (Array.isArray(e)) {
return e
}
return e && e.fileList
}

// 전체 폼을 감싸는 스타일드 컴포넌트
const StyledForm = styled(Form)`
margin: 30px;
`
// 폼을 감싸는 스타일드 컴포넌트
const StyledFormWrapper = styled.div`
padding: 10px;
border-radius: 10px;
background-color: rgba(0, 62.67, 151.94, 0.08);
max-width: 800px;
margin: 10px auto;
`

// 타이틀을 감싸는 스타일드 컴포넌트
const Title = styled.h1`
margin: 10px 40px;
text-align: left;
font-size: 32px;
font-family: 'KoPubWorld Dotum';
font-weight: 700;
word-wrap: break-word;
`
// 폼 아이템을 감싸는 스타일드 컴포넌트
const StyledFormItems = styled(Form.Item)`
.ant-form-item-label {
text-align: left;
margin-left: 40px;
font-size: 24px;
font-family: 'KoPubWorld Dotum';
font-weight: 700;
word-wrap: break-word;
}
.ant-input {
text-align: left;
font-size: 14px;
margin-top: 6px;
}
.ant-btn {
height: 50px;
width: 100px;
font-size: 24px;
}
`
const CreateForm = () => (
<StyledForm
name="basic"
labelCol={{
span: 3,
}}
wrapperCol={{
span: 16,
}}
initialValues={{
remember: true,
}}
onFinish={onFinish}
onFinishFailed={onFinishFailed}
autoComplete="off"
>
<StyledFormWrapper>
<Title>모임 기본 정보 등록</Title>
<StyledFormItems label="모임 이름" name="groupname">
<Input placeholder="ex) 한사랑산악회, 숭실대 IT대 학생회" />
</StyledFormItems>
<StyledFormItems label="모임 설명" name="groupdescription">
<Input placeholder="ex) 열정 있는 사람들의 모임" />
</StyledFormItems>
</StyledFormWrapper>
<StyledFormWrapper>
<Title>모임 회원 등록</Title>
<StyledFormItems label="파일 업로드" valuePropName="fileList" getValueFromEvent={normFile}>
<Upload action="/upload.do" accept=".csv, .xlsx" listType="picture-card" maxCount={1}>
<button
style={{
border: 0,
background: 'none',
}}
type="button"
>
<PlusOutlined />
<div
style={{
marginTop: 8,
}}
>
업로드하기
</div>
</button>
</Upload>
</StyledFormItems>
</StyledFormWrapper>
<StyledFormItems wrapperCol={{}}>
<Button type="primary" htmlType="submit">
완료
</Button>
</StyledFormItems>
</StyledForm>
)
export default CreateForm
39 changes: 32 additions & 7 deletions src/Components/NavBar/NavBar.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,43 @@
import { Menu } from 'antd'
import { Link } from 'react-router-dom'
import React from 'react'
import styled from 'styled-components'

const StyledNavBar = styled.div`
const StyledMenu = styled(Menu)`
height: 200px;
width: 100%;
background-color: green;
background-color: #003f98;
display: flex;
justify-content: right;
padding: 40px;
.ant-menu-item {
height: 40px;
color: white;
font-size: 22px;
font-weight: 700;
font-family: 'KoPubWorld Dotum';
word-wrap: break-word;
margin-right: 50px;
}
`

const items = [
{
key: 'myGroups',
label: <Link to="/showGroupList">나의 모임</Link>,
},
{
key: 'myEvents',
label: <Link to="/showEventList">나의 이벤트</Link>,
},
{
key: 'myProfile',
label: <Link to="/showProfile">김보안</Link>,
},
]

const NavBar = () => {
return (
<div>
<StyledNavBar />
</div>
)
return <StyledMenu mode="horizontal" items={items}></StyledMenu>
}

export default NavBar
9 changes: 7 additions & 2 deletions src/Pages/CreateGroupPage/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import React from 'react'
// import styled from 'styled-components'
import CreateForm from '../../Components/Forms/CreateForm'
//import CreateForm from '../../Components/Forms/CreateForm'

const CreateGroup = () => {
return <div></div>
return (
<div>
<CreateForm />
</div>
)
}

export default CreateGroup
34 changes: 32 additions & 2 deletions src/Pages/ShowGroupDetails/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,37 @@
import React from 'react'

import styled from 'styled-components'
import { Tabs } from 'antd'
import dummy from '../../db/data.json'
const Wrapper = styled.div`
padding: 10px;
border-radius: 10px;
background-color: rgba(0, 62.67, 151.94, 0.08);
max-width: 400px;
margin: 10px 60px;
`
const onChange = (key) => {
console.log(key)
}
/* Read 구현 필요 */
const items = [
{
key: '1',
label: '회원',
children: '그룹 정보',
},
{
key: '2',
label: '이벤트',
children: '그룹 멤버',
},
]
console.log(dummy)
const ShowGroupDetails = () => {
return <div>ShowGroupDetails 페이지</div>
return (
<Wrapper>
<Tabs defaultActiveKey="1" items={items} onChange={onChange}></Tabs>
</Wrapper>
)
}

export default ShowGroupDetails
21 changes: 21 additions & 0 deletions src/db/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"users": [{ "userId": 1 }, { "userId": 2 }, { "userId": 3 }],

"groups": [
{
"id": 1,
"name": "모임1",
"descript": "모임1입니다."
},
{
"id": 2,
"name": "모임2",
"descript": "모임2입니다."
},
{
"id": 3,
"name": "모임3",
"descript": "모임3입니다."
}
]
}

0 comments on commit bf3fb54

Please sign in to comment.