From 016f847ccb5b1a6b5d9a810435be15a7fca1c56c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EB=AF=B8?= Date: Wed, 12 Jun 2024 15:46:09 +0900 Subject: [PATCH 01/23] =?UTF-8?q?=F0=9F=93=A6=20chore:=20env=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20gitignore=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8f322f0d8..45c1abce8 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ yarn-error.log* # local env files .env*.local +.env # vercel .vercel From bbb8b6d54c0361d3bc514eba732d12096093eafb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EB=AF=B8?= Date: Wed, 12 Jun 2024 15:47:24 +0900 Subject: [PATCH 02/23] =?UTF-8?q?=F0=9F=93=A6=20chore:=20env=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20git=EC=97=90=EC=84=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 381905d00..000000000 --- a/.env +++ /dev/null @@ -1 +0,0 @@ -NEXT_PUBLIC_BASE_URL=https://panda-market-api.vercel.app From aa7c6a7dcd76aadf4bae29601cf6240ef927a7d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EB=AF=B8?= Date: Wed, 12 Jun 2024 16:00:54 +0900 Subject: [PATCH 03/23] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20axios=20?= =?UTF-8?q?URLSearchParams=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/api.ts | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/api/api.ts b/api/api.ts index 452e79071..5339c7044 100644 --- a/api/api.ts +++ b/api/api.ts @@ -3,9 +3,12 @@ import instance from "@/lib/axios"; // 페이지네이션을 위한 전체 게시글 수 export async function getTotalPosts() { try { - const { data } = await instance.get( - "/articles?&pageSize=10000&orderBy=recent", - ); + const params = new URLSearchParams({ + pageSize: "10000", + orderBy: "recent", + }); + + const { data } = await instance.get("/articles?", { params }); return data.list.length; } catch (error) { console.error("getTotalPosts 함수에서 오류 발생:", error); @@ -36,9 +39,11 @@ export async function getPosts({ export async function getBestPosts({ pageSize = 3 }) { try { - const { data } = await instance.get( - `/articles?&pageSize=${pageSize}&orderBy=like`, - ); + const params = new URLSearchParams({ orderBy: "like" }); + + const { data } = await instance.get(`/articles?&pageSize=${pageSize}`, { + params, + }); return data.list; } catch (error) { console.error("getBestPosts 함수에서 오류 발생:", error); @@ -58,9 +63,10 @@ export async function getPostsDetail(articleId: string) { export async function getPostsComments(articleId: string) { try { - const { data } = await instance.get( - `/articles/${articleId}/comments?limit=100`, - ); + const params = new URLSearchParams({ limit: "100" }); + const { data } = await instance.get(`/articles/${articleId}/comments?`, { + params, + }); return data.list; } catch (error) { console.error("getPostsComments 함수에서 오류 발생:", error); From c4a9dfc2f2abb7ff4406f611eb8d50b3d6eca7f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EB=AF=B8?= Date: Wed, 12 Jun 2024 16:02:02 +0900 Subject: [PATCH 04/23] =?UTF-8?q?=F0=9F=94=A5=20remove:=20=EC=9E=A5?= =?UTF-8?q?=EC=8B=9D=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EB=B9=88=20alt=20?= =?UTF-8?q?=EB=A1=9C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/BestPosts.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BestPosts.tsx b/components/BestPosts.tsx index 5f3aaf526..8a2f7b873 100644 --- a/components/BestPosts.tsx +++ b/components/BestPosts.tsx @@ -108,7 +108,7 @@ export default function BestPosts({ initialBestPosts }: BestPostsProps) { key={post.id} >
- 메달 +

Best

