From f1871ea445ba9d2c67be9ac4234ffacedab8af0c Mon Sep 17 00:00:00 2001 From: leeyoul <2yulrang@gmail.com> Date: Tue, 23 Jul 2024 11:28:03 +0900 Subject: [PATCH] =?UTF-8?q?[=EC=9D=B4=EC=9C=A8]=20Sprint11=20(#733)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 회원가입 기능 구현 * feat: 로그인 기능 추가 * feat: user 정보 불러오기 * feat: 로그인시 헤더 바뀌는 기능 추가 * feat: 게시글 등록(제목, 내용, 이미지) 기능 추가 * feat: 자유게시판 글 좋아요 기능 추가 * feat: 댓글 달기 기능 추가 * Design: no-reply 이미지 추가 * refactor: 로그인 api 연동부분 수정 * feat: localstorage, context 활용 로그인 상태변경 * fix: 중고마켓 상품이미지 기본이미지 나오도록 수정 * feat: 30분마다 refresh하여 로그인 유지되는 기능 추가 --- .eslintrc.js | 1 - .prettierrc.js | 2 +- components/BoardList.tsx | 3 +- components/Header.tsx | 15 ++- components/Input/EmailInput.tsx | 8 +- components/Input/FileInput.tsx | 2 +- components/Input/PasswordInput.tsx | 9 +- components/Input/TextInput.tsx | 1 + components/ItemCard.tsx | 3 +- eslint.config.mjs | 7 +- next.config.js | 2 +- pages/_app.tsx | 5 +- pages/addboard.tsx | 63 ++++++------ pages/boards/[id].tsx | 70 ++++++++++--- pages/index.tsx | 14 ++- pages/items/[id].tsx | 3 +- pages/items/index.tsx | 2 + pages/join.tsx | 32 +++++- pages/signin.tsx | 52 +++++++--- src/api/api.tsx | 110 +++++++++++++++++++- src/contexts/AuthProvider.tsx | 159 +++++++++++++++++++++++++++++ src/img/Img_product_empty-sm.png | Bin 0 -> 8248 bytes src/img/Img_product_empty.png | Bin 0 -> 10043 bytes src/img/Img_reply_empty.png | Bin 0 -> 5994 bytes src/img/ic_heart_on.svg | 3 + src/styles/_form.scss | 2 +- src/styles/page/DetailPage.scss | 16 +++ 27 files changed, 494 insertions(+), 90 deletions(-) create mode 100644 src/contexts/AuthProvider.tsx create mode 100644 src/img/Img_product_empty-sm.png create mode 100644 src/img/Img_product_empty.png create mode 100644 src/img/Img_reply_empty.png create mode 100644 src/img/ic_heart_on.svg diff --git a/.eslintrc.js b/.eslintrc.js index 85e8fead3..ab167697f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -22,7 +22,6 @@ module.exports = { ], plugins: ["react", "react-hooks", "@typescript-eslint", "jsx-a11y", "import", "prettier"], rules: { - "prettier/prettier": "error", "react/react-in-jsx-scope": "off", // Next.js doesn't require React to be in scope // 'import/prefer-default-export': 'off', // '@typescript-eslint/explicit-module-boundary-types': 'off', diff --git a/.prettierrc.js b/.prettierrc.js index 8377e42ff..4422986e2 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1,4 +1,4 @@ module.exports = { - printWidth: 200, + printWidth: 100, tabWidth: 2, }; diff --git a/components/BoardList.tsx b/components/BoardList.tsx index 4e1df4ad0..edec272fa 100644 --- a/components/BoardList.tsx +++ b/components/BoardList.tsx @@ -7,6 +7,7 @@ import { Article } from "@/src/types/article"; import Link from "next/link"; import WriterInfo from "./WriterInfo"; import Styles from "./BoardList.module.scss"; +import ImgProductEmpty from "@/src/img/Img_product_empty-sm.png"; interface articleListProps { order: string; @@ -58,7 +59,7 @@ export function BoardList({ order = "", pageSize = 0, keyword = "", page = undef {article.image && (
- 이미지 + 이미지
)} diff --git a/components/Header.tsx b/components/Header.tsx index d7775316b..95f311b2a 100644 --- a/components/Header.tsx +++ b/components/Header.tsx @@ -1,8 +1,13 @@ import Link from "next/link"; import Logo from "./Logo"; import GNB from "./GNB"; +import { useAuth } from "@/src/contexts/AuthProvider"; +import Image from "next/image"; +import ImgUser from "@/src/img/ic_profile.svg"; export default function Header() { + const { user, isAuth } = useAuth(true); + return (
@@ -13,9 +18,13 @@ export default function Header() {
- - 로그인 - + {isAuth ? ( + 유저 이미지 + ) : ( + + 로그인 + + )}
diff --git a/components/Input/EmailInput.tsx b/components/Input/EmailInput.tsx index 9056337f5..a79a0b726 100644 --- a/components/Input/EmailInput.tsx +++ b/components/Input/EmailInput.tsx @@ -1,18 +1,19 @@ -import { ChangeEvent, useState } from "react"; +import { ChangeEvent, ChangeEventHandler, useState } from "react"; import Styles from "./Input.module.scss"; interface EmailInputProps { name: string; value: string; - onChange: () => void; + onChange: (e: ChangeEvent) => void; id: string; className: string; required: boolean; setIsInvalid: (value: boolean) => void; } -export default function EmailInput({ name, value, id, className, required, setIsInvalid }: EmailInputProps) { +export default function EmailInput({ name, value, id, className, required, setIsInvalid, onChange }: EmailInputProps) { const [isEmpty, setIsEmpty] = useState(false); + const handleChange = (e: ChangeEvent) => { if (e.target.checkValidity()) { setIsInvalid(false); @@ -24,6 +25,7 @@ export default function EmailInput({ name, value, id, className, required, setIs } else { setIsEmpty(false); } + onChange(e); }; return ( <> diff --git a/components/Input/FileInput.tsx b/components/Input/FileInput.tsx index f0d9c1e80..f6dfb7d60 100644 --- a/components/Input/FileInput.tsx +++ b/components/Input/FileInput.tsx @@ -49,7 +49,7 @@ export default function FileInput({ name, value, onChange }: FileInputProps) { {preview && (
- 이미지 미리보기 + 이미지 미리보기 diff --git a/components/Input/PasswordInput.tsx b/components/Input/PasswordInput.tsx index cf158d0a5..d33bacf9a 100644 --- a/components/Input/PasswordInput.tsx +++ b/components/Input/PasswordInput.tsx @@ -1,15 +1,18 @@ -import { ChangeEvent, useState } from "react"; +import { ChangeEvent, ChangeEventHandler, useState } from "react"; import Styles from "./Input.module.scss"; interface PasswordInputProps { id: string; + name: string; + value: string; className?: string; required?: boolean; inputRef: React.RefObject; setIsInvalid: (value: boolean) => void; + onChange: (e: ChangeEvent) => void; } -export default function PasswordInput({ id, className, required, inputRef, setIsInvalid }: PasswordInputProps) { +export default function PasswordInput({ id, name, value, className, required, inputRef, setIsInvalid, onChange }: PasswordInputProps) { const [isEmpty, setIsEmpty] = useState(false); const handleCheck = (e: ChangeEvent) => { @@ -34,7 +37,7 @@ export default function PasswordInput({ id, className, required, inputRef, setIs return ( <> - +