배포 api 수정

This commit is contained in:
sunmingLee 2025-10-30 13:04:49 +09:00
parent 8f0d002d82
commit e1287806a7

View File

@ -88,39 +88,46 @@ export default function ApprovalStep({ eventData, onApprove, onBack }: ApprovalS
});
console.log('✅ Event details updated');
// 3. 배포 채널 선택
if (eventData.channels && eventData.channels.length > 0) {
console.log('📞 Selecting channels:', eventData.channels);
// 채널명 매핑 (Frontend → Backend)
const channelMap: Record<string, string[]> = {
uriTV: ['URIDONGNETV'],
ringoBiz: ['RINGOBIZ'],
genieTV: ['GINITV'],
sns: ['INSTAGRAM', 'NAVER', 'KAKAO'],
};
// 채널명 매핑 (Frontend → Backend)
const channelMap: Record<string, string> = {
'uriTV': 'WEBSITE',
'ringoBiz': 'EMAIL',
'genieTV': 'KAKAO',
'sns': 'INSTAGRAM',
};
const apiChannels = eventData.channels?.flatMap(ch => channelMap[ch] || []) || [];
const backendChannels = eventData.channels.map(ch => channelMap[ch] || ch.toUpperCase());
const distributionRequest = {
eventId: eventId,
title: eventName,
description: eventData.contentEdit?.guide || eventData.recommendation?.recommendation?.description || '',
imageUrl: '', // TODO: 이미지 URL 연동 필요
channels: apiChannels,
channelSettings: {},
};
await eventApi.selectChannels(eventId, {
channels: backendChannels,
});
console.log('✅ Channels selected');
console.log('🚀 Distributing event:', distributionRequest);
const response = await fetch(`${DISTRIBUTION_API_BASE_URL}/api/v1/distribution/distribute`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(distributionRequest),
});
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.error || '배포 중 오류가 발생했습니다');
}
// 4. TODO: 이미지 선택
// 현재 frontend에서 selectedImageId를 추적하지 않음
// 향후 contentPreview 단계에서 선택된 이미지 ID를 eventData에 저장 필요
console.log('⚠️ Image selection skipped - imageId not tracked in frontend');
const data = await response.json();
console.log('✅ Distribution completed:', data);
// 5. 이벤트 배포 API 호출
console.log('📞 Publishing event:', eventId);
const publishResponse = await eventApi.publishEvent(eventId);
console.log('✅ Event published:', publishResponse);
// 성공 다이얼로그 표시
setIsDeploying(false);
setSuccessDialogOpen(true);
} else {
throw new Error('Event creation failed: No event ID returned');
}