Skip to content

Commit f518390

Browse files
author
chaewon41
committed
refactor: default categories 상수 파일로 분리 및 오타 수정
1 parent 16e4040 commit f518390

File tree

11 files changed

+32
-94
lines changed

11 files changed

+32
-94
lines changed

src/app/(main)/archive/page.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { DeleteConfirmDialog } from "@/components/archive/DeleteConfirmDialog";
1515
import { ArchiveCategoryEditBottomSheet } from "@/components/archive/ArchiveCategoryEditBottomSheet";
1616
import { NewCategoryBottomSheet } from "@/components/study/NewCategoryBottomSheet";
1717
import Loading from "@/components/common/Loading";
18+
import { DEFAULT_CATEGORIES } from "@/constants/categories";
1819

1920
type TabType = "news" | "terms";
2021

@@ -83,19 +84,6 @@ function Pagination({
8384
);
8485
}
8586

86-
// 기본 카테고리 (API 실패 시 사용)
87-
const DEFAULT_CATEGORIES: Category[] = [
88-
{ category_id: null, name: "종합" },
89-
{ category_id: 1, name: "금융" },
90-
{ category_id: 2, name: "증권" },
91-
{ category_id: 3, name: "산업/재계" },
92-
{ category_id: 4, name: "부동산" },
93-
{ category_id: 5, name: "중기/벤처" },
94-
{ category_id: 6, name: "글로벌 경제" },
95-
{ category_id: 7, name: "경제 일반" },
96-
{ category_id: 8, name: "생활 경제" },
97-
];
98-
9987
export default function ArchivePage() {
10088
const router = useRouter();
10189
const [activeTab, setActiveTab] = useState<TabType>("news");
@@ -152,7 +140,7 @@ export default function ArchivePage() {
152140
{ category_id: 2, name: "증권", code: "STOCK" },
153141
{ category_id: 3, name: "산업/재계", code: "INDUSTRY" },
154142
{ category_id: 4, name: "부동산", code: "REAL_ESTATE" },
155-
{ category_id: 5, name: "중기/벤처", code: "SME" },
143+
{ category_id: 5, name: "중기/벤쳐", code: "SME" },
156144
{ category_id: 6, name: "글로벌 경제", code: "GLOBAL" },
157145
{ category_id: 7, name: "경제 일반", code: "GENERAL" },
158146
{ category_id: 8, name: "생활 경제", code: "LIVING" },
@@ -164,7 +152,7 @@ export default function ArchivePage() {
164152
["STOCK", "증권"],
165153
["INDUSTRY", "산업/재계"],
166154
["REAL_ESTATE", "부동산"],
167-
["SME", "중기/벤처"],
155+
["SME", "중기/벤쳐"],
168156
["GLOBAL", "글로벌 경제"],
169157
["GENERAL", "경제 일반"],
170158
["LIVING", "생활 경제"],

src/app/(main)/archive/search/page.tsx

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,9 @@ import { ArchiveSortDropdown } from "@/components/archive/ArchiveSortDropdown";
1111
import { getCategoryOrder } from "@/lib/api/user";
1212
import { getStorageFolders, searchStorageNews, searchStorageTerms, type StorageNewsSearchItem, type StorageTermsSearchItem } from "@/lib/api/storage";
1313
import Loading from "@/components/common/Loading";
14-
type TabType = "news" | "terms";
14+
import { DEFAULT_CATEGORIES, type Category } from "@/constants/categories";
1515

16-
type Category = {
17-
category_id: number | null;
18-
name: string;
19-
};
20-
21-
// 기본 카테고리 (API 실패 시 사용)
22-
const DEFAULT_CATEGORIES: Category[] = [
23-
{ category_id: null, name: "종합" },
24-
{ category_id: 1, name: "금융" },
25-
{ category_id: 2, name: "증권" },
26-
{ category_id: 3, name: "산업/재계" },
27-
{ category_id: 4, name: "부동산" },
28-
{ category_id: 5, name: "중기/벤처" },
29-
{ category_id: 6, name: "글로벌 경제" },
30-
{ category_id: 7, name: "경제 일반" },
31-
{ category_id: 8, name: "생활 경제" },
32-
];
16+
type TabType = "news" | "terms";
3317

3418
// 뒤로가기 버튼
3519
function BackButton() {
@@ -219,7 +203,7 @@ function ArchiveSearchContent() {
219203
["STOCK", "증권"],
220204
["INDUSTRY", "산업/재계"],
221205
["REAL_ESTATE", "부동산"],
222-
["VENTURE", "중기/벤처"],
206+
["SME", "중기/벤쳐"],
223207
["GLOBAL", "글로벌 경제"],
224208
["GENERAL", "경제 일반"],
225209
["LIVING", "생활 경제"],
@@ -232,7 +216,7 @@ function ArchiveSearchContent() {
232216
[2, "STOCK"],
233217
[3, "INDUSTRY"],
234218
[4, "REAL_ESTATE"],
235-
[5, "VENTURE"],
219+
[5, "SME"],
236220
[6, "GLOBAL"],
237221
[7, "GENERAL"],
238222
[8, "LIVING"],

src/app/(main)/study/page.tsx

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,7 @@ import {
2121
updateCategoryOrder,
2222
type CategoryOrderItem,
2323
} from "@/lib/api/user";
24-
25-
type Category = {
26-
category_id: number | null;
27-
name: string;
28-
};
29-
30-
// 기본 카테고리 (API 실패 시 사용)
31-
const DEFAULT_CATEGORIES: Category[] = [
32-
{ category_id: null, name: "종합" },
33-
{ category_id: 1, name: "금융" },
34-
{ category_id: 2, name: "증권" },
35-
{ category_id: 3, name: "산업/재계" },
36-
{ category_id: 4, name: "부동산" },
37-
{ category_id: 5, name: "중기/벤처" },
38-
{ category_id: 6, name: "글로벌 경제" },
39-
{ category_id: 7, name: "경제 일반" },
40-
{ category_id: 8, name: "생활 경제" },
41-
];
24+
import { DEFAULT_CATEGORIES, type Category } from "@/constants/categories";
4225

4326
// 목 데이터 (API 응답이 없을 때 사용)
4427
const MOCK_NEWS: NewsItem[] = [

src/app/(main)/study/search/page.tsx

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,7 @@ import {
1616
import { getCategoryOrder, type CategoryOrderItem } from "@/lib/api/user";
1717
import { CATEGORY_MAP } from "@/store/homeStore";
1818
import Loading from "@/components/common/Loading";
19-
20-
type Category = {
21-
category_id: number | null;
22-
name: string;
23-
};
24-
25-
// 기본 카테고리 (API 실패 시 사용)
26-
const DEFAULT_CATEGORIES: Category[] = [
27-
{ category_id: null, name: "종합" },
28-
{ category_id: 1, name: "금융" },
29-
{ category_id: 2, name: "증권" },
30-
{ category_id: 3, name: "산업/재계" },
31-
{ category_id: 4, name: "부동산" },
32-
{ category_id: 5, name: "중기/벤처" },
33-
{ category_id: 6, name: "글로벌 경제" },
34-
{ category_id: 7, name: "경제 일반" },
35-
{ category_id: 8, name: "생활 경제" },
36-
];
19+
import { DEFAULT_CATEGORIES, type Category } from "@/constants/categories";
3720

3821
// 카테고리 ID를 API 카테고리 값으로 변환
3922
const categoryIdToApiCategory = (

src/components/archive/ArchiveSortDropdown.tsx

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,16 @@
11
"use client";
22

33
import { useState, useRef, useEffect } from "react";
4+
import { DEFAULT_CATEGORIES, type Category } from "@/constants/categories";
45

56
export type ArchiveCategoryOption = number | null;
67

7-
type Category = {
8-
category_id: number | null;
9-
name: string;
10-
};
11-
128
type ArchiveSortDropdownProps = {
139
value: ArchiveCategoryOption;
1410
onChange: (value: ArchiveCategoryOption) => void;
1511
categories?: Category[];
1612
};
1713

18-
// 기본 카테고리 목록
19-
const DEFAULT_CATEGORIES: Category[] = [
20-
{ category_id: null, name: "종합" },
21-
{ category_id: 1, name: "금융" },
22-
{ category_id: 2, name: "증권" },
23-
{ category_id: 3, name: "산업/재계" },
24-
{ category_id: 4, name: "부동산" },
25-
{ category_id: 5, name: "중기/벤처" },
26-
{ category_id: 6, name: "글로벌 경제" },
27-
{ category_id: 7, name: "경제 일반" },
28-
{ category_id: 8, name: "생활 경제" },
29-
];
30-
3114
export function ArchiveSortDropdown({
3215
value,
3316
onChange,

src/components/mypage/BalanceRings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default function BalanceRings({ items }: Props) {
6262
STOCK: "증권",
6363
INDUSTRY: "산업/재계",
6464
REAL_ESTATE: "부동산",
65-
SME: "중기/벤처",
65+
SME: "중기/벤쳐",
6666
GLOBAL: "글로벌 경제",
6767
GENERAL: "경제 일반",
6868
LIVING: "생활 경제",

src/components/mypage/WeeklyReportCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const MODE_LABEL: Record<string, string> = {
3232
STOCK: "증권 전문가",
3333
INDUSTRY: "산업/재계 전문가",
3434
REAL_ESTATE: "부동산 전문가",
35-
SME: "증기/벤처 전문가",
35+
SME: "중기/벤쳐 전문가",
3636
GLOBAL: "글로벌 경제 전문가",
3737
GENERAL: "경제 일반 전문가",
3838
LIFE: "생활경제 전문가",

src/constants/categories.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export interface Category {
2+
category_id: number | null;
3+
name: string;
4+
}
5+
6+
// 기본 카테고리 목록 (API 실패 시 사용)
7+
export const DEFAULT_CATEGORIES: Category[] = [
8+
{ category_id: null, name: "종합" },
9+
{ category_id: 1, name: "금융" },
10+
{ category_id: 2, name: "증권" },
11+
{ category_id: 3, name: "산업/재계" },
12+
{ category_id: 4, name: "부동산" },
13+
{ category_id: 5, name: "중기/벤쳐" },
14+
{ category_id: 6, name: "글로벌 경제" },
15+
{ category_id: 7, name: "경제 일반" },
16+
{ category_id: 8, name: "생활경제" },
17+
];

src/lib/mock/mypage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export const ALL_CATEGORIES_8: CategoryItem[] = [
9191
{ section: "GLOBAL", displayName: "글로벌 경제" },
9292
{ section: "INDUSTRY", displayName: "산업/재계" },
9393
{ section: "REAL_ESTATE", displayName: "부동산" },
94-
{ section: "SME", displayName: "중기/벤처" },
94+
{ section: "SME", displayName: "중기/벤쳐" },
9595
{ section: "GENERAL", displayName: "경제 일반" },
9696
{ section: "LIFE", displayName: "생활경제" },
9797
];

src/store/homeStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const CATEGORY_MAP: Record<string, string> = {
1919
FINANCE: '금융',
2020
STOCK: '증권',
2121
INDUSTRY: '산업/재계',
22-
SME: '중기/벤처',
22+
SME: '중기/벤쳐',
2323
REAL_ESTATE: '부동산',
2424
GLOBAL: '글로벌 경제',
2525
LIVING: '생활경제',

0 commit comments

Comments
 (0)