Skip to content

Commit

Permalink
뒤로가기 버튼 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
BumgeunSong committed Oct 20, 2024
1 parent 7676e8e commit 1d7216d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/components/Pages/BackToFeedButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import { useNavigate } from 'react-router-dom';

const BackToFeedButton: React.FC = () => {
const navigate = useNavigate();

const handleBackToFeed = () => {
navigate('/feed');
};

return (
<button onClick={handleBackToFeed}>
피드로 돌아가기
</button>
);
};

export default BackToFeedButton;
2 changes: 2 additions & 0 deletions src/components/Pages/EditPostPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { doc, updateDoc, serverTimestamp } from 'firebase/firestore';
import { useAuth } from '../../contexts/AuthContext';
import ReactQuill from 'react-quill';
import 'react-quill/dist/quill.snow.css';
import BackToFeedButton from './BackToFeedButton';

const EditPostPage: React.FC = () => {
const { id } = useParams<{ id: string }>();
Expand Down Expand Up @@ -44,6 +45,7 @@ const EditPostPage: React.FC = () => {
return (
<div>
<h1>Edit Post</h1>
<BackToFeedButton />
<form onSubmit={handleSubmit}>
<ReactQuill value={content} onChange={setContent} />
<button type="submit">Update Post</button>
Expand Down
4 changes: 3 additions & 1 deletion src/components/Pages/PostDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { deleteDoc, doc } from 'firebase/firestore';
import { fetchPost } from '../../utils/postUtils';
import { Post } from '../../types/Posts';
import { useAuth } from '../../contexts/AuthContext';
import BackToFeedButton from '../Pages/BackToFeedButton';

const deletePost = async (id: string): Promise<void> => {
await deleteDoc(doc(firestore, 'posts', id));
Expand Down Expand Up @@ -65,6 +66,7 @@ const PostDetailPage: React.FC = () => {

return (
<div>
<BackToFeedButton />
<h1>{post.title}</h1>
<div dangerouslySetInnerHTML={{ __html: post.content }} />
<p>
Expand All @@ -80,4 +82,4 @@ const PostDetailPage: React.FC = () => {
);
};

export default PostDetailPage;
export default PostDetailPage;

0 comments on commit 1d7216d

Please sign in to comment.