'use client'; import type { GoalConfigItem } from '@/types/response/donation/goalConfig'; import { Checkbox } from '@/components/ui/checkbox'; import { FONT_OPTIONS } from '../../alert/constants'; import { GOAL_STYLES } from '../types'; import type { FormState } from '../types'; import { GOAL_BAR_HEIGHT_MIN, GOAL_BAR_HEIGHT_MAX, FONT_SIZE_MIN, FONT_SIZE_MAX, COLOR_HEX_MAX_LENGTH } from '@/constants/donation'; type Props = { form: FormState; editingItem: GoalConfigItem|null; saving: boolean; onFormChange: (field: K, value: FormState[K]) => void; onSave: () => void; onCancel: () => void; }; export default function GoalFormPanel({ form, editingItem, saving, onFormChange, onSave, onCancel }: Props) { // ── 색상 그룹 렌더러 ───────────────────────────── const renderColorField = ( label: string, id: string, colorField: 'barColor'|'barBackgroundColor'|'titleFontColor'|'amountFontColor', ) => (
onFormChange(colorField, e.target.value)} /> onFormChange(colorField, e.target.value)} maxLength={COLOR_HEX_MAX_LENGTH} title={label} />
); // ── 폰트 그룹 렌더러 ───────────────────────────── const renderFontGroup = ( label: string, prefix: string, familyField: 'titleFontFamily'|'amountFontFamily', sizeField: 'titleFontSizePx'|'amountFontSizePx', colorField: 'titleFontColor'|'amountFontColor', defaultSize: number ) => (
{label}
onFormChange(sizeField, parseInt(e.target.value) || defaultSize)} title="Font Size" />
onFormChange(colorField, e.target.value)} /> onFormChange(colorField, e.target.value)} maxLength={COLOR_HEX_MAX_LENGTH} title="Font Color" />
); return (
{/* ── 기본 설정 ────────────────────────────── */}

기본 설정

onFormChange('title', e.target.value)} placeholder="후원 목표" />
onFormChange('startAmount', parseInt(e.target.value) || 0)} />
onFormChange('targetAmount', parseInt(e.target.value) || 0)} />
onFormChange('startAt', e.target.value)} placeholder="2026.03.30 14:00" maxLength={16} />
onFormChange('endAt', e.target.value)} placeholder="2026.03.31 14:00" maxLength={16} />
{/* ── 바 설정 ─────────────────────────────── */}

바 설정

{renderColorField('바 색상', 'goal-barColor', 'barColor')} {renderColorField('바 배경색', 'goal-barBgColor', 'barBackgroundColor')}
onFormChange('barHeightPx', parseInt(e.target.value) || 24)} />
{/* ── 폰트 ────────────────────────────────── */}

폰트

{renderFontGroup('제목', 'font-title', 'titleFontFamily', 'titleFontSizePx', 'titleFontColor', 16)} {renderFontGroup('현황', 'font-amount', 'amountFontFamily', 'amountFontSizePx', 'amountFontColor', 14)}
{/* ── 하단 버튼 ────────────────────────────── */}
); }