Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/pages/Detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ function Detail() {
const { id } = useParams();
const getDetail = (id) => {
const post = posts.find((post) => post.id === parseInt(id));
if(!post) return null;
console.log("post id:", post.id);
if(!post) return 0;

return {
id:post.id,
Expand Down
12 changes: 6 additions & 6 deletions src/pages/code_function/CodeItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ const CodeItem = ({ onClick, post }) => {
//const { selectedType, handleTypeChange , posts} = useCodeContext();
const { id, title, likes, category, date, user } = post;

console.log("CodeItem id:", id);

const print = () => {
console.log("CodeItem id:", id);
console.log("CodeItem category:", category);
};


return (


<div className="codeSpaceItem" category={category} onClick = {()=>{onClick(id)}} >

<div className="codeSpaceItem" category={category} onClick = {()=>{onClick(id); print();}} >
{/* <img src={image} alt="Code Thumbnail" className="CodeThumbnail" /> */}
<div className="codeNumber"><h1>{id}&nbsp;&nbsp;</h1></div>
<div className="codeContent">
<span className="codeTitle">{title}</span>
<span className="codeMeta">{date} | {user.nickname} | ❤️{likes}</span>
</div>
</div>



);
};
Expand Down
9 changes: 4 additions & 5 deletions src/pages/code_function/CodePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const CodePage = () => {
try {
const res = await axios.get("http://localhost:8080/api/getPost");
setPosts(res.data); // ✅ 서버가 보낸 JSON은 res.data 안에 들어있음
console.log(res.data);
console.log(res.data.category);
} catch (err) {
setError(err.message);
} finally {
Expand All @@ -35,10 +35,9 @@ const CodePage = () => {
{ id: 3, image: "/logo192.png", title: "Python 예제", type: "python", likes: 22 }
];

// 필터링
const filteredItems = selectedType === "All"
? posts
: posts.filter(post => post.category === selectedType);
const filteredItems = selectedType === "All"
? posts
: posts.filter(post => post.category === selectedType)

return (
<div className="codePage">
Expand Down