게시물 등록 기능 추가
All checks were successful
Build And Test / build-and-push (push) Successful in 1m42s

This commit is contained in:
2025-05-25 01:12:01 +09:00
parent b94f6cea2e
commit add285da04
5 changed files with 224 additions and 22 deletions

View File

@ -0,0 +1,72 @@
// src/pages/BoardsPage.js
import React, { useState } from "react";
import BoardList from "../components/Board/BoardList";
import PostList from "../components/Board/PostList";
import PostSearchPanel from "../components/Board/PostSearchPanel";
import PostForm from "../components/Board/PostForm";
const BoardsPage = () => {
const [selectedBoard, setSelectedBoard] = useState(null);
const [search, setSearch] = useState("");
const [tag, setTag] = useState("");
const [showForm, setShowForm] = useState(false);
const [refreshKey, setRefreshKey] = useState(0); // 게시글 새로고침 트리거
const handleCreated = () => setRefreshKey(prev => prev + 1);
return (
<div className="grid grid-cols-3 gap-4 p-4">
{/* 좌측: 게시판 리스트 */}
<div>
<BoardList
selectedBoard={selectedBoard}
onSelectBoard={(slug) => {
setSelectedBoard(slug);
setSearch("");
setTag("");
}}
/>
</div>
{/* 중앙: 게시글 리스트 or 등록폼 */}
<div>
{selectedBoard && !showForm && (
<div className="mb-2">
<button
className="bg-green-500 text-white px-4 py-2 rounded"
onClick={() => setShowForm(true)}
>
게시글 등록
</button>
</div>
)}
{showForm ? (
<PostForm
boardSlug={selectedBoard}
onClose={() => setShowForm(false)}
onCreated={handleCreated}
/>
) : (
<PostList
boardSlug={selectedBoard}
search={search}
tag={tag}
key={refreshKey}
/>
)}
</div>
{/* 우측: 검색 + 태그 */}
<div>
<PostSearchPanel
boardSlug={selectedBoard}
onSearch={setSearch}
onTagSelect={setTag}
/>
</div>
</div>
);
};
export default BoardsPage;