Skip to content
Merged
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
4 changes: 1 addition & 3 deletions src/pages/admin/AdminReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,7 @@ export default function AdminReport({

<div className="shrink-0 w-[120px] flex justify-center">
<button
onClick={() =>
navigate(`/post-content/${report.reportedPostId}`)
}
onClick={() => navigate(`/post/${report.reportedPostId}`)}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

하드코딩된 경로 문자열은 오타에 취약하고 나중에 경로 구조가 변경될 때 여러 곳을 수정해야 하는 불편함이 있습니다.

유지보수성을 높이기 위해 경로들을 상수로 관리하는 것을 고려해보세요. 예를 들어, src/constants/paths.ts와 같은 파일을 만들어 경로를 중앙에서 관리할 수 있습니다.

// src/constants/paths.ts
export const PATHS = {
  POST_DETAIL: (postId: number | string) => `/post/${postId}`,
  // ... other paths
};

그리고 다음과 같이 사용할 수 있습니다.

// AdminReport.tsx
import { PATHS } from '@/constants/paths';
// ...
onClick={() => navigate(PATHS.POST_DETAIL(report.reportedPostId))}

이렇게 하면 경로가 변경되어도 paths.ts 파일만 수정하면 되므로 관리가 용이해지고, 자동 완성을 통해 오타를 줄일 수 있습니다.

className="text-main-1 font-semibold cursor-pointer text-2xl whitespace-nowrap"
>
바로가기
Expand Down
Loading