카카오 로그인 및 비로그인 플로우 적용 .
This commit is contained in:
1 parent
2acf4e2cb6
commit
662b6b80bc
15 files changed
+1393
-335
No files matched your search
@@ -50,129 +50,114 @@ const formatReportText = (text: string): React.ReactNode[] => {
|
||||
});
|
||||
};
|
||||
|
||||
// 마크다운 report를 섹션별로 파싱
|
||||
const parseReport = (report: string) => {
|
||||
if (!report || report.trim() === '') {
|
||||
return [];
|
||||
}
|
||||
// 셀링 포인트 카드 타입
|
||||
interface SellingPointCard {
|
||||
title: string;
|
||||
items: string[];
|
||||
}
|
||||
|
||||
const sections: { title: string; content: string }[] = [];
|
||||
const lines = report.split('\n');
|
||||
let currentTitle = '';
|
||||
let currentContent: string[] = [];
|
||||
let hasMarkdownHeaders = report.includes('## ');
|
||||
// facilities 배열을 셀링 포인트 카드 형태로 변환
|
||||
const parseSellingPoints = (facilities: string[]): SellingPointCard[] => {
|
||||
// 기본 카테고리 정의
|
||||
const categories: SellingPointCard[] = [
|
||||
{ title: '브랜드 컨셉', items: [] },
|
||||
{ title: '프라이버시', items: [] },
|
||||
{ title: '로컬 결합', items: [] },
|
||||
{ title: '무드/비주얼', items: [] },
|
||||
{ title: '편의/신뢰', items: [] },
|
||||
{ title: '체류형 가치', items: [] },
|
||||
];
|
||||
|
||||
// 마크다운 헤더가 없는 경우 전체 텍스트를 하나의 섹션으로 반환
|
||||
if (!hasMarkdownHeaders) {
|
||||
return [{ title: '분석 결과', content: report.trim() }];
|
||||
}
|
||||
|
||||
lines.forEach((line) => {
|
||||
if (line.startsWith('## ')) {
|
||||
if (currentTitle || currentContent.length > 0) {
|
||||
sections.push({ title: currentTitle, content: currentContent.join('\n').trim() });
|
||||
}
|
||||
currentTitle = line.replace('## ', '').trim();
|
||||
currentContent = [];
|
||||
} else if (!line.startsWith('# ')) {
|
||||
currentContent.push(line);
|
||||
// facilities를 카테고리에 분배 (최대 2개씩)
|
||||
facilities.forEach((facility, idx) => {
|
||||
const categoryIdx = Math.floor(idx / 2) % categories.length;
|
||||
if (categories[categoryIdx].items.length < 2) {
|
||||
categories[categoryIdx].items.push(facility);
|
||||
}
|
||||
});
|
||||
|
||||
if (currentTitle || currentContent.length > 0) {
|
||||
sections.push({ title: currentTitle, content: currentContent.join('\n').trim() });
|
||||
}
|
||||
|
||||
return sections.filter(s => s.content && !s.title.includes('JSON'));
|
||||
// 아이템이 있는 카테고리만 반환
|
||||
return categories.filter(cat => cat.items.length > 0);
|
||||
};
|
||||
|
||||
const AnalysisResultSection: React.FC<AnalysisResultSectionProps> = ({ onBack, onGenerate, data }) => {
|
||||
const { processed_info, marketing_analysis } = data;
|
||||
const tags = marketing_analysis.tags || [];
|
||||
const facilities = marketing_analysis.facilities || [];
|
||||
const reportSections = parseReport(marketing_analysis.report);
|
||||
const sellingPoints = parseSellingPoints(facilities);
|
||||
|
||||
return (
|
||||
<div className="analysis-container">
|
||||
{/* Back Button */}
|
||||
<div className="back-button-container" style={{ marginLeft: 0 }}>
|
||||
<button onClick={onBack} className="btn-back">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<path d="M15 18l-6-6 6-6" />
|
||||
</svg>
|
||||
뒤로가기
|
||||
</button>
|
||||
</div>
|
||||
{/* Header Area */}
|
||||
<div className="analysis-header-area">
|
||||
{/* Back Button */}
|
||||
<div className="back-button-container">
|
||||
<button onClick={onBack} className="btn-back">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<path d="M15 18l-6-6 6-6" />
|
||||
</svg>
|
||||
뒤로가기
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Header */}
|
||||
<div className="analysis-header">
|
||||
<div className="analysis-icon">
|
||||
<svg className="w-8 h-8" viewBox="0 0 24 24" fill="currentColor">
|
||||
<path d="M12 2l2.4 7.2L22 12l-7.6 2.4L12 22l-2.4-7.2L2 12l7.6-2.4z" />
|
||||
</svg>
|
||||
{/* Header */}
|
||||
<div className="analysis-header">
|
||||
<div className="analysis-icon">
|
||||
<svg className="w-8 h-8" viewBox="0 0 24 24" fill="currentColor">
|
||||
<path d="M12 2l2.4 7.2L22 12l-7.6 2.4L12 22l-2.4-7.2L2 12l7.6-2.4z" />
|
||||
</svg>
|
||||
</div>
|
||||
<h1 className="page-title">브랜드 분석</h1>
|
||||
<p className="page-subtitle">
|
||||
쉽고 빠르게, 브랜드 소셜 미디어 캠페인을 만드세요.
|
||||
</p>
|
||||
</div>
|
||||
<h1 className="page-title">브랜드 분석</h1>
|
||||
<p className="page-subtitle">
|
||||
쉽고 빠르게, 브랜드 소셜 미디어 캠페인을 만드세요.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Main Content Grid */}
|
||||
<div className="analysis-grid">
|
||||
{/* Brand Identity */}
|
||||
{/* Left: Brand Identity (Scrollable) */}
|
||||
<div className="brand-identity-card">
|
||||
<div className="brand-header">
|
||||
<span className="section-title">브랜드 정체성</span>
|
||||
<span className="brand-subtitle">AI 마케팅 분석 요약</span>
|
||||
</div>
|
||||
|
||||
<div className="brand-info">
|
||||
<h2 className="brand-name">{processed_info.customer_name}</h2>
|
||||
<p className="brand-location">{processed_info.region} · {processed_info.detail_region_info}</p>
|
||||
</div>
|
||||
<div className="brand-content">
|
||||
<div className="brand-info">
|
||||
<h2 className="brand-name">{processed_info.customer_name}</h2>
|
||||
<p className="brand-location">{processed_info.detail_region_info}</p>
|
||||
</div>
|
||||
|
||||
{/* Marketing Analysis Summary */}
|
||||
<div className="report-section">
|
||||
<div className="report-content custom-scrollbar">
|
||||
{reportSections.length === 0 ? (
|
||||
<div>
|
||||
{marketing_analysis.report
|
||||
? formatReportText(marketing_analysis.report)
|
||||
: '분석 결과가 없습니다.'}
|
||||
</div>
|
||||
) : (
|
||||
<div className="report-sections">
|
||||
{reportSections.map((section, idx) => (
|
||||
<div key={idx}>
|
||||
{section.title && <h4 className="report-section-title">{section.title}</h4>}
|
||||
<div>
|
||||
{formatReportText(section.content)}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<div className="report-content">
|
||||
{marketing_analysis.report
|
||||
? formatReportText(marketing_analysis.report)
|
||||
: '분석 결과가 없습니다.'}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{/* Right Cards */}
|
||||
{/* Right: Selling Points & Keywords (Fixed) */}
|
||||
<div className="analysis-cards-column">
|
||||
{/* Main Selling Points (Facilities) */}
|
||||
<div className="feature-card">
|
||||
<span className="section-title-purple">주요 셀링 포인트</span>
|
||||
<div className="tags-wrapper">
|
||||
{facilities.map((facility, idx) => (
|
||||
<span key={idx} className="feature-tag">
|
||||
{facility}
|
||||
</span>
|
||||
{/* Main Selling Points */}
|
||||
<div className="feature-card selling-points-card">
|
||||
<span className="section-title">주요 셀링 포인트</span>
|
||||
<div className="selling-points-grid">
|
||||
{sellingPoints.map((point, idx) => (
|
||||
<div key={idx} className="selling-point-item">
|
||||
<span className="selling-point-title">{point.title}</span>
|
||||
<div className="selling-point-content">
|
||||
{point.items.map((item, itemIdx) => (
|
||||
<p key={itemIdx}>{item}</p>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Recommended Target Keywords (Tags) */}
|
||||
<div className="feature-card">
|
||||
{/* Recommended Target Keywords */}
|
||||
<div className="feature-card keywords-card">
|
||||
<span className="section-title">추천 타겟 키워드</span>
|
||||
<div className="tags-wrapper">
|
||||
{tags.map((tag, idx) => (
|
||||
|
||||
@@ -6,12 +6,17 @@ import SoundStudioContent from './SoundStudioContent';
|
||||
import CompletionContent from './CompletionContent';
|
||||
import DashboardContent from './DashboardContent';
|
||||
import BusinessSettingsContent from './BusinessSettingsContent';
|
||||
import { ImageItem } from '../../types/api';
|
||||
import UrlInputContent from './UrlInputContent';
|
||||
import LoadingSection from '../Analysis/LoadingSection';
|
||||
import AnalysisResultSection from '../Analysis/AnalysisResultSection';
|
||||
import { ImageItem, CrawlingResponse } from '../../types/api';
|
||||
import { crawlUrl } from '../../utils/api';
|
||||
|
||||
const WIZARD_STEP_KEY = 'castad_wizard_step';
|
||||
const ACTIVE_ITEM_KEY = 'castad_active_item';
|
||||
const SONG_TASK_ID_KEY = 'castad_song_task_id';
|
||||
const IMAGE_TASK_ID_KEY = 'castad_image_task_id';
|
||||
const ANALYSIS_DATA_KEY = 'castad_analysis_data';
|
||||
|
||||
// 다른 컴포넌트에서 사용하는 storage key들 (초기화용)
|
||||
const SONG_GENERATION_KEY = 'castad_song_generation';
|
||||
@@ -37,27 +42,82 @@ interface GenerationFlowProps {
|
||||
initialActiveItem?: string;
|
||||
initialImageList?: string[];
|
||||
businessInfo?: BusinessInfo;
|
||||
initialAnalysisData?: CrawlingResponse | null;
|
||||
}
|
||||
|
||||
const GenerationFlow: React.FC<GenerationFlowProps> = ({ onHome, initialActiveItem = '대시보드', initialImageList = [], businessInfo }) => {
|
||||
// 위저드 단계:
|
||||
// -2: URL 입력
|
||||
// -1: 로딩 (분석 중)
|
||||
// 0: 브랜드 분석 결과
|
||||
// 1: 에셋 관리 (Asset Management)
|
||||
// 2: 사운드 스튜디오 (Sound Studio)
|
||||
// 3: 완료 (Completion)
|
||||
|
||||
const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
onHome,
|
||||
initialActiveItem = '대시보드',
|
||||
initialImageList = [],
|
||||
businessInfo,
|
||||
initialAnalysisData
|
||||
}) => {
|
||||
// localStorage에서 저장된 상태 복원
|
||||
const savedActiveItem = localStorage.getItem(ACTIVE_ITEM_KEY);
|
||||
const savedWizardStep = localStorage.getItem(WIZARD_STEP_KEY);
|
||||
const savedSongTaskId = localStorage.getItem(SONG_TASK_ID_KEY);
|
||||
const savedImageTaskId = localStorage.getItem(IMAGE_TASK_ID_KEY);
|
||||
const savedAnalysisData = localStorage.getItem(ANALYSIS_DATA_KEY);
|
||||
|
||||
// 분석 데이터 파싱
|
||||
const parseAnalysisData = (): CrawlingResponse | null => {
|
||||
if (initialAnalysisData) return initialAnalysisData;
|
||||
if (!savedAnalysisData) return null;
|
||||
try {
|
||||
return JSON.parse(savedAnalysisData) as CrawlingResponse;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const [activeItem, setActiveItem] = useState(savedActiveItem || initialActiveItem);
|
||||
// 현재 위저드 단계 (0: Asset, 1: Sound Studio, 2: Completion)
|
||||
const [wizardStep, setWizardStep] = useState(savedWizardStep ? parseInt(savedWizardStep, 10) : 0);
|
||||
|
||||
// 초기 위저드 단계 결정
|
||||
const getInitialWizardStep = (): number => {
|
||||
// 저장된 단계가 있으면 사용
|
||||
if (savedWizardStep !== null) {
|
||||
return parseInt(savedWizardStep, 10);
|
||||
}
|
||||
// 분석 데이터가 있으면 에셋 관리(1)부터, 없으면 URL 입력(-2)부터
|
||||
const hasAnalysisData = initialAnalysisData || savedAnalysisData;
|
||||
return hasAnalysisData ? 1 : -2;
|
||||
};
|
||||
|
||||
const [wizardStep, setWizardStep] = useState(getInitialWizardStep());
|
||||
const [songTaskId, setSongTaskId] = useState<string | null>(savedSongTaskId);
|
||||
const [imageTaskId, setImageTaskId] = useState<string | null>(savedImageTaskId);
|
||||
const [videoGenerationStatus, setVideoGenerationStatus] = useState<'idle' | 'generating' | 'complete' | 'error'>('idle');
|
||||
const [videoGenerationProgress, setVideoGenerationProgress] = useState(0);
|
||||
const [analysisData, setAnalysisData] = useState<CrawlingResponse | null>(parseAnalysisData());
|
||||
const [analysisError, setAnalysisError] = useState<string | null>(null);
|
||||
|
||||
// 현재 비즈니스 정보 (분석 데이터에서 가져오거나 prop에서 가져옴)
|
||||
const currentBusinessInfo = analysisData?.processed_info || businessInfo;
|
||||
|
||||
// URL 이미지를 ImageItem 형태로 변환하여 초기화
|
||||
const [imageList, setImageList] = useState<ImageItem[]>(
|
||||
initialImageList.map(url => ({ type: 'url', url }))
|
||||
);
|
||||
const getInitialImageList = (): ImageItem[] => {
|
||||
if (analysisData?.image_list && analysisData.image_list.length > 0) {
|
||||
return analysisData.image_list.map(url => ({ type: 'url', url }));
|
||||
}
|
||||
return initialImageList.map(url => ({ type: 'url', url }));
|
||||
};
|
||||
|
||||
const [imageList, setImageList] = useState<ImageItem[]>(getInitialImageList());
|
||||
|
||||
// analysisData 변경 시 imageList 업데이트
|
||||
useEffect(() => {
|
||||
if (analysisData?.image_list && analysisData.image_list.length > 0) {
|
||||
setImageList(analysisData.image_list.map(url => ({ type: 'url', url })));
|
||||
}
|
||||
}, [analysisData]);
|
||||
|
||||
const handleRemoveImage = (index: number) => {
|
||||
setImageList(prev => {
|
||||
@@ -83,10 +143,12 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({ onHome, initialActiveIt
|
||||
// 홈 버튼(로고) 클릭 시 모든 상태 초기화 후 홈으로 이동
|
||||
const handleHome = () => {
|
||||
clearAllProjectStorage();
|
||||
setWizardStep(0);
|
||||
localStorage.removeItem(ANALYSIS_DATA_KEY);
|
||||
setWizardStep(-2);
|
||||
setSongTaskId(null);
|
||||
setImageTaskId(null);
|
||||
setImageList(initialImageList.map(url => ({ type: 'url', url })));
|
||||
setAnalysisData(null);
|
||||
setImageList([]);
|
||||
onHome();
|
||||
};
|
||||
|
||||
@@ -96,6 +158,50 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({ onHome, initialActiveIt
|
||||
localStorage.setItem(WIZARD_STEP_KEY, step.toString());
|
||||
};
|
||||
|
||||
// URL 분석 시작
|
||||
const handleStartAnalysis = async (url: string) => {
|
||||
if (!url.trim()) return;
|
||||
|
||||
goToWizardStep(-1); // 로딩 상태로
|
||||
setAnalysisError(null);
|
||||
|
||||
try {
|
||||
const data = await crawlUrl(url);
|
||||
|
||||
// 기본값 보장
|
||||
if (data.marketing_analysis) {
|
||||
data.marketing_analysis.tags = data.marketing_analysis.tags || [];
|
||||
data.marketing_analysis.facilities = data.marketing_analysis.facilities || [];
|
||||
data.marketing_analysis.report = data.marketing_analysis.report || '';
|
||||
}
|
||||
if (data.processed_info) {
|
||||
data.processed_info.customer_name = data.processed_info.customer_name || '알 수 없음';
|
||||
data.processed_info.region = data.processed_info.region || '';
|
||||
data.processed_info.detail_region_info = data.processed_info.detail_region_info || '';
|
||||
}
|
||||
data.image_list = data.image_list || [];
|
||||
|
||||
setAnalysisData(data);
|
||||
localStorage.setItem(ANALYSIS_DATA_KEY, JSON.stringify(data));
|
||||
goToWizardStep(0); // 브랜드 분석 결과로
|
||||
} catch (err) {
|
||||
console.error('Crawling failed:', err);
|
||||
const errorMessage = err instanceof Error ? err.message : '분석 중 오류가 발생했습니다. 다시 시도해주세요.';
|
||||
setAnalysisError(errorMessage);
|
||||
goToWizardStep(-2); // URL 입력으로 돌아가기
|
||||
}
|
||||
};
|
||||
|
||||
// 브랜드 분석에서 콘텐츠 생성 클릭
|
||||
const handleAnalysisGenerate = () => {
|
||||
goToWizardStep(1); // 에셋 관리로
|
||||
};
|
||||
|
||||
// 브랜드 분석에서 뒤로가기
|
||||
const handleAnalysisBack = () => {
|
||||
goToWizardStep(-2); // URL 입력으로
|
||||
};
|
||||
|
||||
// activeItem 변경 시 localStorage에 저장
|
||||
useEffect(() => {
|
||||
localStorage.setItem(ACTIVE_ITEM_KEY, activeItem);
|
||||
@@ -104,7 +210,31 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({ onHome, initialActiveIt
|
||||
// 새 프로젝트 만들기 - 단계별 컨텐츠 렌더링
|
||||
const renderWizardContent = () => {
|
||||
switch (wizardStep) {
|
||||
case -2:
|
||||
// URL 입력 단계
|
||||
return (
|
||||
<UrlInputContent
|
||||
onAnalyze={handleStartAnalysis}
|
||||
error={analysisError}
|
||||
/>
|
||||
);
|
||||
case -1:
|
||||
// 로딩 단계
|
||||
return <LoadingSection />;
|
||||
case 0:
|
||||
// 브랜드 분석 결과 단계
|
||||
if (!analysisData) {
|
||||
goToWizardStep(-2);
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<AnalysisResultSection
|
||||
onBack={handleAnalysisBack}
|
||||
onGenerate={handleAnalysisGenerate}
|
||||
data={analysisData}
|
||||
/>
|
||||
);
|
||||
case 1:
|
||||
return (
|
||||
<AssetManagementContent
|
||||
onNext={(taskId: string) => {
|
||||
@@ -115,32 +245,32 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({ onHome, initialActiveIt
|
||||
|
||||
setImageTaskId(taskId);
|
||||
localStorage.setItem(IMAGE_TASK_ID_KEY, taskId);
|
||||
goToWizardStep(1);
|
||||
goToWizardStep(2);
|
||||
}}
|
||||
imageList={imageList}
|
||||
onRemoveImage={handleRemoveImage}
|
||||
onAddImages={handleAddImages}
|
||||
/>
|
||||
);
|
||||
case 1:
|
||||
case 2:
|
||||
return (
|
||||
<SoundStudioContent
|
||||
onBack={() => goToWizardStep(0)}
|
||||
onBack={() => goToWizardStep(1)}
|
||||
onNext={(taskId: string) => {
|
||||
setSongTaskId(taskId);
|
||||
localStorage.setItem(SONG_TASK_ID_KEY, taskId);
|
||||
goToWizardStep(2);
|
||||
goToWizardStep(3);
|
||||
}}
|
||||
businessInfo={businessInfo}
|
||||
businessInfo={currentBusinessInfo}
|
||||
imageTaskId={imageTaskId}
|
||||
videoGenerationStatus={videoGenerationStatus}
|
||||
videoGenerationProgress={videoGenerationProgress}
|
||||
/>
|
||||
);
|
||||
case 2:
|
||||
case 3:
|
||||
return (
|
||||
<CompletionContent
|
||||
onBack={() => goToWizardStep(1)}
|
||||
onBack={() => goToWizardStep(2)}
|
||||
songTaskId={songTaskId}
|
||||
onVideoStatusChange={setVideoGenerationStatus}
|
||||
onVideoProgressChange={setVideoGenerationProgress}
|
||||
@@ -158,6 +288,10 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({ onHome, initialActiveIt
|
||||
case '비즈니스 설정':
|
||||
return <BusinessSettingsContent />;
|
||||
case '새 프로젝트 만들기':
|
||||
// 브랜드 분석(0)과 로딩(-1)은 전체 화면으로 표시
|
||||
if (wizardStep === 0 || wizardStep === -1) {
|
||||
return renderWizardContent();
|
||||
}
|
||||
return (
|
||||
<div className="wizard-page-container">
|
||||
{renderWizardContent()}
|
||||
@@ -172,10 +306,34 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({ onHome, initialActiveIt
|
||||
}
|
||||
};
|
||||
|
||||
// 로딩 화면에서만 Sidebar 숨김
|
||||
const showSidebar = wizardStep !== -1;
|
||||
|
||||
// 브랜드 분석(0)일 때는 전체 페이지 스크롤
|
||||
const isBrandAnalysis = activeItem === '새 프로젝트 만들기' && wizardStep === 0;
|
||||
// 스크롤이 필요한 페이지: 대시보드, 비즈니스 설정, 브랜드 분석(0)
|
||||
const needsScroll = activeItem === '대시보드' || activeItem === '비즈니스 설정' || isBrandAnalysis;
|
||||
|
||||
// 브랜드 분석일 때는 높이 제한 없이 자연 스크롤
|
||||
if (isBrandAnalysis) {
|
||||
return (
|
||||
<div className="flex w-full bg-[#0d1416] text-white">
|
||||
{showSidebar && (
|
||||
<Sidebar activeItem={activeItem} onNavigate={setActiveItem} onHome={handleHome} />
|
||||
)}
|
||||
<div className="flex-1 relative">
|
||||
{renderContent()}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={`flex w-full bg-[#0d1416] text-white ${activeItem === '대시보드' || activeItem === '비즈니스 설정' ? 'min-h-[100dvh]' : 'h-[100dvh] overflow-hidden'}`}>
|
||||
<Sidebar activeItem={activeItem} onNavigate={setActiveItem} onHome={handleHome} />
|
||||
<div className={`flex-1 relative pl-0 md:pl-0 ${activeItem === '대시보드' || activeItem === '비즈니스 설정' ? 'overflow-y-auto' : 'h-full overflow-hidden'}`}>
|
||||
<div className={`flex w-full bg-[#0d1416] text-white ${needsScroll ? 'min-h-[100dvh]' : 'h-[100dvh] overflow-hidden'}`}>
|
||||
{showSidebar && (
|
||||
<Sidebar activeItem={activeItem} onNavigate={setActiveItem} onHome={handleHome} />
|
||||
)}
|
||||
<div className={`flex-1 relative pl-0 md:pl-0 ${needsScroll ? 'overflow-y-auto' : 'h-full overflow-hidden'}`}>
|
||||
{renderContent()}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
|
||||
import React, { useState } from 'react';
|
||||
|
||||
interface UrlInputContentProps {
|
||||
onAnalyze: (url: string) => void;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
const UrlInputContent: React.FC<UrlInputContentProps> = ({ onAnalyze, error }) => {
|
||||
const [url, setUrl] = useState('');
|
||||
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (url.trim()) {
|
||||
onAnalyze(url.trim());
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="url-input-container">
|
||||
<div className="url-input-content">
|
||||
{/* 아이콘 */}
|
||||
<div className="url-input-icon">
|
||||
<svg width="40" height="40" viewBox="0 0 24 24" fill="currentColor">
|
||||
<path d="M12 2l2.4 7.2L22 12l-7.6 2.4L12 22l-2.4-7.2L2 12l7.6-2.4z" />
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
{/* 제목 */}
|
||||
<h1 className="url-input-title">브랜드 분석</h1>
|
||||
<p className="url-input-subtitle">
|
||||
쉽고 빠르게, 브랜드 소셜 미디어 캠페인을 만드세요.
|
||||
</p>
|
||||
|
||||
{/* URL 입력 폼 */}
|
||||
<form onSubmit={handleSubmit} className="url-input-form">
|
||||
<div className="url-input-wrapper">
|
||||
<input
|
||||
type="url"
|
||||
value={url}
|
||||
onChange={(e) => setUrl(e.target.value)}
|
||||
placeholder="네이버 지도 URL을 입력하세요"
|
||||
className="url-input-field"
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={!url.trim()}
|
||||
className="url-input-button"
|
||||
>
|
||||
분석 시작
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* 에러 메시지 */}
|
||||
{error && (
|
||||
<p className="url-input-error">{error}</p>
|
||||
)}
|
||||
</form>
|
||||
|
||||
{/* 안내 텍스트 */}
|
||||
<p className="url-input-guide">
|
||||
네이버 지도에서 업체 URL을 복사하여 붙여넣기 해주세요.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default UrlInputContent;
|
||||
@@ -50,6 +50,7 @@ const orbConfigs: OrbConfig[] = [
|
||||
const HeroSection: React.FC<HeroSectionProps> = ({ onAnalyze, onNext, error: externalError, scrollProgress = 0 }) => {
|
||||
const [url, setUrl] = useState('');
|
||||
const [localError, setLocalError] = useState('');
|
||||
const [isFocused, setIsFocused] = useState(false);
|
||||
const orbRefs = useRef<(HTMLDivElement | null)[]>([]);
|
||||
const animationRefs = useRef<number[]>([]);
|
||||
|
||||
@@ -174,8 +175,8 @@ const HeroSection: React.FC<HeroSectionProps> = ({ onAnalyze, onNext, error: ext
|
||||
<div className="hero-content">
|
||||
{/* Logo Image */}
|
||||
<img
|
||||
src="/assets/images/castad-logo-large.svg"
|
||||
alt="CASTAD"
|
||||
src="/assets/images/ado2-logo.svg"
|
||||
alt="ADO2"
|
||||
className="hero-logo"
|
||||
/>
|
||||
|
||||
@@ -183,7 +184,7 @@ const HeroSection: React.FC<HeroSectionProps> = ({ onAnalyze, onNext, error: ext
|
||||
{/* Input Form */}
|
||||
<div className="hero-form">
|
||||
<span className="hero-input-label">URL 입력</span>
|
||||
<div className="hero-input-wrapper">
|
||||
<div className={`hero-input-wrapper ${isFocused ? 'focused' : ''} ${error ? 'error' : ''} ${url && !isFocused ? 'filled' : ''}`}>
|
||||
<input
|
||||
type="text"
|
||||
value={url}
|
||||
@@ -191,9 +192,23 @@ const HeroSection: React.FC<HeroSectionProps> = ({ onAnalyze, onNext, error: ext
|
||||
setUrl(e.target.value);
|
||||
if (localError) setLocalError('');
|
||||
}}
|
||||
onFocus={() => setIsFocused(true)}
|
||||
onBlur={() => setIsFocused(false)}
|
||||
placeholder="https://www.castad.com"
|
||||
className={`hero-input ${error ? 'error' : ''}`}
|
||||
className={`hero-input ${url ? 'has-value' : ''}`}
|
||||
/>
|
||||
{url && (
|
||||
<button
|
||||
type="button"
|
||||
className="hero-input-clear"
|
||||
onClick={() => {
|
||||
setUrl('');
|
||||
setLocalError('');
|
||||
}}
|
||||
>
|
||||
<img src="/assets/images/input-clear-icon.svg" alt="Clear" />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<span className="hero-input-hint">URL에서 가져온 정보로 영상이 자동 생성됩니다.</span>
|
||||
{error && (
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
import React from 'react';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { getKakaoLoginUrl, kakaoCallback } from '../../utils/api';
|
||||
|
||||
interface LoginSectionProps {
|
||||
onBack: () => void;
|
||||
@@ -7,10 +8,66 @@ interface LoginSectionProps {
|
||||
}
|
||||
|
||||
const LoginSection: React.FC<LoginSectionProps> = ({ onBack, onLogin }) => {
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
// 카카오 콜백 처리 (URL에서 code 파라미터 확인)
|
||||
useEffect(() => {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const code = urlParams.get('code');
|
||||
|
||||
if (code) {
|
||||
handleKakaoCallback(code);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const handleKakaoCallback = async (code: string) => {
|
||||
setIsLoading(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
await kakaoCallback(code);
|
||||
|
||||
// URL에서 code 파라미터 제거
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.delete('code');
|
||||
window.history.replaceState({}, document.title, url.pathname);
|
||||
|
||||
// 로그인 성공
|
||||
onLogin();
|
||||
} catch (err) {
|
||||
console.error('Kakao callback failed:', err);
|
||||
setError('카카오 로그인에 실패했습니다. 다시 시도해주세요.');
|
||||
|
||||
// URL에서 code 파라미터 제거
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.delete('code');
|
||||
window.history.replaceState({}, document.title, url.pathname);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleKakaoLogin = async () => {
|
||||
setIsLoading(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
const response = await getKakaoLoginUrl();
|
||||
|
||||
// 카카오 로그인 페이지로 리다이렉트
|
||||
window.location.href = response.auth_url;
|
||||
} catch (err) {
|
||||
console.error('Failed to get Kakao login URL:', err);
|
||||
setError('로그인 URL을 가져오는데 실패했습니다. 다시 시도해주세요.');
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="login-container">
|
||||
{/* Back Button */}
|
||||
<button onClick={onBack} className="login-back-btn">
|
||||
<button onClick={onBack} className="login-back-btn" disabled={isLoading}>
|
||||
<img src="/assets/images/icon-back.svg" alt="Back" />
|
||||
<span>뒤로가기</span>
|
||||
</button>
|
||||
@@ -21,9 +78,20 @@ const LoginSection: React.FC<LoginSectionProps> = ({ onBack, onLogin }) => {
|
||||
<img src="/assets/images/login-logo.svg" alt="CASTAD" />
|
||||
</div>
|
||||
|
||||
{/* Error Message */}
|
||||
{error && (
|
||||
<div className="login-error">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Kakao Login Button */}
|
||||
<button onClick={onLogin} className="btn-kakao">
|
||||
카카오로 시작하기
|
||||
<button
|
||||
onClick={handleKakaoLogin}
|
||||
className="btn-kakao"
|
||||
disabled={isLoading}
|
||||
>
|
||||
{isLoading ? '로그인 중...' : '카카오로 시작하기'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user