mirror of
https://github.com/ktds-dg0501/kt-event-marketing-fe.git
synced 2026-06-13 02:19:12 +00:00
Merge branch 'develop' of https://github.com/ktds-dg0501/kt-event-marketing-fe into develop
This commit is contained in:
@@ -23,6 +23,7 @@ import { cardStyles, colors, responsiveText } from '@/shared/lib/button-styles';
|
||||
import { eventApi } from '@/entities/event/api/eventApi';
|
||||
import type { EventObjective } from '@/entities/event/model/types';
|
||||
|
||||
|
||||
interface ApprovalStepProps {
|
||||
eventData: EventData;
|
||||
onApprove: () => void;
|
||||
@@ -34,6 +35,7 @@ export default function ApprovalStep({ eventData, onApprove, onBack }: ApprovalS
|
||||
const [termsDialogOpen, setTermsDialogOpen] = useState(false);
|
||||
const [successDialogOpen, setSuccessDialogOpen] = useState(false);
|
||||
const [isDeploying, setIsDeploying] = useState(false);
|
||||
const DISTRIBUTION_API_BASE_URL = process.env.NEXT_PUBLIC_DISTRIBUTION_HOST || 'http://kt-event-marketing-api.20.214.196.128.nip.io';
|
||||
|
||||
const handleApprove = async () => {
|
||||
if (!agreeTerms) return;
|
||||
@@ -86,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');
|
||||
}
|
||||
@@ -129,6 +138,7 @@ export default function ApprovalStep({ eventData, onApprove, onBack }: ApprovalS
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const handleSaveDraft = () => {
|
||||
// TODO: 임시저장 API 연동
|
||||
alert('임시저장되었습니다');
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
const DISTRIBUTION_API_BASE_URL = process.env.NEXT_PUBLIC_DISTRIBUTION_HOST || 'http://kt-event-marketing-api.20.214.196.128.nip.io';
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { eventId: string } }
|
||||
) {
|
||||
try {
|
||||
const { eventId } = params;
|
||||
|
||||
console.log('🔄 Proxying distribution status request to Distribution API:', {
|
||||
url: `${DISTRIBUTION_API_BASE_URL}/api/v1/distribution/${eventId}/status`,
|
||||
eventId,
|
||||
});
|
||||
|
||||
const response = await fetch(`${DISTRIBUTION_API_BASE_URL}/distribution/${eventId}/status`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
console.error('❌ Distribution API error:', response.status, errorText);
|
||||
return NextResponse.json(
|
||||
{ error: 'Failed to get distribution status', details: errorText },
|
||||
{ status: response.status }
|
||||
);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
console.log('✅ Distribution status retrieved:', data);
|
||||
|
||||
return NextResponse.json(data);
|
||||
} catch (error) {
|
||||
console.error('❌ Proxy error:', error);
|
||||
return NextResponse.json(
|
||||
{ error: 'Internal server error', details: error instanceof Error ? error.message : 'Unknown error' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,15 @@ export const participationClient: AxiosInstance = axios.create({
|
||||
},
|
||||
});
|
||||
|
||||
// Distribution API 전용 클라이언트
|
||||
export const distributionClient: AxiosInstance = axios.create({
|
||||
baseURL: `${API_HOSTS.distribution}`,
|
||||
timeout: 90000,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
// 공통 Request interceptor 함수
|
||||
const requestInterceptor = (config: InternalAxiosRequestConfig) => {
|
||||
console.log('🚀 API Request:', {
|
||||
@@ -93,4 +102,8 @@ apiClient.interceptors.response.use(responseInterceptor, responseErrorIntercepto
|
||||
participationClient.interceptors.request.use(requestInterceptor, requestErrorInterceptor);
|
||||
participationClient.interceptors.response.use(responseInterceptor, responseErrorInterceptor);
|
||||
|
||||
// Distribution API Client 인터셉터 적용
|
||||
distributionClient.interceptors.request.use(requestInterceptor, requestErrorInterceptor);
|
||||
distributionClient.interceptors.response.use(responseInterceptor, responseErrorInterceptor);
|
||||
|
||||
export default apiClient;
|
||||
|
||||
Reference in New Issue
Block a user