From 3ce3309d8d4f45a6394f44655b41c53be7f1d679 Mon Sep 17 00:00:00 2001 From: gwansikk Date: Sun, 11 Feb 2024 16:50:10 +0900 Subject: [PATCH 1/3] chore: no-console rules --- .eslintrc.json | 3 ++- apps/member/.eslintrc.cjs | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index cffb67e7..27aa3e38 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -16,7 +16,8 @@ "rules": { "react/react-in-jsx-scope": "off", // React 17 이상에서는 필요 없음 "@typescript-eslint/explicit-module-boundary-types": "off", // 모든 함수의 반환 타입 명시를 강제하지 않음 - "react/prop-types": "off" // TypeScript를 사용할 경우 propTypes는 필요 없음 + "react/prop-types": "off", // TypeScript를 사용할 경우 propTypes는 필요 없음 + "no-console": "error" }, "env": { "browser": true, "es2020": true } } diff --git a/apps/member/.eslintrc.cjs b/apps/member/.eslintrc.cjs index ee8cdb22..18874a7d 100644 --- a/apps/member/.eslintrc.cjs +++ b/apps/member/.eslintrc.cjs @@ -4,7 +4,7 @@ module.exports = { extends: [ 'eslint:recommended', 'plugin:@typescript-eslint/recommended', - 'plugin:react-hooks/recommended' + 'plugin:react-hooks/recommended', ], ignorePatterns: ['dist', '.eslintrc.cjs'], parser: '@typescript-eslint/parser', @@ -12,7 +12,8 @@ module.exports = { rules: { 'react-refresh/only-export-components': [ 'warn', - { allowConstantExport: true } - ] - } + { allowConstantExport: true }, + ], + 'no-console': 'warn', + }, }; From 6cd5f4470589daa13057e105d4b7f3b167cd6525 Mon Sep 17 00:00:00 2001 From: gwansikk Date: Sun, 11 Feb 2024 16:54:47 +0900 Subject: [PATCH 2/3] refactor: Image Not found --- apps/member/src/components/common/Image/Image.tsx | 12 ++++++------ apps/member/src/constants/path.ts | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/member/src/components/common/Image/Image.tsx b/apps/member/src/components/common/Image/Image.tsx index de793944..1f3366e9 100644 --- a/apps/member/src/components/common/Image/Image.tsx +++ b/apps/member/src/components/common/Image/Image.tsx @@ -1,5 +1,6 @@ +import { SyntheticEvent, useState } from 'react'; import classNames from 'classnames'; -import { useState } from 'react'; +import { NOT_FOUND_IMG } from '@constants/path'; interface ImageProps { src?: string; @@ -12,7 +13,7 @@ interface ImageProps { } const Image = ({ - src, + src = NOT_FOUND_IMG, alt, width, height, @@ -20,15 +21,14 @@ const Image = ({ onClick, overflow, }: ImageProps) => { - const [imgSrc, setImgSrc] = useState(src); const [loading, setLoading] = useState(true); const [error, setError] = useState(false); const _width = width ? width : 'w-full'; const _height = height ? height : 'h-full'; - const handleError = () => { - setImgSrc('/not_found.webp'); + const handleError = (e: SyntheticEvent) => { + e.currentTarget.src = NOT_FOUND_IMG; setError(true); setLoading(false); }; @@ -45,7 +45,7 @@ const Image = ({ 'bg-gray-50': error, 'cursor-pointer': onClick, })} - src={imgSrc} + src={src} alt={alt} onClick={onClick} onLoad={() => setLoading(false)} diff --git a/apps/member/src/constants/path.ts b/apps/member/src/constants/path.ts index 9246aaaf..3f58b956 100644 --- a/apps/member/src/constants/path.ts +++ b/apps/member/src/constants/path.ts @@ -11,6 +11,8 @@ export const createPath = (...paths: Array): string => { .join('/'); }; +export const NOT_FOUND_IMG = '/not_found.webp'; + export const PATH = { ROOT: '', MAIN: '/', From bc804bcd5f096cc5288b30c180fbf53a01bbaaf8 Mon Sep 17 00:00:00 2001 From: gwansikk Date: Sun, 11 Feb 2024 16:55:48 +0900 Subject: [PATCH 3/3] =?UTF-8?q?refactor:=20BookPanel=20Text=20overflow=20?= =?UTF-8?q?=EB=8F=84=EC=84=9C=20=ED=8C=A8=EB=84=90=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EB=94=94=EB=8D=B0=EC=9D=B4=20=ED=91=9C=EC=8B=9C=EA=B0=80=20?= =?UTF-8?q?=EC=98=A4=EB=B2=84=ED=94=8C=EB=A1=9C=EC=9A=B0=EA=B0=80=20?= =?UTF-8?q?=EB=90=98=EC=96=B4=20=EC=88=98=EC=A0=95=ED=96=88=EC=8A=B5?= =?UTF-8?q?=EB=8B=88=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/panels/BookPanel/BookPanel.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/apps/member/src/components/panels/BookPanel/BookPanel.tsx b/apps/member/src/components/panels/BookPanel/BookPanel.tsx index a40a2bc0..23167e83 100644 --- a/apps/member/src/components/panels/BookPanel/BookPanel.tsx +++ b/apps/member/src/components/panels/BookPanel/BookPanel.tsx @@ -1,8 +1,8 @@ import Panel from '@components/common/Panel/Panel'; import ProgressBar from '@components/common/ProgressBar/ProgressBar'; import { BookItem } from '@type/book'; -import dayjs from 'dayjs'; import { FcBookmark } from 'react-icons/fc'; +import dayjs from 'dayjs'; interface BookPanelProps { data: Array; @@ -17,15 +17,13 @@ const ActionButton = ({ children }: { children: React.ReactNode }) => ( const checkProgress = (createdAt: string) => { const now = dayjs(); const end = dayjs(createdAt).add(14, 'd'); - const value = (end.diff(now, 'd') * 100) % 14; - console.log(value); - return value; + return (end.diff(now, 'd') * 100) % 14; }; + const checkDueDate = (createdAt: string) => { const today = dayjs(); const end = dayjs(createdAt).add(14, 'd'); - const value = end.diff(today, 'd'); - return value; + return end.diff(today, 'd'); }; const BookPanel = ({ data }: BookPanelProps) => { @@ -44,7 +42,7 @@ const BookPanel = ({ data }: BookPanelProps) => {
  • {title} - + D-{checkDueDate(createdAt)}