From 81a2112b59352d09839f648541e6254fef4c7fca Mon Sep 17 00:00:00 2001 From: caadiq Date: Fri, 23 Jan 2026 09:30:18 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EC=83=89=EC=83=81=20=EC=9C=A0?= =?UTF-8?q?=ED=8B=B8=EB=A6=AC=ED=8B=B0=20=ED=86=B5=ED=95=A9=20-=20colorMap?= =?UTF-8?q?/getColorStyle=20=EC=A4=91=EB=B3=B5=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - utils/color.js 생성 (COLOR_MAP, COLOR_OPTIONS, getColorStyle) - Schedules.jsx: 1159줄 → 1139줄 (20줄 감소) - ScheduleForm.jsx: 765줄 → 743줄 (22줄 감소) - ScheduleCategory.jsx: 466줄 → 441줄 (25줄 감소) - 3개 파일에서 중복 코드 제거, 공통 유틸리티 import로 교체 Co-Authored-By: Claude Opus 4.5 --- .../pc/admin/schedules/ScheduleCategory.jsx | 29 +----------- .../pages/pc/admin/schedules/ScheduleForm.jsx | 24 +--------- .../pages/pc/admin/schedules/Schedules.jsx | 22 +--------- frontend-temp/src/utils/color.js | 44 +++++++++++++++++++ 4 files changed, 48 insertions(+), 71 deletions(-) create mode 100644 frontend-temp/src/utils/color.js diff --git a/frontend-temp/src/pages/pc/admin/schedules/ScheduleCategory.jsx b/frontend-temp/src/pages/pc/admin/schedules/ScheduleCategory.jsx index adb005d..fb666f2 100644 --- a/frontend-temp/src/pages/pc/admin/schedules/ScheduleCategory.jsx +++ b/frontend-temp/src/pages/pc/admin/schedules/ScheduleCategory.jsx @@ -8,32 +8,7 @@ import { AdminLayout, ConfirmDialog } from '@/components/pc/admin'; import { useAdminAuth } from '@/hooks/pc/admin'; import { useToast } from '@/hooks/common'; import * as categoriesApi from '@/api/admin/categories'; - -// 기본 색상 (8개) -const colorOptions = [ - { id: 'blue', name: '파란색', bg: 'bg-blue-500', hex: '#3b82f6' }, - { id: 'green', name: '초록색', bg: 'bg-green-500', hex: '#22c55e' }, - { id: 'purple', name: '보라색', bg: 'bg-purple-500', hex: '#a855f7' }, - { id: 'red', name: '빨간색', bg: 'bg-red-500', hex: '#ef4444' }, - { id: 'pink', name: '분홍색', bg: 'bg-pink-500', hex: '#ec4899' }, - { id: 'yellow', name: '노란색', bg: 'bg-yellow-500', hex: '#eab308' }, - { id: 'orange', name: '주황색', bg: 'bg-orange-500', hex: '#f97316' }, - { id: 'gray', name: '회색', bg: 'bg-gray-500', hex: '#6b7280' }, -]; - -// 색상 헬퍼 (커스텀 HEX 지원) -const getColorStyle = (colorValue) => { - // 기본 색상인지 확인 - const preset = colorOptions.find((c) => c.id === colorValue); - if (preset) { - return { className: preset.bg }; - } - // HEX 색상인 경우 - if (colorValue?.startsWith('#')) { - return { style: { backgroundColor: colorValue } }; - } - return { className: 'bg-gray-500' }; -}; +import { COLOR_OPTIONS, getColorStyle } from '@/utils/color'; function ScheduleCategory() { const { user, isAuthenticated } = useAdminAuth(); @@ -319,7 +294,7 @@ function ScheduleCategory() {
- {colorOptions.map((color) => ( + {COLOR_OPTIONS.map((color) => (