Skip to content

Commit

Permalink
[FEAT] 게시글 작성 기능 구현 (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
jh2ee committed Jul 25, 2023
1 parent 08df84a commit 4ba65d5
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
Empty file added job1/src/Community/Write.js
Empty file.
63 changes: 62 additions & 1 deletion job1/src/View/Write.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,66 @@

import { useState } from "react";
import { useNavigate, useLocation } from "react-router-dom";

function Write() {
return <div>Write</div>;
const [post, setPost] = useState({
title: '',
content: '',
author: '',
likes: '0'
});

const { title, content, author, likes } = post;

const onChange = (e) => {
const { name, value } = e.target;
setPost({
...post,
[name]: value,
});
};

const navigate = useNavigate();
const submit = (e) => {
e.preventDefault();
alert('등록되었습니다!');
navigate('/community');
console.log(post);
};

const cancel = () => {
navigate(`/community`);
};

return (
<form>
<div>
<p>글쓰기</p>
<hr/>
<input
type="text"
name="title"
placeholder="제목"
value={title}
onChange={onChange}
/>
<textarea
name="content"
placeholder="내용을 입력하세요"
value={content}
onChange={onChange}
></textarea>
</div>
<div>
<p>태그 선택</p>
<hr/>
{/* 태그 */}
<hr/>
<button onClick={submit}>등록</button>
<button onClick={cancel}>취소</button>
</div>
</form>
);
}

export default Write;

0 comments on commit 4ba65d5

Please sign in to comment.