'use client'; import { useFunnel } from '@use-funnel/browser'; import { useRouter } from 'next/navigation'; import ObjectiveStep from './steps/ObjectiveStep'; import RecommendationStep from './steps/RecommendationStep'; import ContentPreviewStep from './steps/ContentPreviewStep'; import ContentEditStep from './steps/ContentEditStep'; import ChannelStep from './steps/ChannelStep'; import ApprovalStep from './steps/ApprovalStep'; // 이벤트 생성 데이터 타입 export type EventObjective = 'new_customer' | 'revisit' | 'sales' | 'awareness'; export type BudgetLevel = 'low' | 'medium' | 'high'; export type EventMethod = 'online' | 'offline'; export interface EventData { eventDraftId?: number; eventId?: string; objective?: EventObjective; recommendation?: { recommendation: { optionNumber: number; concept: string; title: string; description: string; targetAudience: string; duration: { recommendedDays: number; recommendedPeriod?: string; }; mechanics: { type: 'DISCOUNT' | 'GIFT' | 'STAMP' | 'EXPERIENCE' | 'LOTTERY' | 'COMBO'; details: string; }; promotionChannels: string[]; estimatedCost: { min: number; max: number; breakdown?: { material?: number; promotion?: number; discount?: number; }; }; expectedMetrics: { newCustomers: { min: number; max: number }; repeatVisits?: { min: number; max: number }; revenueIncrease: { min: number; max: number }; roi: { min: number; max: number }; socialEngagement?: { estimatedPosts: number; estimatedReach: number; }; }; differentiator: string; }; eventId: string; }; contentPreview?: { imageStyle: string; images?: any[]; }; contentEdit?: { title: string; prize: string; guide: string; }; channels?: string[]; } export default function EventCreatePage() { const router = useRouter(); const funnel = useFunnel<{ objective: EventData; recommendation: EventData; contentPreview: EventData; contentEdit: EventData; channel: EventData; approval: EventData; }>({ id: 'event-creation', initial: { step: 'objective', context: {}, }, }); const handleComplete = () => { // 이벤트 생성 완료 후 대시보드로 이동 router.push('/'); }; return ( ( { history.push('recommendation', { objective, eventId }); }} /> )} recommendation={({ context, history }) => ( { history.push('channel', { ...context, recommendation }); }} onBack={() => { history.go(-1); }} /> )} channel={({ context, history }) => ( { // 우리동네TV, 지니TV, SNS 중 하나라도 포함되어 있으면 contentPreview로 const needsContent = channels.some((ch) => ['uriTV', 'genieTV', 'sns'].includes(ch) ); if (needsContent) { // localStorage에 이벤트 정보 저장 const eventData = { eventDraftId: context.recommendation?.eventId || String(Date.now()), // eventId 사용 eventTitle: context.recommendation?.recommendation.title || '', eventDescription: context.recommendation?.recommendation.description || '', industry: '', location: '', trends: context.recommendation?.recommendation.promotionChannels || [], prize: '', }; localStorage.setItem('eventCreationData', JSON.stringify(eventData)); history.push('contentPreview', { ...context, channels }); } else { history.push('approval', { ...context, channels }); } }} onBack={() => { history.go(-1); }} /> )} contentPreview={({ context, history }) => ( { history.push('contentEdit', { ...context, contentPreview: { imageStyle, images }, }); }} onSkip={() => { history.push('approval', context); }} onBack={() => { history.go(-1); }} /> )} contentEdit={({ context, history }) => ( { history.push('approval', { ...context, contentEdit }); }} onBack={() => { history.go(-1); }} /> )} approval={({ context, history }) => ( { history.go(-1); }} /> )} /> ); }