feat: 게시물 답글 등록 기능
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
||||
import { CreatePage } from "@/pages/(pst)/normal";
|
||||
|
||||
export default async function PstBbsNormalAnswerPage({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ bbsId: string; pstNo: string }>;
|
||||
}) {
|
||||
const { bbsId, pstNo } = await params;
|
||||
return <CreatePage bbsId={bbsId} pstNo={pstNo} />;
|
||||
}
|
||||
@@ -8,7 +8,9 @@ import { PostForm } from "@/widgets/post";
|
||||
import { PostApi, postFormSchema, type PostFormData } from "@/entities/post";
|
||||
import { useAlertStore, useUserStore } from "@/shared/lib";
|
||||
|
||||
function CreatePage({ bbsId }: { bbsId: string }) {
|
||||
function CreatePage({ bbsId, pstNo }: { bbsId: string; pstNo?: string }) {
|
||||
const answerRegisterMode = !!pstNo;
|
||||
|
||||
const router = useRouter();
|
||||
const { userInfo } = useUserStore((state) => state);
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
@@ -30,13 +32,16 @@ function CreatePage({ bbsId }: { bbsId: string }) {
|
||||
popupYn: "N",
|
||||
upndFixYn: "N",
|
||||
prdPstgYn: "N",
|
||||
parentPstNo: pstNo ? parseInt(pstNo) : null,
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="card card-border !mt-6">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">게시글 등록</h3>
|
||||
<h3 className="text-2xl font-medium text-label">
|
||||
{answerRegisterMode ? "답글 등록" : "게시글 등록"}
|
||||
</h3>
|
||||
</div>
|
||||
<PostForm form={form} handleSave={createPost} />
|
||||
</div>
|
||||
|
||||
@@ -47,10 +47,21 @@ export const columns: ColumnDef<Post & { isUpndFixPost?: boolean }>[] = [
|
||||
accessorKey: "pstTtl",
|
||||
header: "제목",
|
||||
cell: ({ row }) => {
|
||||
const { pstTtl, inqNocs } = row.original;
|
||||
const { ansPstn, pstTtl, inqNocs } = row.original;
|
||||
|
||||
return (
|
||||
<div className="flex min-w-[20vw] items-center gap-2 text-left">
|
||||
<div
|
||||
className="flex min-w-[20vw] items-center gap-2 text-left"
|
||||
style={{ paddingInlineStart: `${ansPstn * 10}px` }}
|
||||
>
|
||||
{ansPstn > 0 && (
|
||||
<div className="flex items-center gap-1">
|
||||
<div className="-rotate-90">
|
||||
<i className="diveicon di-arrow-90left-down rotate-90" />
|
||||
</div>
|
||||
<Badge color="smokyBlue">답변</Badge>
|
||||
</div>
|
||||
)}
|
||||
{inqNocs >= 100 && <Badge color="red">HOT</Badge>}
|
||||
{dayjs().diff(dayjs(row.original.regDt), "hour") < 24 && (
|
||||
<Badge color="blue">NEW</Badge>
|
||||
|
||||
@@ -50,6 +50,14 @@ function PostAction({ children, bbsId, pstNo }: PostActionProps) {
|
||||
>
|
||||
수정
|
||||
</Button>
|
||||
<Button
|
||||
size="lg"
|
||||
type="button"
|
||||
color="gray"
|
||||
onClick={() => router.push(`${pathname}/answer`)}
|
||||
>
|
||||
답글
|
||||
</Button>
|
||||
<Button size="lg" color="red" type="button" onClick={onDelete}>
|
||||
삭제
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user