From ee6ca2bc80c39cd2a805ee4da37900ebee40b945 Mon Sep 17 00:00:00 2001 From: junjeeong Date: Tue, 19 Nov 2024 17:46:54 +0900 Subject: [PATCH 1/5] =?UTF-8?q?Feat:=20SharePage=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/api/axiosInstanceApi.ts | 2 +- lib/api/link.ts | 5 ++- pages/share/[folderId].tsx | 61 +++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 pages/share/[folderId].tsx diff --git a/lib/api/axiosInstanceApi.ts b/lib/api/axiosInstanceApi.ts index 9c7b8b1..7992f9c 100644 --- a/lib/api/axiosInstanceApi.ts +++ b/lib/api/axiosInstanceApi.ts @@ -5,7 +5,7 @@ const axiosInstance = axios.create({ }); export const proxy = axios.create({ - baseURL: "https://linkbrary-9-99.vercel.app", + baseURL: "http://localhost:3000/", }); proxy.interceptors.response.use( diff --git a/lib/api/link.ts b/lib/api/link.ts index 5fb5f6a..32d9be5 100644 --- a/lib/api/link.ts +++ b/lib/api/link.ts @@ -14,7 +14,10 @@ interface putLinkFavoriteProps { } // 폴더에 속한 링크 조회 -export const getLink = async (query: any, forderId: number) => { +export const getLink = async ( + query: any, + forderId: string | string[] | undefined +) => { let queryString; query ? (queryString = `?page=${query.page}&pageSize=${query.pageSize}`) : ""; diff --git a/pages/share/[folderId].tsx b/pages/share/[folderId].tsx new file mode 100644 index 0000000..c465903 --- /dev/null +++ b/pages/share/[folderId].tsx @@ -0,0 +1,61 @@ +import { GetServerSidePropsContext } from "next"; +import { LinkData } from "@/types/linkTypes"; +import { getFolder } from "@/lib/api/folder"; +import { getLink } from "../../lib/api/link"; +import CardsLayout from "@/components/Layout/CardsLayout"; +import Container from "@/components/Layout/Container"; +import LinkCard from "@/components/Link/LinkCard"; +import Pagination from "@/components/Pagination"; + +interface SharePageprops { + folderName: string; + linkList: LinkData[]; + totalCount: number; +} + +export const getServerSideProps = async ( + context: GetServerSidePropsContext +) => { + const { page, pageSize } = context.query; + const { folderId } = context.params!; + const folderListData = await getLink( + { page: page, pageSize: pageSize }, + folderId + ); + const folderNameData = await getFolder(folderId); + + return { + props: { + folderName: folderNameData.data.name, + linkList: folderListData.data.list, + totalCount: folderListData.data.totalCount, + }, + }; +}; + +const SharePage = ({ folderName, linkList, totalCount }: SharePageprops) => { + return ( + <> +
+

+ {folderName} +

+
+ + {/* 로딩 중일 때 */} + {linkList.length > 0 && ( + <> + + {linkList.length > 0 + ? linkList.map((link) => ) + : null} + + + + )} + + + ); +}; + +export default SharePage; From 478dc342f4adc407d5386a935733a8545243a1c7 Mon Sep 17 00:00:00 2001 From: junjeeong Date: Tue, 19 Nov 2024 18:36:41 +0900 Subject: [PATCH 2/5] =?UTF-8?q?Feat:=20=EB=A7=81=ED=81=AC=20=EA=B3=B5?= =?UTF-8?q?=EC=9C=A0=20=ED=8E=98=EC=9D=B4=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Link/LinkCard.tsx | 6 +++--- lib/api/link.ts | 13 +++++++------ pages/share/[folderId].tsx | 9 +++++---- util/shareSNS.ts | 4 ++-- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/components/Link/LinkCard.tsx b/components/Link/LinkCard.tsx index e5d7cbd..48a148a 100644 --- a/components/Link/LinkCard.tsx +++ b/components/Link/LinkCard.tsx @@ -31,7 +31,7 @@ const LinkCard = ({ info }: LinkCardProps) => { const createdTime = timeAgo(info.createdAt); const router = useRouter(); - const isFavoritePage = router.pathname === "/favorite"; + const onlyLinkPage = router.pathname === "/link"; const dropdownRef = useRef(null); // 모달이 열릴 때 드롭다운 닫기 @@ -98,7 +98,7 @@ const LinkCard = ({ info }: LinkCardProps) => { fill /> {/* 즐겨찾기 페이지가 아닐 때에는 즐겨찾기 버튼 렌더링x */} - {!isFavoritePage && ( + {onlyLinkPage && (
{ {createdTime || "1일 전"} {/* isFavoritePage일 때만 케밥 버튼 렌더링 */} - {!isFavoritePage && ( + {onlyLinkPage && (
- {/* 로딩 중일 때 */} {linkList.length > 0 && ( <> diff --git a/util/shareSNS.ts b/util/shareSNS.ts index 4315a77..f08b1fb 100644 --- a/util/shareSNS.ts +++ b/util/shareSNS.ts @@ -14,8 +14,8 @@ export const handleShareKakao = () => { description: "나에게 필요한 링크만 모아 두었어요!", imageUrl: "https://linkbrary-9-99.vercel.app/images/home_main.png", //배포 후 실제 도메인으로 변경 필요 link: { - mobileWebUrl: location.href, - webUrl: location.href, + mobileWebUrl: location.href.replace("link?", "share?"), + webUrl: location.href.replace("link?", "share?"), }, }, }); From 3ea37be817c3de7d8684b01faecf0e140ad5f04b Mon Sep 17 00:00:00 2001 From: MunGyun <126762196+mungyun@users.noreply.github.com> Date: Tue, 19 Nov 2024 19:03:29 +0900 Subject: [PATCH 3/5] Update axiosInstanceApi.ts --- lib/api/axiosInstanceApi.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/axiosInstanceApi.ts b/lib/api/axiosInstanceApi.ts index 7992f9c..9c7b8b1 100644 --- a/lib/api/axiosInstanceApi.ts +++ b/lib/api/axiosInstanceApi.ts @@ -5,7 +5,7 @@ const axiosInstance = axios.create({ }); export const proxy = axios.create({ - baseURL: "http://localhost:3000/", + baseURL: "https://linkbrary-9-99.vercel.app", }); proxy.interceptors.response.use( From ee90b2af08b55de6cacc8194f64537a889873d0d Mon Sep 17 00:00:00 2001 From: MunGyun <126762196+mungyun@users.noreply.github.com> Date: Tue, 19 Nov 2024 19:06:47 +0900 Subject: [PATCH 4/5] Update [folderId].tsx --- pages/share/[folderId].tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/share/[folderId].tsx b/pages/share/[folderId].tsx index 6df75ee..dead112 100644 --- a/pages/share/[folderId].tsx +++ b/pages/share/[folderId].tsx @@ -17,7 +17,7 @@ export const getServerSideProps = async ( context: GetServerSidePropsContext ) => { const { page, pageSize } = context.query; - const { folderId } = context.params!; + const { folderId } = context.params; const folderListData = await getLink( { page: page, pageSize: pageSize }, From e8624b36527bec226f8c19f0ad3a88c8a852d07b Mon Sep 17 00:00:00 2001 From: MunGyun <126762196+mungyun@users.noreply.github.com> Date: Tue, 19 Nov 2024 19:08:28 +0900 Subject: [PATCH 5/5] Update [folderId].tsx --- pages/share/[folderId].tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/share/[folderId].tsx b/pages/share/[folderId].tsx index dead112..6df75ee 100644 --- a/pages/share/[folderId].tsx +++ b/pages/share/[folderId].tsx @@ -17,7 +17,7 @@ export const getServerSideProps = async ( context: GetServerSidePropsContext ) => { const { page, pageSize } = context.query; - const { folderId } = context.params; + const { folderId } = context.params!; const folderListData = await getLink( { page: page, pageSize: pageSize },