import { useState } from 'react'; import { Box, Container, Typography, Card, CardContent, Button, Checkbox, FormControlLabel, Select, MenuItem, TextField, FormControl, InputLabel, IconButton, } from '@mui/material'; import { ArrowBack } from '@mui/icons-material'; // 디자인 시스템 색상 const colors = { pink: '#F472B6', purple: '#C084FC', purpleLight: '#E9D5FF', blue: '#60A5FA', mint: '#34D399', orange: '#FB923C', yellow: '#FBBF24', gray: { 900: '#1A1A1A', 700: '#4A4A4A', 500: '#9E9E9E', 300: '#D9D9D9', 100: '#F5F5F5', }, }; interface Channel { id: string; name: string; selected: boolean; config?: Record; } interface ChannelStepProps { onNext: (channels: string[]) => void; onBack: () => void; } export default function ChannelStep({ onNext, onBack }: ChannelStepProps) { const [channels, setChannels] = useState([ { id: 'uriTV', name: '우리동네TV', selected: false, config: { radius: '500', time: 'evening' } }, { id: 'ringoBiz', name: '링고비즈', selected: false, config: { phone: '010-1234-5678' } }, { id: 'genieTV', name: '지니TV 광고', selected: false, config: { region: 'suwon', time: 'all', budget: '' } }, { id: 'sns', name: 'SNS', selected: false, config: { instagram: 'true', naver: 'true', kakao: 'false', schedule: 'now' } }, ]); const handleChannelToggle = (channelId: string) => { setChannels((prev) => prev.map((ch) => (ch.id === channelId ? { ...ch, selected: !ch.selected } : ch)) ); }; const handleConfigChange = (channelId: string, key: string, value: string) => { setChannels((prev) => prev.map((ch) => ch.id === channelId ? { ...ch, config: { ...ch.config, [key]: value } } : ch ) ); }; const getChannelConfig = (channelId: string, key: string): string => { const channel = channels.find((ch) => ch.id === channelId); return (channel?.config?.[key] as string) || ''; }; const calculateSummary = () => { let totalCost = 0; let totalExposure = 0; channels.forEach((ch) => { if (!ch.selected) return; if (ch.id === 'uriTV') { totalCost += 80000; totalExposure += 50000; } else if (ch.id === 'ringoBiz') { totalExposure += 30000; } else if (ch.id === 'genieTV') { const budget = parseInt(getChannelConfig('genieTV', 'budget')) || 0; totalCost += budget; totalExposure += Math.floor(budget / 100) * 1000; } }); return { totalCost, totalExposure }; }; const handleNext = () => { const selectedChannels = channels.filter((ch) => ch.selected).map((ch) => ch.id); if (selectedChannels.length > 0) { onNext(selectedChannels); } }; const { totalCost, totalExposure } = calculateSummary(); const selectedCount = channels.filter((ch) => ch.selected).length; return ( {/* Header */} 배포 채널 선택 (최소 1개 이상) {/* 우리동네TV */} handleChannelToggle('uriTV')} sx={{ color: colors.purple, '&.Mui-checked': { color: colors.purple, }, }} /> } label={ 우리동네TV } sx={{ mb: channels[0].selected ? 2 : 0 }} /> {channels[0].selected && ( 반경 노출 시간대 예상 노출: 5만명 비용: 8만원 )} {/* 링고비즈 */} handleChannelToggle('ringoBiz')} sx={{ color: colors.purple, '&.Mui-checked': { color: colors.purple, }, }} /> } label={ 링고비즈 } sx={{ mb: channels[1].selected ? 2 : 0 }} /> {channels[1].selected && ( 연결음 자동 업데이트 예상 노출: 3만명 비용: 무료 )} {/* 지니TV 광고 */} handleChannelToggle('genieTV')} sx={{ color: colors.purple, '&.Mui-checked': { color: colors.purple, }, }} /> } label={ 지니TV 광고 } sx={{ mb: channels[2].selected ? 2 : 0 }} /> {channels[2].selected && ( 지역 노출 시간대 handleConfigChange('genieTV', 'budget', e.target.value)} InputProps={{ inputProps: { min: 0, step: 10000 } }} sx={{ mb: 2 }} /> 예상 노출:{' '} {getChannelConfig('genieTV', 'budget') ? `${(Math.floor(parseInt(getChannelConfig('genieTV', 'budget')) / 100) * 1000 / 10000).toFixed(1)}만명` : '계산중...'} )} {/* SNS */} handleChannelToggle('sns')} sx={{ color: colors.purple, '&.Mui-checked': { color: colors.purple, }, }} /> } label={ SNS } sx={{ mb: channels[3].selected ? 2 : 0 }} /> {channels[3].selected && ( 플랫폼 선택 handleConfigChange('sns', 'instagram', e.target.checked.toString()) } sx={{ color: colors.purple, '&.Mui-checked': { color: colors.purple, }, }} /> } label="Instagram" sx={{ display: 'block' }} /> handleConfigChange('sns', 'naver', e.target.checked.toString()) } sx={{ color: colors.purple, '&.Mui-checked': { color: colors.purple, }, }} /> } label="Naver Blog" sx={{ display: 'block' }} /> handleConfigChange('sns', 'kakao', e.target.checked.toString()) } sx={{ color: colors.purple, '&.Mui-checked': { color: colors.purple, }, }} /> } label="Kakao Channel" sx={{ display: 'block', mb: 2 }} /> 예약 게시 예상 노출: - 비용: 무료 )} {/* Summary */} 총 예상 비용 {totalCost.toLocaleString()}원 총 예상 노출 {totalExposure > 0 ? `${totalExposure.toLocaleString()}명+` : '0명'} {/* Action Buttons */} ); }