mirror of
https://github.com/ktds-dg0501/kt-event-marketing-fe.git
synced 2025-12-06 06:56:24 +00:00
배포 api 수정
This commit is contained in:
parent
8f0d002d82
commit
e1287806a7
@ -88,39 +88,46 @@ export default function ApprovalStep({ eventData, onApprove, onBack }: ApprovalS
|
|||||||
});
|
});
|
||||||
console.log('✅ Event details updated');
|
console.log('✅ Event details updated');
|
||||||
|
|
||||||
// 3. 배포 채널 선택
|
// 채널명 매핑 (Frontend → Backend)
|
||||||
if (eventData.channels && eventData.channels.length > 0) {
|
const channelMap: Record<string, string[]> = {
|
||||||
console.log('📞 Selecting channels:', eventData.channels);
|
uriTV: ['URIDONGNETV'],
|
||||||
|
ringoBiz: ['RINGOBIZ'],
|
||||||
|
genieTV: ['GINITV'],
|
||||||
|
sns: ['INSTAGRAM', 'NAVER', 'KAKAO'],
|
||||||
|
};
|
||||||
|
|
||||||
// 채널명 매핑 (Frontend → Backend)
|
const apiChannels = eventData.channels?.flatMap(ch => channelMap[ch] || []) || [];
|
||||||
const channelMap: Record<string, string> = {
|
|
||||||
'uriTV': 'WEBSITE',
|
|
||||||
'ringoBiz': 'EMAIL',
|
|
||||||
'genieTV': 'KAKAO',
|
|
||||||
'sns': 'INSTAGRAM',
|
|
||||||
};
|
|
||||||
|
|
||||||
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, {
|
console.log('🚀 Distributing event:', distributionRequest);
|
||||||
channels: backendChannels,
|
|
||||||
});
|
const response = await fetch(`${DISTRIBUTION_API_BASE_URL}/api/v1/distribution/distribute`, {
|
||||||
console.log('✅ Channels selected');
|
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: 이미지 선택
|
const data = await response.json();
|
||||||
// 현재 frontend에서 selectedImageId를 추적하지 않음
|
console.log('✅ Distribution completed:', data);
|
||||||
// 향후 contentPreview 단계에서 선택된 이미지 ID를 eventData에 저장 필요
|
|
||||||
console.log('⚠️ Image selection skipped - imageId not tracked in frontend');
|
|
||||||
|
|
||||||
// 5. 이벤트 배포 API 호출
|
|
||||||
console.log('📞 Publishing event:', eventId);
|
|
||||||
const publishResponse = await eventApi.publishEvent(eventId);
|
|
||||||
console.log('✅ Event published:', publishResponse);
|
|
||||||
|
|
||||||
// 성공 다이얼로그 표시
|
|
||||||
setIsDeploying(false);
|
setIsDeploying(false);
|
||||||
setSuccessDialogOpen(true);
|
setSuccessDialogOpen(true);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Event creation failed: No event ID returned');
|
throw new Error('Event creation failed: No event ID returned');
|
||||||
}
|
}
|
||||||
@ -130,7 +137,7 @@ export default function ApprovalStep({ eventData, onApprove, onBack }: ApprovalS
|
|||||||
alert('이벤트 배포에 실패했습니다. 다시 시도해 주세요.');
|
alert('이벤트 배포에 실패했습니다. 다시 시도해 주세요.');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const handleSaveDraft = () => {
|
const handleSaveDraft = () => {
|
||||||
// TODO: 임시저장 API 연동
|
// TODO: 임시저장 API 연동
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user