Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/assets/img/404-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions src/app/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use client';

import Button from '@/components/Button';

export default function errorPage() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

컴포넌트 함수명 규칙 준수 필요

React 컴포넌트 함수는 Pascal case를 사용해야 합니다.

-export default function errorPage() {
+export default function ErrorPage() {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export default function errorPage() {
-export default function errorPage() {
+export default function ErrorPage() {
🤖 Prompt for AI Agents
In src/app/error.tsx at line 5, the React component function name 'errorPage'
does not follow the PascalCase naming convention. Rename the function to
'ErrorPage' to comply with React component naming standards.

return (
<main
className="relative flex h-screen w-screen items-center justify-center px-10 md:justify-end bg-none md:bg-[url('/assets/img/404-image.png')] bg-no-repeat bg-cover md:bg-center"
>
<div className="relative z-10 w-full max-w-1200 mx-auto px-6 md:px-12 flex justify-center md:justify-end">
<div className="flex flex-col items-center md:items-start gap-8 md:gap-20 text-center md:text-left max-w-xl">
<h1 className="text-5xl md:text-8xl font-extrabold text-nomad">OPPS!</h1>
<p className="text-base md:text-xl text-nomad mb-6 leading-relaxed">
서비스 이용에 불편을 드려 죄송합니다.<br />
잠시 후 다시 시도해 주세요.
</p>
<Button
className="w-full max-w-200 px-30 py-16 rounded-[10px] shadow-lg hover:opacity-80 transition-colors duration-300 bg-nomad text-white text-base"
variant="primary"
onClick={() => (window.location.href = '/')}
>
홈으로 돌아가기
</Button>
Comment on lines +17 to +23
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

라우팅 방식 개선 및 스타일 중복 제거 필요

  1. window.location.href 대신 Next.js의 라우터 사용을 권장합니다.
  2. Button 컴포넌트의 variant와 className에 중복된 스타일이 있습니다.
+'use client';
+
+import { useRouter } from 'next/navigation';
 import Button from '@/components/Button';

 export default function ErrorPage() {
+  const router = useRouter();
+
   return (
     // ... other code
           <Button
-            className="w-full max-w-200 px-30 py-16 rounded-[10px] shadow-lg hover:opacity-80 transition-colors duration-300 bg-nomad text-white text-base"
+            className="w-full max-w-200 px-30 py-16 rounded-[10px] shadow-lg hover:opacity-80 transition-opacity duration-300"
             variant="primary"
-            onClick={() => (window.location.href = '/')}
+            onClick={() => router.push('/')}
           >
             홈으로 돌아가기
           </Button>
🤖 Prompt for AI Agents
In src/app/error.tsx around lines 17 to 23, replace the use of
window.location.href with Next.js router's navigation method to handle routing
properly. Import and use the useRouter hook from 'next/router' and call
router.push('/') inside the onClick handler. Additionally, review the Button
component's variant and className props to remove overlapping styles by
consolidating styles either in the variant or className to avoid duplication.

</div>
</div>
</main>
);
}
25 changes: 13 additions & 12 deletions src/app/not-found.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@ import Button from '@/components/Button';

export default function NotFoundPage() {
return (
<div className='fixed inset-0 z-[9999] flex h-screen w-screen flex-col items-center justify-center overflow-hidden bg-gray-300 text-center'>
<div className='z-10 w-full max-w-xl items-center justify-center space-y-6'>
<div className='mb-2 flex w-full items-center justify-center'></div>
<div className='space-y-6'>
<h1 className='text-primary-100 text-3xl font-bold'>
존재하지 않는 페이지입니다
</h1>
</div>
<div className='mt-12 flex w-full items-center justify-center'>
<main
className="relative flex h-screen w-screen items-center justify-center px-10 md:justify-end bg-none md:bg-[url('/assets/img/404-image.png')] bg-no-repeat bg-cover md:bg-center"
>
<div className="relative z-10 w-full max-w-1200 mx-auto px-6 md:px-12 flex justify-center md:justify-end">
<div className="flex flex-col items-center md:items-start gap-8 md:gap-20 text-center md:text-left max-w-xl">
<h1 className="text-5xl md:text-8xl font-extrabold text-nomad">404 ERROR</h1>
<p className="text-base md:text-xl text-nomad mb-6 leading-relaxed">
존재하지 않는 주소를 입력하셨거나,<br />
요청하신 페이지의 주소가 변경 또는 삭제되었을 수 있습니다.
</p>
<Button
className='cursor-pointer rounded-lg border border-gray-300 bg-gray-700 py-4 text-xl font-bold text-gray-100 transition-colors hover:bg-gray-600 focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 focus:outline-none'
variant='primary'
className="w-full max-w-200 px-30 py-16 rounded-[10px] shadow-lg hover:opacity-80 transition-colors duration-300 bg-nomad text-white text-base"
variant="primary"
onClick={() => (window.location.href = '/')}
>
홈으로 돌아가기
</Button>
Comment on lines 17 to 23
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

라우팅 방식 개선 및 스타일 중복 제거 필요

error.tsx와 동일한 이슈가 있습니다:

  1. window.location.href 대신 Next.js 라우터 사용 권장
  2. Button 컴포넌트의 스타일 중복 제거 필요
+'use client';
+
+import { useRouter } from 'next/navigation';
 import Button from '@/components/Button';

 export default function NotFoundPage() {
+  const router = useRouter();
+
   return (
     // ... other code
           <Button
-            className="w-full max-w-200 px-30 py-16 rounded-[10px] shadow-lg hover:opacity-80 transition-colors duration-300 bg-nomad text-white text-base"
+            className="w-full max-w-200 px-30 py-16 rounded-[10px] shadow-lg hover:opacity-80 transition-opacity duration-300"
             variant="primary"
-            onClick={() => (window.location.href = '/')}
+            onClick={() => router.push('/')}
           >
             홈으로 돌아가기
           </Button>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Button
className='cursor-pointer rounded-lg border border-gray-300 bg-gray-700 py-4 text-xl font-bold text-gray-100 transition-colors hover:bg-gray-600 focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 focus:outline-none'
variant='primary'
className="w-full max-w-200 px-30 py-16 rounded-[10px] shadow-lg hover:opacity-80 transition-colors duration-300 bg-nomad text-white text-base"
variant="primary"
onClick={() => (window.location.href = '/')}
>
홈으로 돌아가기
</Button>
'use client';
import { useRouter } from 'next/navigation';
import Button from '@/components/Button';
export default function NotFoundPage() {
const router = useRouter();
return (
// ... other code
<Button
className="w-full max-w-200 px-30 py-16 rounded-[10px] shadow-lg hover:opacity-80 transition-opacity duration-300"
variant="primary"
onClick={() => router.push('/')}
>
홈으로 돌아가기
</Button>
);
}
🤖 Prompt for AI Agents
In src/app/not-found.tsx around lines 17 to 23, replace the use of
window.location.href with Next.js router's navigation method (e.g., useRouter's
push) for client-side routing. Also, refactor the Button component's className
to remove redundant or duplicate style definitions, possibly by consolidating
styles or using a shared style variable or class to avoid repetition.

</div>
</div>
</div>
</main>
Comment on lines +7 to +26
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

코드 중복 제거를 위한 공통 컴포넌트 추출 권장

error.tsxnot-found.tsx가 거의 동일한 구조와 스타일을 공유하고 있습니다. 유지보수성 향상을 위해 공통 에러 페이지 컴포넌트로 추출하는 것을 권장합니다.

공통 컴포넌트 예시:

// src/components/ErrorPageLayout.tsx
interface ErrorPageLayoutProps {
  title: string;
  message: string;
}

export default function ErrorPageLayout({ title, message }: ErrorPageLayoutProps) {
  const router = useRouter();

  return (
    <main
      className="relative flex h-screen w-screen items-center justify-center px-10 md:justify-end bg-none md:bg-[url('/assets/img/404-image.png')] bg-no-repeat bg-cover md:bg-center"
    >
      <div className="relative z-10 w-full max-w-1200 mx-auto px-6 md:px-12 flex justify-center md:justify-end">
        <div className="flex flex-col items-center md:items-start gap-8 md:gap-20 text-center md:text-left max-w-xl">
          <h1 className="text-5xl md:text-8xl font-extrabold text-nomad">{title}</h1>
          <p className="text-base md:text-xl text-nomad mb-6 leading-relaxed">
            {message}
          </p>
          <Button
            className="w-full max-w-200 px-30 py-16 rounded-[10px] shadow-lg hover:opacity-80 transition-opacity duration-300"
            variant="primary"
            onClick={() => router.push('/')}
          >
            홈으로 돌아가기
          </Button>
        </div>
      </div>
    </main>
  );
}
🤖 Prompt for AI Agents
In src/app/not-found.tsx around lines 7 to 26, the code duplicates the structure
and styling found in error.tsx. To improve maintainability, extract the shared
layout into a common ErrorPageLayout component that accepts title and message as
props. Replace the current JSX in not-found.tsx with this new component, passing
the appropriate title and message, and update the button's onClick to use
router.push('/') for navigation.

);
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
}