Skip to content

Commit

Permalink
feat: CategoryId 타입 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
BangDori committed May 14, 2024
1 parent a3ee67a commit 37bce5e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 9 additions & 2 deletions src/features/feed-reports/consts/reports.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
export const REPORT_CATEOGRIES = [
export type ReportCategoryId = 1 | 2 | 3 | 4 | 5 | 6 | 7;

interface ReportCategory {
id: ReportCategoryId;
name: string;
}

export const REPORT_CATEOGRIES: ReportCategory[] = [
{ id: 1, name: '상업적/홍보성' },
{ id: 2, name: '음란/선정성' },
{ id: 3, name: '저작권 침해' },
{ id: 4, name: '개인정보 노출' },
{ id: 5, name: '욕설/인신공격' },
{ id: 6, name: '반복적인 내용' },
{ id: 7, name: '기타' },
] as const;
];

export const MAX_REPORT_CONTENT_LENGTH = 100;
6 changes: 2 additions & 4 deletions src/features/feed-reports/model/useReportCategories.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { useState } from 'react';

import { REPORT_CATEOGRIES } from '../consts';

type ReportCategoryId = (typeof REPORT_CATEOGRIES)[number]['id'];
import { REPORT_CATEOGRIES, ReportCategoryId } from '../consts';

export const useReportCategories = () => {
const [categories, setCategories] = useState(
Expand All @@ -24,5 +22,5 @@ export const useReportCategories = () => {

export function getCategoryName(id: ReportCategoryId) {
const category = REPORT_CATEOGRIES.find((item) => item.id === id);
return category ? category.name : '';
return category?.name ?? '';
}

0 comments on commit 37bce5e

Please sign in to comment.