-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* New : 포스트 디테일 페이지 인터셉트 라우트 구현 * New : 포스트 디테일 페이지 인터셉트 라우트 구현 * New : 포스트 디테일 URL 함수로 관리 * Minor : 해시태그 모킹 추가 * Minor : Fixme 추가
- Loading branch information
1 parent
486694b
commit fadf6de
Showing
10 changed files
with
222 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import ModalWrapper from "@/components/ModalWrapper"; | ||
import PostDetail from "@/components/post/PostDetail"; | ||
|
||
const mockData = { | ||
id: "123458", | ||
createdAt: "Mon Nov 06 2023 00:13:07", | ||
nickname: "testNick", | ||
userId: "userID", | ||
userImage: "https://source.unsplash.com/random?wallpapers", | ||
content: | ||
"Lorem ipsum dolor, sit amet consectetur adipisicing elit. Eos ullam aut minus aliquam quis officia, non dolore omnis, magnam totam tenetur ad harum? Mollitia omnis odit atque blanditiis exercitationem! Voluptatum.", | ||
image: ["https://source.unsplash.com/random?wallpapers"], | ||
tags: ["해시태그1", "해시태그2"], | ||
}; | ||
|
||
const page = () => { | ||
return ( | ||
<ModalWrapper> | ||
<PostDetail {...mockData} /> | ||
</ModalWrapper> | ||
); | ||
}; | ||
|
||
export default page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const Default = () => { | ||
return null; | ||
}; | ||
|
||
export default Default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"use client"; | ||
import { Box, Modal, ModalProps } from "@mui/material"; | ||
import { useRouter } from "next/navigation"; | ||
|
||
import { ReactNode } from "react"; | ||
|
||
interface ModalInterface | ||
extends Omit<ModalProps, "open" | "onClick" | "children"> { | ||
children?: ReactNode; | ||
/** | ||
* 기본으로 설정된 <Box/> 의 패딩, 배경색 속성을 제거 | ||
*/ | ||
disableBox?: boolean; | ||
} | ||
|
||
/** | ||
* MUI <Modla/>과 <Box/>를 랩핑해놓은 글로벌 모달 | ||
*/ | ||
const ModalWrapper = ({ children, disableBox }: ModalInterface) => { | ||
const { back } = useRouter(); | ||
|
||
return ( | ||
<Modal | ||
open={true} | ||
onClick={() => back()} | ||
disablePortal | ||
sx={{ | ||
alignItems: "center", | ||
justifyContent: "center", | ||
display: "flex", | ||
}} | ||
> | ||
{ | ||
<Box | ||
sx={{ | ||
bgcolor: disableBox ? undefined : "background.paper", | ||
p: disableBox ? 0 : 4, | ||
maxWidth: "90%", | ||
maxHeight: "90%", | ||
overflowY: "scroll", | ||
}} | ||
> | ||
{children} | ||
</Box> | ||
} | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default ModalWrapper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { PostInterface } from "@/types/post/PostInterface"; | ||
|
||
const PostDetail = ({ | ||
image, | ||
createdAt, | ||
userId, | ||
nickname, | ||
content, | ||
userImage, | ||
tags, | ||
id, | ||
}: PostInterface) => { | ||
return <>{userId}</>; | ||
}; | ||
export default PostDetail; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import createPostDetailPath from "@/utils/createPostDetailPath"; | ||
|
||
describe("createPostDetailPath 함수 테스트", () => { | ||
it("postId=1 userId=thisUser 가 입력되었을 때 ", () => { | ||
expect(createPostDetailPath("thisUser", "1")).toEqual("/@thisUser/1"); | ||
}); | ||
it("공백을 자동으로 Trim 하는지 여부", () => { | ||
expect(createPostDetailPath(" thisUser", "1 ")).toEqual("/@thisUser/1"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* 유저아이디와 게시글 아이디를 입력받아 /@userId/postId 형태의 String을 리턴 | ||
* @param userId 유저ID | ||
* @param postId 게시글ID | ||
* @returns | ||
*/ | ||
const createPostUrl = (userId: string, postId: string) => { | ||
const trimmedUserId = userId.trim(); | ||
const trimmedPostId = postId.trim(); | ||
|
||
return `/@${trimmedUserId}/${trimmedPostId}`; | ||
}; | ||
|
||
export default createPostUrl; |