diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index acea016216e5ebbaf9d18d5b970a87525bf23677..adb343e102be9ae917ac6c37848501cab0e04144 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -27,9 +27,9 @@ export const App = () => { } /> } /> - }> - } /> - + } /> + } /> + {/* */} -
+

Id

empty

+ > + {post.text} +
diff --git a/frontend/src/post/intopost.tsx b/frontend/src/post/intopost.tsx index a63fb1671cdef179625e5ea4f9c15fd6d2516988..dc184f118b58a1e69fc69a636ed03a4338e0974b 100644 --- a/frontend/src/post/intopost.tsx +++ b/frontend/src/post/intopost.tsx @@ -1,5 +1,5 @@ import React, { MouseEvent } from "react"; -import { useLocation, useNavigate, Link } from "react-router-dom"; +import { useLocation, useNavigate, Link, Outlet } from "react-router-dom"; import { postApi } from "../apis"; import { PostType } from "../types"; @@ -23,42 +23,45 @@ export function IntoPost() { return (
-
-
- +
+
+
+ +
+
+ + + +
-
- - - +
+
+ 제목: {post.title} +
+
+ 작성자: nickname +
-
-
-
- 제목: {post.title} -
-
- 작성자: nickname -
-
-
-
- 도시: {post.city} -
-
- 테마: {post.theme} -
-
- 작성일: {post.date} -
-
- 조회수: {post.counts} +
+
+ 도시: {post.city} +
+
+ 테마: {post.theme} +
+
+ 작성일: {post.date} +
+
+ 조회수: {post.counts} +
+
{post.text}
-
{post.text}
+ {/* */}
); } diff --git a/src/controllers/post.controller.ts b/src/controllers/post.controller.ts index c6cf78a3784bf2b925f5a97f2046c937fe5b44fd..41ed408bd6b08c55305ce33dddd3adab7cac301f 100644 --- a/src/controllers/post.controller.ts +++ b/src/controllers/post.controller.ts @@ -94,7 +94,7 @@ export const getOnePost = asyncWrap(async (req, res) => { export const deleteOnePost = asyncWrap(async (req, res) => { const { postId } = req.params; - console.log(postId); + // console.log(postId); const deleteCount = await postDb.deletePost(postId); return res.json(deleteCount); diff --git a/src/db/post.db.ts b/src/db/post.db.ts index d71dfdf343bff1c503561c7779163a268d1e8324..4c89712d3155763bbc26b6b6ae6be701f461aae5 100644 --- a/src/db/post.db.ts +++ b/src/db/post.db.ts @@ -42,7 +42,15 @@ export const deletePost = async (_id: string) => { export const updateOnePost = async (post: PostType, _id: string) => { const newPost = await Post.findOneAndUpdate( { _id: _id }, - { post }, + { + title: post.title, + text: post.text, + theme: post.theme, + city: post.city, + date: post.date, + counts: post.counts, + user: post.user, + }, { new: true } ); return newPost; diff --git a/src/routes/post.route.ts b/src/routes/post.route.ts index 384992b161233e97d99cdb4214d4385bb307474d..c0108bea00be7a10e634091392bfff02db6c1572 100644 --- a/src/routes/post.route.ts +++ b/src/routes/post.route.ts @@ -9,11 +9,9 @@ router.route("/").get(postCtrl.getAllPost); router .route("/:postId") .post(authCtrl.requireLogin, postCtrl.addCounts) - .get(authCtrl.requireLogin, postCtrl.getOnePost); - -router.route("/:postId").delete(authCtrl.requireLogin, postCtrl.deleteOnePost); // authenticate - -router.route("/:postId").put(authCtrl.requireLogin, postCtrl.updatePost); + .get(authCtrl.requireLogin, postCtrl.getOnePost) + .delete(authCtrl.requireLogin, postCtrl.deleteOnePost) // authenticate + .put(authCtrl.requireLogin, postCtrl.updatePost); router.param("postId", postCtrl.userByPostId); export default router;