diff --git a/public/icons/ic_back.svg b/public/icons/ic_back.svg new file mode 100644 index 000000000..253a47d7b --- /dev/null +++ b/public/icons/ic_back.svg @@ -0,0 +1,4 @@ + diff --git a/src/app/board/[id]/BoardDetail.jsx b/src/app/board/[id]/BoardDetail.jsx index cceb65384..051001afd 100644 --- a/src/app/board/[id]/BoardDetail.jsx +++ b/src/app/board/[id]/BoardDetail.jsx @@ -1,12 +1,14 @@ "use client"; import ActionDropdown from "@/components/ActionDropdown"; +import { API_BASE_URL } from "@/lib/api"; import Image from "next/image"; import { useRouter } from "next/navigation"; import React from "react"; const BoardDetail = ({ data }) => { const router = useRouter(); + const handleModify = () => { router.push( `/board/new?id=${data.id}&title=${encodeURIComponent( @@ -16,17 +18,15 @@ const BoardDetail = ({ data }) => { )}&author=${encodeURIComponent(data.author)}` ); }; + const handleDelete = async () => { try { - const res = await fetch(`http://localhost:4000/posts/${data.id}`, { + const res = await fetch(`${API_BASE_URL}/posts/${data.id}`, { method: "DELETE", // header 필요해? // 오답노트: 나중에 인가시에 필요 }); - if (!res.ok) { - alert("게시글 삭제에 실패했습니다."); - console.error(res.statusText); - } + if (!res.ok) throw new Error(`delete failed: ${res.statusText}`); alert("삭제가 완료되었습니다."); router.push("/board"); @@ -34,13 +34,14 @@ const BoardDetail = ({ data }) => { console.error(err); } }; + return ( -