크레딧기능 추가
This commit is contained in:
1 parent
044fd21b2d
commit
bdd52ed992
12 files changed
+153
-25
No files matched your search
@@ -12,6 +12,7 @@ interface CompletionContentProps {
|
||||
songTaskId: string | null;
|
||||
onVideoStatusChange?: (status: 'idle' | 'generating' | 'complete' | 'error') => void;
|
||||
onVideoProgressChange?: (progress: number) => void;
|
||||
onVideoComplete?: () => void;
|
||||
}
|
||||
|
||||
type VideoStatus = 'idle' | 'generating' | 'polling' | 'complete' | 'error';
|
||||
@@ -32,7 +33,8 @@ const CompletionContent: React.FC<CompletionContentProps> = ({
|
||||
onBack,
|
||||
songTaskId,
|
||||
onVideoStatusChange,
|
||||
onVideoProgressChange
|
||||
onVideoProgressChange,
|
||||
onVideoComplete,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [videoStatus, setVideoStatus] = useState<VideoStatus>('idle');
|
||||
@@ -253,6 +255,7 @@ const CompletionContent: React.FC<CompletionContentProps> = ({
|
||||
setVideoStatus('complete');
|
||||
setStatusMessage('');
|
||||
saveToStorage(videoTaskId, currentSongTaskId, 'complete', videoUrlFromResponse, videoId);
|
||||
onVideoComplete?.();
|
||||
} else {
|
||||
throw new Error(t('completion.videoUrlMissing'));
|
||||
}
|
||||
|
||||
@@ -618,7 +618,7 @@ const DashboardContent: React.FC<DashboardContentProps> = ({ onNavigate }) => {
|
||||
|
||||
// showMockData=true면 전체 mock 강제, 아니면 API 우선 / isEmptyState 시 mock 폴백
|
||||
const useReal = !showMockData && !isEmptyState;
|
||||
const hasRealContentMetrics = useReal && !!dashboardData?.contentMetrics?.slice(0, -1).some((m: ContentMetric) => m.value > 0);
|
||||
const hasRealContentMetrics = useReal && !!dashboardData?.contentMetrics?.some((m: ContentMetric) => m.value > 0);
|
||||
const contentMetrics = hasRealContentMetrics ? dashboardData!.contentMetrics : MOCK_CONTENT_METRICS;
|
||||
|
||||
// 블러 조건: 1)계정 미연결 2)업로드 영상 없음 3)데이터 없음 4)에러 있음 5)실제 지표 없음
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import Sidebar from '../../components/Sidebar';
|
||||
import AssetManagementContent from './AssetManagementContent';
|
||||
@@ -14,7 +14,7 @@ import ContentCalendarContent from './ContentCalendarContent';
|
||||
import LoadingSection from '../Analysis/LoadingSection';
|
||||
import AnalysisResultSection from '../Analysis/AnalysisResultSection';
|
||||
import { ImageItem, CrawlingResponse, UserMeResponse } from '../../types/api';
|
||||
import { crawlUrl, autocomplete, AutocompleteRequest, getUserMe, clearTokens } from '../../utils/api';
|
||||
import { crawlUrl, autocomplete, AutocompleteRequest, getUserMe, getUserCredits, clearTokens } from '../../utils/api';
|
||||
import { useTutorial } from '../../components/Tutorial/useTutorial';
|
||||
import { TUTORIAL_KEYS } from '../../components/Tutorial/tutorialSteps';
|
||||
import TutorialOverlay, { TutorialRestartPopup } from '../../components/Tutorial/TutorialOverlay';
|
||||
@@ -117,14 +117,25 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
const [analysisError, setAnalysisError] = useState<string | null>(null);
|
||||
const [isAnalysisComplete, setIsAnalysisComplete] = useState(false);
|
||||
const [userInfo, setUserInfo] = useState<UserMeResponse | null>(null);
|
||||
const [credits, setCredits] = useState<number | null>(null);
|
||||
const tutorial = useTutorial();
|
||||
|
||||
// 로그인 직후 사용자 정보 조회
|
||||
const refreshCredits = useCallback(async () => {
|
||||
try {
|
||||
const { credits } = await getUserCredits();
|
||||
setCredits(credits);
|
||||
} catch (e) {
|
||||
console.error('Failed to refresh credits:', e);
|
||||
}
|
||||
}, []);
|
||||
|
||||
// 로그인 직후 사용자 정보 + 크레딧 조회
|
||||
useEffect(() => {
|
||||
const fetchUserInfo = async () => {
|
||||
try {
|
||||
const data = await getUserMe();
|
||||
const [data, creditsData] = await Promise.all([getUserMe(), getUserCredits()]);
|
||||
setUserInfo(data);
|
||||
setCredits(creditsData.credits);
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch user info:', error);
|
||||
}
|
||||
@@ -467,6 +478,7 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
songTaskId={songTaskId}
|
||||
onVideoStatusChange={setVideoGenerationStatus}
|
||||
onVideoProgressChange={setVideoGenerationProgress}
|
||||
onVideoComplete={refreshCredits}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
@@ -572,7 +584,7 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
return (
|
||||
<div className="analysis-page-wrapper">
|
||||
{showSidebar && (
|
||||
<Sidebar activeItem={activeItem} onNavigate={handleNavigate} onHome={handleHome} userInfo={userInfo} onLogout={handleLogout} />
|
||||
<Sidebar activeItem={activeItem} onNavigate={handleNavigate} onHome={handleHome} userInfo={userInfo} onLogout={handleLogout} credits={credits} />
|
||||
)}
|
||||
<main className="analysis-page-main">
|
||||
{renderContent()}
|
||||
@@ -585,7 +597,7 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
return (
|
||||
<div className={`flex w-full bg-[#002224] text-white ${needsScroll ? 'min-h-[100dvh]' : 'h-[100dvh] overflow-hidden'}`}>
|
||||
{showSidebar && (
|
||||
<Sidebar activeItem={activeItem} onNavigate={handleNavigate} onHome={handleHome} userInfo={userInfo} onLogout={handleLogout} />
|
||||
<Sidebar activeItem={activeItem} onNavigate={handleNavigate} onHome={handleHome} userInfo={userInfo} onLogout={handleLogout} credits={credits} />
|
||||
)}
|
||||
{tutorialUI}
|
||||
<div className={`flex-1 relative pl-0 md:pl-0 ${needsScroll ? 'overflow-auto' : 'h-full overflow-hidden'}`}>
|
||||
|
||||
@@ -42,7 +42,7 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
|
||||
mId,
|
||||
onStatusChange,
|
||||
videoGenerationStatus = 'idle',
|
||||
videoGenerationProgress = 0
|
||||
videoGenerationProgress = 0,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [selectedType, setSelectedType] = useState('보컬');
|
||||
@@ -533,11 +533,19 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
|
||||
</button>
|
||||
)}
|
||||
|
||||
{errorMessage && (
|
||||
<div className="error-message-new">
|
||||
{errorMessage}
|
||||
</div>
|
||||
)}
|
||||
{errorMessage && (() => {
|
||||
const isCreditsError = errorMessage.includes('credit');
|
||||
return (
|
||||
<div className="error-message-new">
|
||||
{isCreditsError ? t('soundStudio.creditsExhausted') : errorMessage}
|
||||
{isCreditsError && (
|
||||
<a href="#" className="charge-credits-link">
|
||||
{t('soundStudio.chargeCredits')}
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})()}
|
||||
</div>
|
||||
|
||||
{/* Right Column - Lyrics */}
|
||||
|
||||
Reference in new issue
Block a user