From 2ea2e70a0cbaf3c295c4a409b9687572defbf92d Mon Sep 17 00:00:00 2001 From: BearHumanS Date: Tue, 9 Jan 2024 08:55:47 +0900 Subject: [PATCH 01/13] =?UTF-8?q?Feat:=20ci/cd=20workflow=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd.yml | 21 +++++++++++++++++++++ .github/workflows/ci.yml | 27 +++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 .github/workflows/cd.yml create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..124d344 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,21 @@ +name: CD +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} +on: + push: + branches: + - main +jobs: + Deploy-Production: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Vercel CLI + run: npm install --global vercel@latest + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} + - name: Build Project Artifacts + run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} + - name: Deploy Project Artifacts to Vercel + run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..5f7cf1f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,27 @@ +name: CI + +on: [pull_request] + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v2 + with: + node-version: '18' + - run: yarn install + - run: yarn lint + build: + name: Build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v2 + with: + node-version: '18' + - run: yarn install + - run: CI='false' yarn build From ddad21812c8ca418769af24fcf3134b0cce54d66 Mon Sep 17 00:00:00 2001 From: BearHumanS Date: Tue, 9 Jan 2024 09:05:40 +0900 Subject: [PATCH 02/13] =?UTF-8?q?Doc:=20gitignore=20=EB=AA=A9=EB=A1=9D=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 50c8dda..0deb676 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ dist-ssr *.sw? .env + +.vercel From 30aadf8321dff62eee3ecce9c64a6429ff836647 Mon Sep 17 00:00:00 2001 From: BearHumanS Date: Tue, 9 Jan 2024 09:13:01 +0900 Subject: [PATCH 03/13] =?UTF-8?q?Docs:=20=EC=9D=BC=EB=B6=80=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 8 ++++---- package.json | 3 ++- src/hook/useCommunityDataList.tsx | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5f7cf1f..ddb3ae4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,8 @@ jobs: - uses: actions/setup-node@v2 with: node-version: '18' - - run: yarn install - - run: yarn lint + - run: npm install + - run: npm run lint build: name: Build runs-on: ubuntu-latest @@ -23,5 +23,5 @@ jobs: - uses: actions/setup-node@v2 with: node-version: '18' - - run: yarn install - - run: CI='false' yarn build + - run: npm install + - run: CI='false' npm run build diff --git a/package.json b/package.json index 4689a89..ac67256 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "scripts": { "dev": "vite", "build": "tsc && vite build", - "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\"", + "lint:fix": "eslint --fix \"src/**/*.{js,jsx,ts,tsx}\"", "preview": "vite preview" }, "dependencies": { diff --git a/src/hook/useCommunityDataList.tsx b/src/hook/useCommunityDataList.tsx index ef08666..ed98f45 100644 --- a/src/hook/useCommunityDataList.tsx +++ b/src/hook/useCommunityDataList.tsx @@ -28,6 +28,7 @@ const useCommunityDataList = (val: string) => { }; fetchData(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); // 빈 배열을 전달하여 컴포넌트가 마운트될 때 한 번만 실행되도록 함 return { dataList, commentsList, repliesList, setDataList }; From 6e152df9d9a7537d57660e77ab2afbeab2b739e0 Mon Sep 17 00:00:00 2001 From: BearHumanS Date: Fri, 12 Jan 2024 16:37:35 +0900 Subject: [PATCH 04/13] =?UTF-8?q?Feat:=20Inner=20style=20props=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20(=EC=9D=B8=EB=9D=BC=EC=9D=B8=20=EC=8A=A4=ED=83=80?= =?UTF-8?q?=EC=9D=BC=20=EC=A0=81=EC=9A=A9=ED=95=98=EA=B8=B0=20=EC=9C=84?= =?UTF-8?q?=ED=95=B4=EC=84=9C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Inner.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/Inner.tsx b/src/components/Inner.tsx index 8f76588..ebe04da 100644 --- a/src/components/Inner.tsx +++ b/src/components/Inner.tsx @@ -1,12 +1,17 @@ -import { ReactNode } from 'react'; +import { CSSProperties, ReactNode } from 'react'; import styles from './Inner.module.scss'; interface InnerProp { children: ReactNode; + style?: CSSProperties; } -const Inner = ({ children }: InnerProp) => { - return
{children}
; +const Inner = ({ children, style }: InnerProp) => { + return ( +
+ {children} +
+ ); }; export default Inner; From dcb8b7696bc9a6ff7efca47271d205a1178d600a Mon Sep 17 00:00:00 2001 From: BearHumanS Date: Fri, 12 Jan 2024 16:37:53 +0900 Subject: [PATCH 05/13] =?UTF-8?q?Feat:=20=EC=A2=8B=EC=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EA=B2=8C=EC=8B=9C=EB=AC=BC=20=EC=BB=B4=ED=8F=AC?= =?UTF-8?q?=EB=84=8C=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/mypage/MyActive.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/mypage/MyActive.tsx b/src/components/mypage/MyActive.tsx index 232b837..09717e5 100644 --- a/src/components/mypage/MyActive.tsx +++ b/src/components/mypage/MyActive.tsx @@ -1,3 +1,4 @@ +import LikedPosts from './LikedPosts'; import MyLikedPokemon from './MyLikedPokemon'; import MyPosts from './MyPosts'; import styles from './Mypage.module.scss'; @@ -9,7 +10,9 @@ const MyActive = () => {
-
+
+ +
From 3b7884e60a9cdbc7a8d1671e62e52d49f4814e28 Mon Sep 17 00:00:00 2001 From: BearHumanS Date: Fri, 12 Jan 2024 16:38:15 +0900 Subject: [PATCH 06/13] =?UTF-8?q?Design:=20=EC=BB=B4=ED=8F=AC=EB=84=8C?= =?UTF-8?q?=ED=8A=B8=20=EC=B6=94=EA=B0=80=EC=97=90=20=EB=94=B0=EB=A5=B8=20?= =?UTF-8?q?=EC=9D=BC=EB=B6=80=20=EC=8A=A4=ED=83=80=EC=9D=BC=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/mypage/Mypage.module.scss | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/mypage/Mypage.module.scss b/src/components/mypage/Mypage.module.scss index fa5a55e..c6f9f07 100644 --- a/src/components/mypage/Mypage.module.scss +++ b/src/components/mypage/Mypage.module.scss @@ -293,7 +293,7 @@ span { color: #000; font-family: Gmarket Sans; - font-size: 28px; + font-size: 24px; font-style: normal; font-weight: 600; line-height: normal; @@ -306,6 +306,7 @@ display: flex; flex-direction: column; align-items: center; + cursor: pointer; &__none { display: flex; @@ -316,6 +317,7 @@ &__item { width: 549px; + height: 52px; display: flex; align-items: center; justify-content: space-between; From fb06a1379a690b42187408cb66639c4322da79ca Mon Sep 17 00:00:00 2001 From: BearHumanS Date: Fri, 12 Jan 2024 16:38:29 +0900 Subject: [PATCH 07/13] =?UTF-8?q?Feat:=20button=20=EA=B8=B0=EB=B3=B8=20?= =?UTF-8?q?=EC=86=8D=EC=84=B1=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/styles/global.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/styles/global.scss b/src/styles/global.scss index 74dadeb..1123953 100644 --- a/src/styles/global.scss +++ b/src/styles/global.scss @@ -145,4 +145,6 @@ body { button { cursor: pointer; + border: none; + background-color: inherit; } From e68622801d6391190fb1cf110c3572c61883b9d5 Mon Sep 17 00:00:00 2001 From: BearHumanS Date: Fri, 12 Jan 2024 16:38:57 +0900 Subject: [PATCH 08/13] =?UTF-8?q?Feat:=20=EB=A7=88=EC=9D=B4=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=ED=95=98=EB=8B=A8=20=EB=A0=88=EC=9D=B4?= =?UTF-8?q?=EC=95=84=EC=9B=83=20=EC=9D=B8=EB=9D=BC=EC=9D=B8=20=EC=8A=A4?= =?UTF-8?q?=ED=83=80=EC=9D=BC=EB=A1=9C=20margin-bottom=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/mypage/myPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/mypage/myPage.tsx b/src/pages/mypage/myPage.tsx index 6045f27..3e097d8 100644 --- a/src/pages/mypage/myPage.tsx +++ b/src/pages/mypage/myPage.tsx @@ -6,7 +6,7 @@ import Mycard from '@/components/mypage/Mycard'; const myPage = () => { return ( <> - + From a3d5dce1282f18d6da031f6dfe10719b61d415f0 Mon Sep 17 00:00:00 2001 From: BearHumanS Date: Fri, 12 Jan 2024 16:39:49 +0900 Subject: [PATCH 09/13] =?UTF-8?q?Feat:=20=ED=95=B4=EB=8B=B9=20=EA=B2=8C?= =?UTF-8?q?=EC=8B=9C=EB=AC=BC=EB=A1=9C=20=EC=9D=B4=EB=8F=99=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/mypage/RenderPost.tsx | 41 ++++++++++++++++------------ 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/src/components/mypage/RenderPost.tsx b/src/components/mypage/RenderPost.tsx index 83f0097..60019d0 100644 --- a/src/components/mypage/RenderPost.tsx +++ b/src/components/mypage/RenderPost.tsx @@ -1,4 +1,4 @@ -import { memo } from 'react'; +import { MouseEvent, memo } from 'react'; import { PostData, Posts } from './MyPosts'; import styles from './Mypage.module.scss'; @@ -6,24 +6,31 @@ interface RenderPostProps { post: Posts; onDelete: (postId: string) => void; onEdit: (data: PostData, id: string) => void; + onMovetoDocument: (postId: string) => void; } -const RenderPost = memo(({ post, onDelete, onEdit }: RenderPostProps) => { - return ( -
- {post.data.title} -
- - +const RenderPost = memo( + ({ post, onDelete, onEdit, onMovetoDocument }: RenderPostProps) => { + return ( +
onMovetoDocument(post.id)} + > + {post.data.title} +
+ + +
-
- ); -}); + ); + }, +); export default RenderPost; From 0beb4a7056844b244f92c69455a8d864b10d22d8 Mon Sep 17 00:00:00 2001 From: BearHumanS Date: Fri, 12 Jan 2024 16:40:25 +0900 Subject: [PATCH 10/13] =?UTF-8?q?Feat:=20=EC=B0=9C=ED=95=98=EA=B8=B0=20?= =?UTF-8?q?=EA=B2=8C=EC=8B=9C=EB=AC=BC=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EC=8B=9C=EA=B0=81=ED=99=94=20=EC=BB=B4=ED=8F=AC=EB=84=8C?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/mypage/RenderLikedPosts.tsx | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/components/mypage/RenderLikedPosts.tsx diff --git a/src/components/mypage/RenderLikedPosts.tsx b/src/components/mypage/RenderLikedPosts.tsx new file mode 100644 index 0000000..00a0efa --- /dev/null +++ b/src/components/mypage/RenderLikedPosts.tsx @@ -0,0 +1,36 @@ +import { MouseEvent, memo } from 'react'; + +import styles from './Mypage.module.scss'; +import { Liked } from './LikedPosts'; +import { IoIosHeart } from '@react-icons/all-files/io/IoIosHeart'; + +interface RenderLikedPostsProps { + like: Liked; + onCancleLikedPost: (likeId: string) => void; + onMoveToDocument: (likeId: string) => void; +} + +const RenderLikedPosts = memo( + ({ like, onCancleLikedPost, onMoveToDocument }: RenderLikedPostsProps) => { + return ( +
onMoveToDocument(like.id)} + > + {like.data.title} +
+ +
+
+ ); + }, +); + +export default RenderLikedPosts; From cad73da73a2795c54abf53ee4348b51555604aaa Mon Sep 17 00:00:00 2001 From: BearHumanS Date: Fri, 12 Jan 2024 16:41:08 +0900 Subject: [PATCH 11/13] =?UTF-8?q?Feat:=20=EB=82=B4=EA=B0=80=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=ED=95=9C=20=EA=B2=8C=EC=8B=9C=EB=AC=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/mypage/MyPosts.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/mypage/MyPosts.tsx b/src/components/mypage/MyPosts.tsx index 038193c..0cabb9a 100644 --- a/src/components/mypage/MyPosts.tsx +++ b/src/components/mypage/MyPosts.tsx @@ -76,12 +76,18 @@ const MyPosts = () => { console.error(error); } } + + return; }; const handlePageChange = (pageNumber: number) => { setCurrentPage(pageNumber); }; + const onMovetoDocument = (postId: string) => { + navigate(`/community/detail/${postId}`); + }; + return (
@@ -102,6 +108,7 @@ const MyPosts = () => { post={post} onEdit={onEdit} onDelete={onDelete} + onMovetoDocument={onMovetoDocument} /> ))}
From 6b8f9da731fa96147d602eba88129399e59bbdea Mon Sep 17 00:00:00 2001 From: BearHumanS Date: Fri, 12 Jan 2024 16:41:36 +0900 Subject: [PATCH 12/13] =?UTF-8?q?Feat:=20=EC=B0=9C=ED=95=98=EA=B8=B0=20?= =?UTF-8?q?=EA=B2=8C=EC=8B=9C=EB=AC=BC=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EC=8B=9C=EA=B0=81=ED=99=94=20=EB=B0=8F=20=EB=A0=88=EC=9D=B4?= =?UTF-8?q?=EC=95=84=EC=9B=83=20=EC=9E=91=EC=97=85,=20=EC=B0=9C=ED=95=98?= =?UTF-8?q?=EA=B8=B0=20=EC=B7=A8=EC=86=8C=20=EA=B8=B0=EB=8A=A5=20=EB=B0=8F?= =?UTF-8?q?=20=ED=95=B4=EB=8B=B9=20=EA=B2=8C=EC=8B=9C=EB=AC=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99=20=EA=B8=B0=EB=8A=A5=20=EB=93=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/mypage/LikedPosts.tsx | 113 +++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 src/components/mypage/LikedPosts.tsx diff --git a/src/components/mypage/LikedPosts.tsx b/src/components/mypage/LikedPosts.tsx new file mode 100644 index 0000000..b1ed6aa --- /dev/null +++ b/src/components/mypage/LikedPosts.tsx @@ -0,0 +1,113 @@ +import { deleteDocument, getAllDocument } from '@/lib/firebaseQuery'; +import useUserStore from '@/store/useUsersStore'; +import { useEffect, useState } from 'react'; +import { useNavigate } from 'react-router-dom'; +import RenderLikedPosts from './RenderLikedPosts'; +import styles from './Mypage.module.scss'; +import { Pagination } from 'antd'; +import { DocumentData } from 'firebase/firestore'; + +export interface Liked { + id: string; + data: DocumentData; +} + +const MyPosts = () => { + const itemsPerPage = 4; + const [likes, setLikes] = useState([]); + const [currentPage, setCurrentPage] = useState(1); + const navigate = useNavigate(); + + const { user } = useUserStore(); + + const indexOfLastItem = currentPage * itemsPerPage; + const indexOfFirstItem = indexOfLastItem - itemsPerPage; + const currentItems = likes.slice(indexOfFirstItem, indexOfLastItem); + + useEffect(() => { + const fetchData = async () => { + if (!user) return; + + try { + const docSnap = await getAllDocument(`/heart/${user.uid}/like`); + + setLikes(docSnap); + } catch (error) { + console.error('데이터를 가져오는 중 오류 발생:', error); + } + }; + + fetchData(); + }, [user]); + + const handlePageChange = (pageNumber: number) => { + setCurrentPage(pageNumber); + }; + + const onCancleLikedPost = async (likeId: string) => { + const confirm = window.confirm('해당 게시물의 좋아요를 취소하시겠습니까?'); + + if (confirm && user) { + try { + await deleteDocument(`/heart/${user.uid}/like/${likeId}`); + + setLikes((prev) => prev.filter((like) => like.id !== likeId)); + + const newTotal = likes.length - 1; + const maxPage = Math.ceil(newTotal / itemsPerPage); + if (currentPage > maxPage) { + setCurrentPage(maxPage > 0 ? maxPage : 1); + } + console.log('글이 삭제 되었습니다.'); + } catch (error) { + console.log(error); + } + } + + return; + }; + + const onMoveToDocument = (likeId: string) => { + navigate(`/community/detail/${likeId}`); + }; + + return ( +
+
+ 좋아요한 게시물 +
+ {likes.length === 0 ? ( + <> +
+ 좋아요한 게시물이 없습니다. +
+ + ) : ( + <> +
+ {currentItems.map((like) => ( + + ))} +
+ + )} + +
+ +
+
+ ); +}; + +export default MyPosts; From 487f86d27296f18e2b9e32cd2f3bc18ee8f83429 Mon Sep 17 00:00:00 2001 From: BearHumanS Date: Fri, 12 Jan 2024 17:41:02 +0900 Subject: [PATCH 13/13] =?UTF-8?q?Fix:=20button=20=EB=AA=A8=EB=93=88=20?= =?UTF-8?q?=EB=8C=80=EB=AC=B8=EC=9E=90=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/button/Button.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/button/Button.tsx b/src/components/button/Button.tsx index 23f7582..08b3ec7 100644 --- a/src/components/button/Button.tsx +++ b/src/components/button/Button.tsx @@ -1,4 +1,4 @@ -import styles from './button.module.scss'; +import styles from './Button.module.scss'; interface Props { data: string;