Skip to content

새 그룹 생성 페이지 구현 #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 76 additions & 7 deletions polling-app-client/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion polling-app-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"devDependencies": {
"babel-plugin-import": "^1.6.5",
"react-app-rewire-less": "^2.1.0",
"react-app-rewired": "^1.4.1"
"react-app-rewired": "^1.6.2"
}
}
14 changes: 14 additions & 0 deletions polling-app-client/src/new-group-page/NewGroupPage.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.new-group-container {
max-width: 600px;
margin: 0 auto;
padding: 20px;
}

.member-list {
margin-top: 10px;
padding-left: 20px;
}

.member-list li {
margin-bottom: 4px;
}
102 changes: 102 additions & 0 deletions polling-app-client/src/new-group-page/NewGroupPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import React, { useState } from 'react';
import { Input, Button, Form, message } from 'antd';
import axios from 'axios';
import './NewGroupPage.css'; // CSS ��� ���� import

const NewGroupPage = () => {
const [name, setName] = useState('');
const [description, setDescription] = useState('');
const [imageUrl, setImageUrl] = useState('');
const [members, setMembers] = useState([]);
const [memberInput, setMemberInput] = useState('');
const [loading, setLoading] = useState(false);

const handleAddMember = () => {
if (memberInput.trim() === '') return;
setMembers([...members, memberInput.trim()]);
setMemberInput('');
};

const handleSubmit = async (e) => {
e.preventDefault();
setLoading(true);

try {
await axios.post('/api/groups', {
name,
description,
imageUrl,
members,
});

message.success('�׷��� ���������� �����Ǿ����ϴ�!');
setName('');
setDescription('');
setImageUrl('');
setMembers([]);
setMemberInput('');
} catch (error) {
console.error(error);
message.error('�׷� ���� ����!');
} finally {
setLoading(false);
}
};

return (
<div className="new-group-container">
<h1>�� �׷� ����</h1>
<Form layout="vertical" onSubmitCapture={handleSubmit}>
<Form.Item label="�׷� �̸�">
<Input
value={name}
onChange={(e) => setName(e.target.value)}
placeholder="��: ���͵� �׷�"
/>
</Form.Item>

<Form.Item label="�׷� ����">
<Input.TextArea
value={description}
onChange={(e) => setDescription(e.target.value)}
placeholder="��: �Բ� �����ϴ� ���͵��Դϴ�."
rows={4}
/>
</Form.Item>

<Form.Item label="�̹��� URL">
<Input
value={imageUrl}
onChange={(e) => setImageUrl(e.target.value)}
placeholder="��: https://example.com/image.jpg"
/>
</Form.Item>

<Form.Item label="�׷� ��� �߰�">
<Input
value={memberInput}
onChange={(e) => setMemberInput(e.target.value)}
onPressEnter={handleAddMember}
placeholder="�̸��� �Ǵ� ����� �̸�"
/>
<Button onClick={handleAddMember} style={{ marginTop: '8px' }}>
��� �߰�
</Button>
<ul className="member-list">
{members.map((member, index) => (
<li key={index}>{member}</li>
))}
</ul>
</Form.Item>

<Form.Item>
<Button type="primary" htmlType="submit" loading={loading}>
�׷� ����
</Button>
</Form.Item>
</Form>
</div>
);
};

export default NewGroupPage;
Loading