From 358bb042cc5f5b757514ddef3f7cfe14a37f922a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EB=AF=B8?= Date: Wed, 12 Jun 2024 17:35:40 +0900 Subject: [PATCH 05/23] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20?= =?UTF-8?q?=ED=85=8C=EC=9D=BC=EC=9C=88=EB=93=9C=20=EA=B3=B5=ED=86=B5=20?= =?UTF-8?q?=EB=B3=80=EC=88=98=20=EC=9E=AC=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/BestPosts.tsx | 14 +++++----- components/FileInput.tsx | 4 +-- components/Footer.tsx | 4 +-- components/Header.tsx | 19 ++++++------- components/Pagination.tsx | 6 ++--- components/Posts.tsx | 26 +++++++++--------- pages/addBoards.tsx | 20 +++++++------- pages/boards.tsx | 4 +-- pages/boards/[id].tsx | 26 +++++++++--------- pages/index.tsx | 56 +++++++++++++++++---------------------- pages/signin.tsx | 22 +++++++-------- pages/signup.tsx | 36 ++++++++++++------------- styles/globals.css | 29 -------------------- tailwind.config.js | 41 +++++++++++++++++++++++----- 14 files changed, 145 insertions(+), 162 deletions(-) diff --git a/components/BestPosts.tsx b/components/BestPosts.tsx index 8a2f7b873..094a29c31 100644 --- a/components/BestPosts.tsx +++ b/components/BestPosts.tsx @@ -104,17 +104,17 @@ export default function BestPosts({ initialBestPosts }: BestPostsProps) { bestPosts.map((post) => ( -
+

Best

{post.title}

{post.image && ( -
+
포스트 이미지
-

+

{post.writer.nickname}

하트 -

- {post.likeCount} -

+

{post.likeCount}

-

+

{formatDate(post.createdAt)}

diff --git a/components/FileInput.tsx b/components/FileInput.tsx index f2e8b3017..f4247162d 100644 --- a/components/FileInput.tsx +++ b/components/FileInput.tsx @@ -51,7 +51,7 @@ function FileInput({ name, value, initialPreview, onChange }: FileInputProps) { }, [value, initialPreview]); return ( -
+
{preview ? ( {value && (
@@ -98,7 +95,7 @@ export default function Header() { diff --git a/components/Pagination.tsx b/components/Pagination.tsx index 2123ff7ab..31a73f403 100644 --- a/components/Pagination.tsx +++ b/components/Pagination.tsx @@ -24,8 +24,6 @@ export default function Pagination({ for (let i = 1; i <= totalPages; i++) { pages.push(i); } - // console.log(pages); - // console.log(currentPage, totalPages); return (
@@ -41,8 +39,8 @@ export default function Pagination({
onPageChange(i)} > {i} diff --git a/components/Posts.tsx b/components/Posts.tsx index 6fe3b5120..7762e3646 100644 --- a/components/Posts.tsx +++ b/components/Posts.tsx @@ -108,14 +108,14 @@ export default function Posts({ initialPosts }: PostsProps) { 검색 아이콘
@@ -130,12 +130,12 @@ export default function Posts({ initialPosts }: PostsProps) { 드롭다운 {isDropdownView && ( -
    +
      {selectOptions.map((option) => (
    • selectOption(option.value)} - className="cursor-pointer border-b-[var(--gray100)] p-2 text-center hover:bg-[var(--gray100)]" + className="cursor-pointer border-b border-gray-200 p-2 text-center hover:bg-gray-200" > {option.label}
    • @@ -149,14 +149,14 @@ export default function Posts({ initialPosts }: PostsProps) { posts.map((post) => { return (
      -
      +

      {post.title}

      {post.image && ( -
      +
      포스트 이미지
      -
      +
      프로필 이미지 -

      +

      {post.writer.nickname}

      -

      +

      {formatDate(post.createdAt)}

      -
      +
      하트 -

      - {post.likeCount} -

      +

      {post.likeCount}

      diff --git a/pages/addBoards.tsx b/pages/addBoards.tsx index ffed836d5..a983d5f65 100644 --- a/pages/addBoards.tsx +++ b/pages/addBoards.tsx @@ -1,4 +1,4 @@ -import React, { KeyboardEvent, useState } from "react"; +import React, { useState } from "react"; import FileInput from "../components/FileInput"; import { useRouter } from "next/router"; import instance from "@/lib/axios"; @@ -20,11 +20,12 @@ type PostData = { image?: string; }; -function AddItem({ +function AddBoards({ initialValues = INITIAL_VALUES, initialPreview, }: AddPostProps) { const [values, setValues] = useState(initialValues); + const router = useRouter(); const isDisabled = !values.title || !values.content; @@ -34,6 +35,7 @@ function AddItem({ [name]: value, })); }; + const handleInputChange = ( e: React.ChangeEvent, ) => { @@ -41,9 +43,7 @@ function AddItem({ handleChange(name, value); }; - const router = useRouter(); - - const handleformSubmit = async () => { + const handleFormSubmit = async () => { const token = localStorage.getItem("accessToken"); try { @@ -63,13 +63,11 @@ function AddItem({ imageUrl = imageResponse.data.url; } - // 이미지가 없을 때도 요청을 보낼 수 있게 const postData: PostData = { title: values.title, content: values.content, }; - // 이미지 URL이 존재할 경우에만 이미지 데이터 추가 if (imageUrl) { postData.image = imageUrl; } @@ -89,7 +87,7 @@ function AddItem({ const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); - handleformSubmit(); + await handleFormSubmit(); alert("게시글 등록이 완료되었습니다!"); router.push("/boards"); setValues(INITIAL_VALUES); @@ -115,7 +113,7 @@ function AddItem({ value={values.title} placeholder="제목을 입력해주세요" onChange={handleInputChange} - className="my-4 mt-2 w-full rounded-md border-none bg-[--coolgray100] px-3 py-2 text-sm focus:outline-[--main]" + className="focus:outline-main my-4 mt-2 w-full rounded-md border-none bg-gray-50 px-3 py-2 text-sm" />

      *내용