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', + }, }; 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/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)}
    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: '/',