Merge branch 'main' into feature-dashboard
This commit is contained in:
commit
eceea6a5a4
18 files changed
+679
-721
No files matched your search
@@ -1,7 +1,8 @@
|
||||
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { CrawlingResponse, TargetPersona, SellingPoint } from '../../types/api';
|
||||
import { CrawlingResponse, TargetPersona } from '../../types/api';
|
||||
import { GeometricChart } from './GeometricChart';
|
||||
|
||||
interface AnalysisResultSectionProps {
|
||||
onBack: () => void;
|
||||
@@ -9,200 +10,9 @@ interface AnalysisResultSectionProps {
|
||||
data: CrawlingResponse;
|
||||
}
|
||||
|
||||
// 레이더 차트 컴포넌트
|
||||
interface RadarChartProps {
|
||||
data: SellingPoint[];
|
||||
size?: number;
|
||||
}
|
||||
|
||||
const RadarChart: React.FC<RadarChartProps> = ({ data, size = 360 }) => {
|
||||
const [animatedScores, setAnimatedScores] = useState<number[]>(data.map(() => 0));
|
||||
const [isAnimating, setIsAnimating] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
const targetScores = data.map(item => item.score);
|
||||
const duration = 1500;
|
||||
const startTime = Date.now();
|
||||
|
||||
const animate = () => {
|
||||
const elapsed = Date.now() - startTime;
|
||||
const progress = Math.min(elapsed / duration, 1);
|
||||
const easeProgress = 1 - Math.pow(1 - progress, 3);
|
||||
|
||||
const newScores = targetScores.map(target => target * easeProgress);
|
||||
setAnimatedScores(newScores);
|
||||
|
||||
if (progress < 1) {
|
||||
requestAnimationFrame(animate);
|
||||
} else {
|
||||
setIsAnimating(false);
|
||||
}
|
||||
};
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}, [data]);
|
||||
|
||||
const padding = 80;
|
||||
const center = size / 2 + padding;
|
||||
const maxRadius = size / 2 - 20;
|
||||
const levels = 5;
|
||||
const angleStep = (2 * Math.PI) / data.length;
|
||||
|
||||
const getPoint = (index: number, score: number) => {
|
||||
const angle = angleStep * index - Math.PI / 2;
|
||||
const radius = (score / 100) * maxRadius;
|
||||
return {
|
||||
x: center + radius * Math.cos(angle),
|
||||
y: center + radius * Math.sin(angle),
|
||||
};
|
||||
};
|
||||
|
||||
const dataPoints = animatedScores.map((score, i) => getPoint(i, score));
|
||||
const dataPath = dataPoints.map((p, i) => (i === 0 ? `M ${p.x} ${p.y}` : `L ${p.x} ${p.y}`)).join(' ') + ' Z';
|
||||
|
||||
const levelPaths = Array.from({ length: levels }, (_, levelIndex) => {
|
||||
const levelRadius = ((levelIndex + 1) / levels) * maxRadius;
|
||||
const points = data.map((_, i) => {
|
||||
const angle = angleStep * i - Math.PI / 2;
|
||||
return {
|
||||
x: center + levelRadius * Math.cos(angle),
|
||||
y: center + levelRadius * Math.sin(angle),
|
||||
};
|
||||
});
|
||||
return points.map((p, i) => (i === 0 ? `M ${p.x} ${p.y}` : `L ${p.x} ${p.y}`)).join(' ') + ' Z';
|
||||
});
|
||||
|
||||
const axisLines = data.map((_, i) => {
|
||||
const angle = angleStep * i - Math.PI / 2;
|
||||
const endX = center + maxRadius * Math.cos(angle);
|
||||
const endY = center + maxRadius * Math.sin(angle);
|
||||
return `M ${center} ${center} L ${endX} ${endY}`;
|
||||
});
|
||||
|
||||
const svgSize = size + padding * 2;
|
||||
|
||||
// 순위별로 정렬하여 라벨 위치에 순위 번호 배치
|
||||
const sortedIndices = [...data]
|
||||
.map((item, i) => ({ index: i, score: item.score }))
|
||||
.sort((a, b) => b.score - a.score)
|
||||
.map((item, rank) => ({ ...item, rank: rank + 1 }));
|
||||
|
||||
const rankMap = new Map<number, number>();
|
||||
sortedIndices.forEach(item => rankMap.set(item.index, item.rank));
|
||||
|
||||
return (
|
||||
<div className="bi2-radar-container">
|
||||
<svg
|
||||
width={svgSize}
|
||||
height={svgSize}
|
||||
viewBox={`0 0 ${svgSize} ${svgSize}`}
|
||||
style={{ overflow: 'visible' }}
|
||||
>
|
||||
{levelPaths.map((path, i) => (
|
||||
<path
|
||||
key={`level-${i}`}
|
||||
d={path}
|
||||
fill="none"
|
||||
stroke="rgba(255,255,255,0.2)"
|
||||
strokeWidth="1"
|
||||
/>
|
||||
))}
|
||||
|
||||
{axisLines.map((path, i) => (
|
||||
<path
|
||||
key={`axis-${i}`}
|
||||
d={path}
|
||||
fill="none"
|
||||
stroke="rgba(255,255,255,0.2)"
|
||||
strokeWidth="1"
|
||||
/>
|
||||
))}
|
||||
|
||||
<path
|
||||
d={dataPath}
|
||||
fill="rgba(45, 212, 191, 0.2)"
|
||||
stroke="#2DD4BF"
|
||||
strokeWidth="2"
|
||||
style={{
|
||||
transition: isAnimating ? 'none' : 'd 0.3s ease-out',
|
||||
}}
|
||||
/>
|
||||
|
||||
{dataPoints.map((point, i) => (
|
||||
<circle
|
||||
key={`point-${i}`}
|
||||
cx={point.x}
|
||||
cy={point.y}
|
||||
r="4"
|
||||
fill="#2DD4BF"
|
||||
stroke="#1A1A2E"
|
||||
strokeWidth="2"
|
||||
/>
|
||||
))}
|
||||
|
||||
{data.map((item, i) => {
|
||||
const angle = angleStep * i - Math.PI / 2;
|
||||
const labelRadius = maxRadius + 40;
|
||||
const pos = {
|
||||
x: center + labelRadius * Math.cos(angle),
|
||||
y: center + labelRadius * Math.sin(angle),
|
||||
};
|
||||
const rank = rankMap.get(i) || i + 1;
|
||||
const isTopThree = rank <= 3;
|
||||
|
||||
return (
|
||||
<g key={`label-${i}`}>
|
||||
<g transform={`translate(${pos.x}, ${pos.y})`}>
|
||||
<rect
|
||||
x="-10"
|
||||
y="-10"
|
||||
width="20"
|
||||
height="20"
|
||||
rx="4"
|
||||
fill={isTopThree ? '#94FBE0' : '#206764'}
|
||||
/>
|
||||
<text
|
||||
x="0"
|
||||
y="0"
|
||||
textAnchor="middle"
|
||||
dominantBaseline="central"
|
||||
style={{
|
||||
fontSize: '12px',
|
||||
fontWeight: 600,
|
||||
fill: isTopThree ? '#002224' : '#94FBE0',
|
||||
fontFamily: 'Pretendard',
|
||||
}}
|
||||
>
|
||||
{rank}
|
||||
</text>
|
||||
<text
|
||||
x="16"
|
||||
y="0"
|
||||
textAnchor="start"
|
||||
dominantBaseline="central"
|
||||
style={{
|
||||
fontSize: '14px',
|
||||
fontWeight: 400,
|
||||
fill: '#E5F1F2',
|
||||
fontFamily: 'Pretendard',
|
||||
}}
|
||||
>
|
||||
{item.korean_category}
|
||||
</text>
|
||||
</g>
|
||||
</g>
|
||||
);
|
||||
})}
|
||||
</svg>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const AnalysisResultSection: React.FC<AnalysisResultSectionProps> = ({ onBack, onGenerate, data }) => {
|
||||
const { t } = useTranslation();
|
||||
const { processed_info, marketing_analysis } = data;
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const [buttonPosition, setButtonPosition] = useState({ left: 0, width: 0 });
|
||||
|
||||
const brandIdentity = marketing_analysis?.brand_identity;
|
||||
const marketPositioning = marketing_analysis?.market_positioning;
|
||||
@@ -213,26 +23,6 @@ const AnalysisResultSection: React.FC<AnalysisResultSectionProps> = ({ onBack, o
|
||||
// 셀링 포인트를 score 내림차순으로 정렬
|
||||
const sortedSellingPoints = [...sellingPoints].sort((a, b) => b.score - a.score);
|
||||
|
||||
useEffect(() => {
|
||||
const updateButtonPosition = () => {
|
||||
if (containerRef.current) {
|
||||
const rect = containerRef.current.getBoundingClientRect();
|
||||
setButtonPosition({ left: rect.left, width: rect.width });
|
||||
}
|
||||
};
|
||||
|
||||
updateButtonPosition();
|
||||
window.addEventListener('resize', updateButtonPosition);
|
||||
|
||||
const observer = new MutationObserver(updateButtonPosition);
|
||||
observer.observe(document.body, { attributes: true, subtree: true, attributeFilter: ['class'] });
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('resize', updateButtonPosition);
|
||||
observer.disconnect();
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="bi2-page">
|
||||
{/* Header */}
|
||||
@@ -253,13 +43,15 @@ const AnalysisResultSection: React.FC<AnalysisResultSectionProps> = ({ onBack, o
|
||||
<div className="bi2-title-text">
|
||||
<h1 className="bi2-main-title">{t('analysis.pageTitle')}</h1>
|
||||
<p className="bi2-subtitle">
|
||||
{t('analysis.pageDescHighlight')}{t('analysis.pageDescBefore')}{processed_info?.customer_name || t('analysis.defaultBrandName')}{t('analysis.pageDescAfter')}
|
||||
<span style={{ color: 'var(--Color-mint-500, #94FBE0)' }}>{t('analysis.pageDescHighlight')}</span>{t('analysis.pageDescBefore')}{processed_info?.customer_name || t('analysis.defaultBrandName')}{t('analysis.pageDescAfter')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr className="bi2-page-divider" />
|
||||
|
||||
{/* Main Content Container */}
|
||||
<div ref={containerRef} className="bi2-main-container">
|
||||
<div className="bi2-main-container">
|
||||
{/* 매장명 & 주소 */}
|
||||
<div className="bi2-store-header">
|
||||
<h2 className="bi2-store-name">{processed_info?.customer_name || t('analysis.brandNameFallback')}</h2>
|
||||
@@ -298,7 +90,7 @@ const AnalysisResultSection: React.FC<AnalysisResultSectionProps> = ({ onBack, o
|
||||
{/* 레이더 차트 */}
|
||||
<div className="bi2-selling-chart">
|
||||
{sellingPoints.length > 0 && (
|
||||
<RadarChart data={sellingPoints} size={360} />
|
||||
<GeometricChart data={sellingPoints} />
|
||||
)}
|
||||
</div>
|
||||
{/* 셀링 포인트 리스트 */}
|
||||
@@ -340,9 +132,11 @@ const AnalysisResultSection: React.FC<AnalysisResultSectionProps> = ({ onBack, o
|
||||
<div className="bi2-persona-divider"></div>
|
||||
<div className="bi2-persona-detail grow">
|
||||
<span className="bi2-label-xs">{t('analysis.favorKeywords', { defaultValue: '선호 키워드' })}</span>
|
||||
<p className="bi2-persona-detail-text">
|
||||
{persona.favor_target.join('\n')}
|
||||
</p>
|
||||
<div className="bi2-persona-detail-text">
|
||||
{persona.favor_target.map((item, i) => (
|
||||
<p key={i}>{item}</p>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="bi2-persona-divider"></div>
|
||||
<div className="bi2-persona-detail">
|
||||
@@ -369,13 +163,10 @@ const AnalysisResultSection: React.FC<AnalysisResultSectionProps> = ({ onBack, o
|
||||
</div>
|
||||
|
||||
{/* 콘텐츠 생성 버튼 */}
|
||||
<div
|
||||
className="fixed bottom-8 flex justify-center z-50 pointer-events-none"
|
||||
style={{ left: buttonPosition.left, width: buttonPosition.width }}
|
||||
>
|
||||
<div className="bi2-bottom-button-container">
|
||||
<button
|
||||
onClick={onGenerate}
|
||||
className="pointer-events-auto bg-brand-purple hover:bg-brand-purpleHover text-white font-bold py-3 px-12 rounded-full shadow-2xl shadow-brand-purple/40 transform hover:scale-105 transition-all duration-300 flex items-center gap-2"
|
||||
className="bi2-generate-btn"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden className="w-5 h-5">
|
||||
<path d="M12 2l2.4 6.8L22 12l-7.6 3.2L12 22l-2.4-6.8L2 12l7.6-3.2L12 2z" />
|
||||
|
||||
@@ -1,149 +1,208 @@
|
||||
import React from 'react';
|
||||
|
||||
export interface USP {
|
||||
label: string;
|
||||
subLabel: string;
|
||||
score: number;
|
||||
description: string;
|
||||
}
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { SellingPoint } from '../../types/api';
|
||||
|
||||
interface GeometricChartProps {
|
||||
data: USP[];
|
||||
data: SellingPoint[];
|
||||
}
|
||||
|
||||
export const GeometricChart: React.FC<GeometricChartProps> = ({ data }) => {
|
||||
const size = 500;
|
||||
const [animatedScores, setAnimatedScores] = useState<number[]>(data.map(() => 0));
|
||||
|
||||
useEffect(() => {
|
||||
const targetScores = data.map(item => item.score);
|
||||
const duration = 1500;
|
||||
const startTime = Date.now();
|
||||
|
||||
const animate = () => {
|
||||
const elapsed = Date.now() - startTime;
|
||||
const progress = Math.min(elapsed / duration, 1);
|
||||
const easeProgress = 1 - Math.pow(1 - progress, 3);
|
||||
setAnimatedScores(targetScores.map(t => t * easeProgress));
|
||||
if (progress < 1) requestAnimationFrame(animate);
|
||||
};
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}, [data]);
|
||||
|
||||
const size = 560;
|
||||
const center = size / 2;
|
||||
const radius = 110;
|
||||
const maxRadius = 160;
|
||||
const sides = data.length;
|
||||
const levels = 5;
|
||||
const angleStep = (Math.PI * 2) / sides;
|
||||
|
||||
const accentColor = "#94FBE0";
|
||||
|
||||
const getPoints = (r: number) => {
|
||||
return data.map((_, i) => {
|
||||
const angle = (Math.PI * 2 * i) / sides - Math.PI / 2;
|
||||
const x = center + r * Math.cos(angle);
|
||||
const y = center + r * Math.sin(angle);
|
||||
return `${x},${y}`;
|
||||
}).join(' ');
|
||||
};
|
||||
|
||||
const getDataPoints = () => {
|
||||
return data.map((item, i) => {
|
||||
const normalizedScore = item.score / 100;
|
||||
const r = radius * normalizedScore;
|
||||
const angle = (Math.PI * 2 * i) / sides - Math.PI / 2;
|
||||
const x = center + r * Math.cos(angle);
|
||||
const y = center + r * Math.sin(angle);
|
||||
return `${x},${y}`;
|
||||
}).join(' ');
|
||||
};
|
||||
|
||||
const labelRadius = radius + 55;
|
||||
const labels = data.map((item, i) => {
|
||||
const angle = (Math.PI * 2 * i) / sides - Math.PI / 2;
|
||||
const x = center + labelRadius * Math.cos(angle);
|
||||
const y = center + labelRadius * Math.sin(angle);
|
||||
|
||||
let anchor: 'start' | 'middle' | 'end' = 'middle';
|
||||
if (x < center - 20) anchor = 'end';
|
||||
if (x > center + 20) anchor = 'start';
|
||||
|
||||
return { x, y, text: item.label, sub: item.subLabel, anchor, score: item.score };
|
||||
const getAngle = (i: number) => angleStep * i - Math.PI / 2;
|
||||
const getPoint = (i: number, r: number) => ({
|
||||
x: center + r * Math.cos(getAngle(i)),
|
||||
y: center + r * Math.sin(getAngle(i)),
|
||||
});
|
||||
|
||||
// 순위 매핑
|
||||
const sortedIndices = [...data]
|
||||
.map((item, i) => ({ index: i, score: item.score }))
|
||||
.sort((a, b) => b.score - a.score)
|
||||
.map((item, rank) => ({ ...item, rank: rank + 1 }));
|
||||
const rankMap = new Map<number, number>();
|
||||
sortedIndices.forEach(item => rankMap.set(item.index, item.rank));
|
||||
|
||||
// 레벨 폴리곤
|
||||
const levelPolygons = Array.from({ length: levels }, (_, li) => {
|
||||
const r = ((li + 1) / levels) * maxRadius;
|
||||
return data.map((_, i) => {
|
||||
const p = getPoint(i, r);
|
||||
return `${p.x},${p.y}`;
|
||||
}).join(' ');
|
||||
});
|
||||
|
||||
// 데이터 폴리곤
|
||||
const dataPolygon = animatedScores.map((score, i) => {
|
||||
const r = (score / 100) * maxRadius;
|
||||
const p = getPoint(i, r);
|
||||
return `${p.x},${p.y}`;
|
||||
}).join(' ');
|
||||
|
||||
// 데이터 포인트
|
||||
const dataPoints = animatedScores.map((score, i) => {
|
||||
const r = (score / 100) * maxRadius;
|
||||
return getPoint(i, r);
|
||||
});
|
||||
|
||||
const labelRadius = maxRadius + 22;
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center py-2 relative w-full h-full">
|
||||
<svg viewBox={`0 0 ${size} ${size}`} className="w-full h-auto max-w-[500px]" style={{ overflow: 'visible' }}>
|
||||
<div className="bi2-radar-container">
|
||||
<svg
|
||||
viewBox={`0 0 ${size} ${size}`}
|
||||
style={{ overflow: 'visible', width: '440px', height: '440px' }}
|
||||
>
|
||||
<defs>
|
||||
<radialGradient id="polyGradient" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
|
||||
<stop offset="0%" stopColor={accentColor} stopOpacity="0.3" />
|
||||
<stop offset="100%" stopColor={accentColor} stopOpacity="0.05" />
|
||||
{/* 레이더 폴리곤 fill: radial gradient */}
|
||||
<radialGradient id="radar-fill-gradient" cx="280" cy="280" r="160" fx="280" fy="280" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="60%" stopColor="#034245" stopOpacity="0" />
|
||||
<stop offset="100%" stopColor="#94FBE0" stopOpacity="0.30" />
|
||||
</radialGradient>
|
||||
{/* 레이더 폴리곤 filter: outer drop-shadow + inset glow */}
|
||||
<filter id="radar-polygon-filter" x="-30%" y="-30%" width="160%" height="160%">
|
||||
{/* Outer drop shadow */}
|
||||
<feDropShadow dx="0" dy="0" stdDeviation="6" floodColor="#94FBE0" floodOpacity="0.5" result="dropShadow" />
|
||||
{/* Inset glow: invert alpha → blur → composite inside */}
|
||||
<feComponentTransfer in="SourceAlpha" result="invertedAlpha">
|
||||
<feFuncA type="linear" slope="-1" intercept="1" />
|
||||
</feComponentTransfer>
|
||||
<feGaussianBlur in="invertedAlpha" stdDeviation="6" result="blurredOuter" />
|
||||
<feComposite in="blurredOuter" in2="SourceAlpha" operator="in" result="insetMask" />
|
||||
<feFlood floodColor="#94FBE0" floodOpacity="0.5" result="insetColor" />
|
||||
<feComposite in="insetColor" in2="insetMask" operator="in" result="insetGlow" />
|
||||
<feMerge>
|
||||
<feMergeNode in="dropShadow" />
|
||||
<feMergeNode in="SourceGraphic" />
|
||||
<feMergeNode in="insetGlow" />
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="badge-glow" x="-50%" y="-50%" width="200%" height="200%">
|
||||
<feDropShadow dx="0" dy="0" stdDeviation="4" floodColor="#94FBE0" floodOpacity="0.4" />
|
||||
</filter>
|
||||
</defs>
|
||||
|
||||
{[1, 0.75, 0.5, 0.25].map((scale, i) => (
|
||||
{/* 그리드 레벨 */}
|
||||
{levelPolygons.map((points, i) => (
|
||||
<polygon
|
||||
key={i}
|
||||
points={getPoints(radius * scale)}
|
||||
key={`level-${i}`}
|
||||
points={points}
|
||||
fill="none"
|
||||
stroke={accentColor}
|
||||
strokeOpacity={0.25 - (0.02 * i)}
|
||||
stroke="rgba(255,255,255,0.2)"
|
||||
strokeWidth="1"
|
||||
strokeDasharray={i === 0 ? "0" : "4 2"}
|
||||
/>
|
||||
))}
|
||||
|
||||
{/* 축 선 */}
|
||||
{data.map((_, i) => {
|
||||
const angle = (Math.PI * 2 * i) / sides - Math.PI / 2;
|
||||
const x = center + radius * Math.cos(angle);
|
||||
const y = center + radius * Math.sin(angle);
|
||||
const p = getPoint(i, maxRadius);
|
||||
return (
|
||||
<line
|
||||
key={i}
|
||||
key={`axis-${i}`}
|
||||
x1={center}
|
||||
y1={center}
|
||||
x2={x}
|
||||
y2={y}
|
||||
stroke={accentColor}
|
||||
strokeOpacity="0.25"
|
||||
x2={p.x}
|
||||
y2={p.y}
|
||||
stroke="rgba(255,255,255,0.2)"
|
||||
strokeWidth="1"
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
||||
{/* 데이터 폴리곤 */}
|
||||
<polygon
|
||||
points={getDataPoints()}
|
||||
fill="url(#polyGradient)"
|
||||
stroke={accentColor}
|
||||
strokeWidth="2.5"
|
||||
points={dataPolygon}
|
||||
fill="url(#radar-fill-gradient)"
|
||||
stroke="var(--Color-mint-500, #94FBE0)"
|
||||
strokeWidth="2"
|
||||
strokeLinejoin="round"
|
||||
filter="url(#radar-polygon-filter)"
|
||||
/>
|
||||
|
||||
{/* 데이터 포인트 */}
|
||||
{dataPoints.map((point, i) => (
|
||||
<circle
|
||||
key={`point-${i}`}
|
||||
cx={point.x}
|
||||
cy={point.y}
|
||||
r="4"
|
||||
fill="#ffffff"
|
||||
stroke="#ffffff"
|
||||
strokeWidth="2"
|
||||
/>
|
||||
))}
|
||||
|
||||
{/* 라벨 */}
|
||||
{data.map((item, i) => {
|
||||
const normalizedScore = item.score / 100;
|
||||
const r = radius * normalizedScore;
|
||||
const angle = (Math.PI * 2 * i) / sides - Math.PI / 2;
|
||||
const x = center + r * Math.cos(angle);
|
||||
const y = center + r * Math.sin(angle);
|
||||
const isHigh = item.score >= 90;
|
||||
return (
|
||||
<g key={i}>
|
||||
{isHigh && (
|
||||
<circle cx={x} cy={y} r="10" fill={accentColor} fillOpacity="0.4" />
|
||||
)}
|
||||
<circle cx={x} cy={y} r={isHigh ? 5 : 4} fill="#fff" />
|
||||
</g>
|
||||
)
|
||||
})}
|
||||
const angle = getAngle(i);
|
||||
const pos = getPoint(i, labelRadius);
|
||||
const rank = rankMap.get(i) || i + 1;
|
||||
const isTopThree = rank <= 3;
|
||||
const isLeftSide = Math.cos(angle) < -0.1;
|
||||
const textX = isLeftSide ? -20 : 20;
|
||||
const textAnchor: 'start' | 'end' = isLeftSide ? 'end' : 'start';
|
||||
|
||||
{labels.map((l, i) => {
|
||||
const isHigh = l.score >= 90;
|
||||
return (
|
||||
<g key={i}>
|
||||
<text
|
||||
x={l.x}
|
||||
y={l.y - 7}
|
||||
textAnchor={l.anchor}
|
||||
fill={isHigh ? "#fff" : "#e2e8f0"}
|
||||
fontSize={isHigh ? "14" : "12"}
|
||||
fontWeight={isHigh ? "700" : "600"}
|
||||
className="tracking-tight"
|
||||
style={{ fontFamily: "sans-serif" }}
|
||||
>
|
||||
{l.text}
|
||||
</text>
|
||||
<text
|
||||
x={l.x}
|
||||
y={l.y + 9}
|
||||
textAnchor={l.anchor}
|
||||
fill={isHigh ? accentColor : "#94a3b8"}
|
||||
fontSize={isHigh ? "11" : "10"}
|
||||
fontWeight={isHigh ? "600" : "400"}
|
||||
className="uppercase tracking-wider"
|
||||
>
|
||||
{l.sub}
|
||||
</text>
|
||||
<g key={`label-${i}`}>
|
||||
<g transform={`translate(${pos.x}, ${pos.y})`}>
|
||||
{isLeftSide && (
|
||||
<text
|
||||
x={textX}
|
||||
y="0"
|
||||
textAnchor={textAnchor}
|
||||
dominantBaseline="central"
|
||||
className="bi2-radar-label-text"
|
||||
style={{ fontSize: '20px', fontWeight: 600, fill: '#E5F1F2', fontFamily: 'Pretendard' }}
|
||||
>
|
||||
{item.korean_category}
|
||||
</text>
|
||||
)}
|
||||
<g filter={isTopThree ? 'url(#badge-glow)' : undefined}>
|
||||
<rect x="-12.5" y="-12.5" width="25" height="25" rx="4" fill={isTopThree ? '#94FBE0' : '#206764'} />
|
||||
<text
|
||||
x="0" y="0"
|
||||
textAnchor="middle"
|
||||
dominantBaseline="central"
|
||||
style={{ fontSize: '16px', fontWeight: 600, fill: isTopThree ? '#002224' : '#94FBE0', fontFamily: 'Pretendard' }}
|
||||
>
|
||||
{rank}
|
||||
</text>
|
||||
</g>
|
||||
{!isLeftSide && (
|
||||
<text
|
||||
x={textX}
|
||||
y="0"
|
||||
textAnchor={textAnchor}
|
||||
dominantBaseline="central"
|
||||
className="bi2-radar-label-text"
|
||||
style={{ fontSize: '20px', fontWeight: 600, fill: '#E5F1F2', fontFamily: 'Pretendard' }}
|
||||
>
|
||||
{item.korean_category}
|
||||
</text>
|
||||
)}
|
||||
</g>
|
||||
</g>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -385,7 +385,7 @@ const CompletionContent: React.FC<CompletionContentProps> = ({
|
||||
<div className="comp2-info-content">
|
||||
<div className="comp2-file-info">
|
||||
<h3 className="comp2-filename">{getFileName()}</h3>
|
||||
<p className="comp2-filesize">19.6MB</p>
|
||||
{/* <p className="comp2-filesize">19.6MB</p> */}
|
||||
</div>
|
||||
<div className="comp2-meta-grid">
|
||||
<div className="comp2-meta-item">
|
||||
|
||||
@@ -615,21 +615,22 @@ const DashboardContent: React.FC<DashboardContentProps> = ({ onNavigate }) => {
|
||||
// 블러 조건: 1)계정 미연결 2)업로드 영상 없음 3)데이터 없음 4)에러 있음
|
||||
const isBlurred = accounts.length === 0 || isEmptyState || !dashboardData || !!error;
|
||||
|
||||
// API 데이터 우선 사용, 없거나 영상 없음(isEmptyState) 시 Mock 데이터로 폴백
|
||||
const contentMetrics = (!isEmptyState && dashboardData?.contentMetrics?.length) ? dashboardData.contentMetrics : MOCK_CONTENT_METRICS;
|
||||
const topContent = (!isEmptyState && dashboardData?.topContent?.length) ? dashboardData.topContent : MOCK_TOP_CONTENT;
|
||||
const hasRealAgeGroups = !isEmptyState && !!dashboardData?.audienceData?.ageGroups?.some(g => g.percentage > 0);
|
||||
const hasRealGender = !isEmptyState && ((dashboardData?.audienceData?.gender?.male ?? 0) + (dashboardData?.audienceData?.gender?.female ?? 0)) > 0;
|
||||
const hasRealTopRegions = !isEmptyState && !!dashboardData?.audienceData?.topRegions?.some(r => r.percentage > 0);
|
||||
// showMockData=true면 전체 mock 강제, 아니면 API 우선 / isEmptyState 시 mock 폴백
|
||||
const useReal = !showMockData && !isEmptyState;
|
||||
const contentMetrics = (useReal && dashboardData?.contentMetrics?.length) ? dashboardData.contentMetrics : MOCK_CONTENT_METRICS;
|
||||
const topContent = (useReal && dashboardData?.topContent?.length) ? dashboardData.topContent : MOCK_TOP_CONTENT;
|
||||
const hasRealAgeGroups = useReal && !!dashboardData?.audienceData?.ageGroups?.some(g => g.percentage > 0);
|
||||
const hasRealGender = useReal && ((dashboardData?.audienceData?.gender?.male ?? 0) + (dashboardData?.audienceData?.gender?.female ?? 0)) > 0;
|
||||
const hasRealTopRegions = useReal && !!dashboardData?.audienceData?.topRegions?.some(r => r.percentage > 0);
|
||||
const hasRealAudienceData = hasRealAgeGroups && hasRealGender && hasRealTopRegions;
|
||||
const audienceData = hasRealAudienceData ? dashboardData!.audienceData : MOCK_AUDIENCE_DATA;
|
||||
|
||||
// mode별 차트 데이터를 ChartDataPoint 통합 형식으로 변환
|
||||
const chartData: ChartDataPoint[] = mode === 'month'
|
||||
? ((!isEmptyState && dashboardData?.monthlyData?.length)
|
||||
? ((useReal && dashboardData?.monthlyData?.length)
|
||||
? dashboardData.monthlyData.map((d: MonthlyData) => ({ label: d.month, current: d.thisYear, previous: d.lastYear }))
|
||||
: MOCK_MONTHLY_DATA.map((d: MonthlyData) => ({ label: d.month, current: d.thisYear, previous: d.lastYear })))
|
||||
: ((!isEmptyState && dashboardData?.dailyData?.length)
|
||||
: ((useReal && dashboardData?.dailyData?.length)
|
||||
? dashboardData.dailyData.map((d: DailyData) => ({ label: d.date, current: d.thisPeriod, previous: d.lastPeriod }))
|
||||
: MOCK_DAILY_DATA.map((d: DailyData) => ({ label: d.date, current: d.thisPeriod, previous: d.lastPeriod })));
|
||||
|
||||
@@ -654,8 +655,8 @@ const DashboardContent: React.FC<DashboardContentProps> = ({ onNavigate }) => {
|
||||
<path d="M15 10l4.553-2.069A1 1 0 0121 8.87v6.26a1 1 0 01-1.447.899L15 14M3 8a2 2 0 012-2h10a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2V8z" strokeLinecap="round" strokeLinejoin="round" />
|
||||
</svg>
|
||||
<div>
|
||||
<p style={{ color: '#a6ffea', fontWeight: 600, marginBottom: '2px' }}>아직 업로드된 영상이 없습니다.</p>
|
||||
<p style={{ color: 'rgba(255,255,255,0.5)', fontSize: '13px' }}>ADO2에서 영상을 업로드하면 실제 통계가 표시됩니다.</p>
|
||||
<p style={{ color: '#a6ffea', fontSize: '20px', fontWeight: 600, marginBottom: '2px' }}>아직 업로드된 영상이 없습니다.</p>
|
||||
<p style={{ color: 'rgba(255,255,255,0.5)', fontSize: '16px' }}>ADO2에서 영상을 업로드하면 실제 통계가 표시됩니다.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -789,7 +790,7 @@ const DashboardContent: React.FC<DashboardContentProps> = ({ onNavigate }) => {
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<div>
|
||||
<h2 className="dashboard-section-title" style={{ marginBottom: '2px' }}>{t('dashboard.contentPerformance')}</h2>
|
||||
<p style={{ fontSize: '12px', color: 'rgba(255,255,255,0.4)', margin: 0 }}>ADO2에서 업로드한 최근 30개의 영상 통계가 표시됩니다.</p>
|
||||
<p style={{ fontSize: '14px', color: 'rgba(255,255,255,0.4)', margin: 0 }}>ADO2에서 업로드한 최근 30개의 영상 통계가 표시됩니다.</p>
|
||||
</div>
|
||||
<div className="mode-toggle">
|
||||
<button
|
||||
@@ -863,7 +864,7 @@ const DashboardContent: React.FC<DashboardContentProps> = ({ onNavigate }) => {
|
||||
<AnimatedSection delay={1000} className="audience-section">
|
||||
<div style={{ marginBottom: '16px' }}>
|
||||
<h2 className="dashboard-section-title" style={{ marginBottom: '2px' }}>{t('dashboard.audienceInsights')}</h2>
|
||||
<p style={{ fontSize: '12px', color: 'rgba(255,255,255,0.4)', margin: 0 }}>선택한 채널의 통계가 표시됩니다.</p>
|
||||
<p style={{ fontSize: '14px', color: 'rgba(255,255,255,0.4)', margin: 0 }}>선택한 채널의 통계가 표시됩니다.</p>
|
||||
</div>
|
||||
<div style={{ position: 'relative' }}>
|
||||
<div className="audience-cards" style={!hasRealAudienceData && !showMockData ? { filter: 'blur(4px)', pointerEvents: 'none', userSelect: 'none' } : {}}>
|
||||
@@ -886,7 +887,7 @@ const DashboardContent: React.FC<DashboardContentProps> = ({ onNavigate }) => {
|
||||
</div>
|
||||
</AnimatedItem>
|
||||
</div>
|
||||
{dashboardData && !isEmptyState && !hasRealAudienceData && (
|
||||
{dashboardData && !isEmptyState && !hasRealAudienceData && !showMockData && (
|
||||
<div style={{ position: 'absolute', inset: 0, display: 'flex', alignItems: 'center', justifyContent: 'center', pointerEvents: 'none' }}>
|
||||
<div style={{
|
||||
display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '10px',
|
||||
@@ -895,7 +896,7 @@ const DashboardContent: React.FC<DashboardContentProps> = ({ onNavigate }) => {
|
||||
borderRadius: '12px',
|
||||
padding: '20px 28px',
|
||||
}}>
|
||||
<p style={{ color: 'rgba(255,255,255,0.85)', fontSize: '14px', fontWeight: 500, margin: 0, textAlign: 'center' }}>
|
||||
<p style={{ color: 'rgba(255,255,255,0.85)', fontSize: '16px', fontWeight: 500, margin: 0, textAlign: 'center' }}>
|
||||
누적 데이터가 부족하여 실제 시청자 정보가 없습니다.
|
||||
</p>
|
||||
</div>
|
||||
@@ -904,38 +905,36 @@ const DashboardContent: React.FC<DashboardContentProps> = ({ onNavigate }) => {
|
||||
</div>
|
||||
</AnimatedSection>
|
||||
|
||||
{/* 개발자 모드 전용: mock 데이터 블러 해제 버튼 */}
|
||||
{isTestPage && isEmptyState && (
|
||||
<button
|
||||
onClick={() => setShowMockData(prev => !prev)}
|
||||
style={{
|
||||
position: 'fixed',
|
||||
bottom: '24px',
|
||||
right: '24px',
|
||||
zIndex: 9999,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '6px',
|
||||
background: showMockData ? 'rgba(255,100,100,0.15)' : 'rgba(166,255,234,0.12)',
|
||||
border: `1px solid ${showMockData ? 'rgba(255,100,100,0.4)' : 'rgba(166,255,234,0.4)'}`,
|
||||
borderRadius: '10px',
|
||||
color: showMockData ? 'rgba(255,150,150,0.9)' : '#a6ffea',
|
||||
padding: '8px 14px',
|
||||
fontSize: '12px',
|
||||
fontWeight: 600,
|
||||
cursor: 'pointer',
|
||||
backdropFilter: 'blur(8px)',
|
||||
}}
|
||||
>
|
||||
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
{showMockData
|
||||
? <><path d="M17.94 17.94A10.07 10.07 0 0112 20c-7 0-11-8-11-8a18.45 18.45 0 015.06-5.94"/><path d="M9.9 4.24A9.12 9.12 0 0112 4c7 0 11 8 11 8a18.5 18.5 0 01-2.16 3.19"/><line x1="1" y1="1" x2="23" y2="23"/></>
|
||||
: <><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></>
|
||||
}
|
||||
</svg>
|
||||
{showMockData ? 'Mock 숨기기' : 'Mock 보기'} [DEV]
|
||||
</button>
|
||||
)}
|
||||
{/* mock 데이터 보기 버튼 */}
|
||||
<button
|
||||
onClick={() => setShowMockData(prev => !prev)}
|
||||
style={{
|
||||
position: 'fixed',
|
||||
bottom: '24px',
|
||||
right: '24px',
|
||||
zIndex: 9999,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '6px',
|
||||
background: showMockData ? 'rgba(255,100,100,0.15)' : 'rgba(166,255,234,0.12)',
|
||||
border: `1px solid ${showMockData ? 'rgba(255,100,100,0.4)' : 'rgba(166,255,234,0.4)'}`,
|
||||
borderRadius: '10px',
|
||||
color: showMockData ? 'rgba(255,150,150,0.9)' : '#a6ffea',
|
||||
padding: '8px 14px',
|
||||
fontSize: '12px',
|
||||
fontWeight: 600,
|
||||
cursor: 'pointer',
|
||||
backdropFilter: 'blur(8px)',
|
||||
}}
|
||||
>
|
||||
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
{showMockData
|
||||
? <><path d="M17.94 17.94A10.07 10.07 0 0112 20c-7 0-11-8-11-8a18.45 18.45 0 015.06-5.94"/><path d="M9.9 4.24A9.12 9.12 0 0112 4c7 0 11 8 11 8a18.5 18.5 0 01-2.16 3.19"/><line x1="1" y1="1" x2="23" y2="23"/></>
|
||||
: <><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></>
|
||||
}
|
||||
</svg>
|
||||
{showMockData ? 'Sample 숨기기' : 'Sample 보기'}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import Sidebar from '../../components/Sidebar';
|
||||
import AssetManagementContent from './AssetManagementContent';
|
||||
@@ -148,13 +148,18 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
};
|
||||
|
||||
const [imageList, setImageList] = useState<ImageItem[]>(getInitialImageList());
|
||||
const prevAnalysisMIdRef = useRef<number | null | undefined>(analysisData?.m_id);
|
||||
|
||||
// analysisData 변경 시 imageList 업데이트
|
||||
// analysisData 변경 시 m_id가 바뀐 경우(새로운 분석)에만 imageList 업데이트
|
||||
// m_id가 동일하면 언어 변경 등 기타 업데이트이므로 사용자가 수정한 이미지 목록 유지
|
||||
useEffect(() => {
|
||||
console.log('[GenerationFlow] analysisData updated, m_id:', analysisData?.m_id);
|
||||
if (analysisData?.image_list && analysisData.image_list.length > 0) {
|
||||
setImageList(analysisData.image_list.map(url => ({ type: 'url', url })));
|
||||
if (prevAnalysisMIdRef.current !== analysisData.m_id) {
|
||||
setImageList(analysisData.image_list.map(url => ({ type: 'url', url })));
|
||||
}
|
||||
}
|
||||
prevAnalysisMIdRef.current = analysisData?.m_id;
|
||||
}, [analysisData]);
|
||||
|
||||
const handleRemoveImage = (index: number) => {
|
||||
|
||||
@@ -124,6 +124,17 @@ const UrlInputContent: React.FC<UrlInputContentProps> = ({ onAnalyze, onAutocomp
|
||||
}
|
||||
};
|
||||
|
||||
// 붙여넣기 시 URL만 추출
|
||||
const handlePaste = (e: React.ClipboardEvent<HTMLInputElement>) => {
|
||||
if (searchType !== 'url') return;
|
||||
const pasted = e.clipboardData.getData('text');
|
||||
const urlMatch = pasted.match(/https?:\/\/[^\s]+/);
|
||||
if (urlMatch) {
|
||||
e.preventDefault();
|
||||
setInputValue(urlMatch[0]);
|
||||
}
|
||||
};
|
||||
|
||||
// 폼 제출 처리
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
@@ -196,10 +207,19 @@ const UrlInputContent: React.FC<UrlInputContentProps> = ({ onAnalyze, onAutocomp
|
||||
{/* 입력 필드 */}
|
||||
<div className="url-input-field-container" ref={autocompleteRef}>
|
||||
<input
|
||||
type={searchType === 'url' ? 'url' : 'text'}
|
||||
type="text"
|
||||
value={inputValue}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value;
|
||||
let value = e.target.value;
|
||||
|
||||
// URL 모드일 때 URL만 추출 (예: "[네이버 지도] https://...")
|
||||
if (searchType === 'url') {
|
||||
const urlMatch = value.match(/https?:\/\/\S+/);
|
||||
if (urlMatch && urlMatch[0] !== value) {
|
||||
value = urlMatch[0];
|
||||
}
|
||||
}
|
||||
|
||||
setInputValue(value);
|
||||
|
||||
// 업체명 검색일 때 자동완성 검색 (디바운스)
|
||||
@@ -212,6 +232,7 @@ const UrlInputContent: React.FC<UrlInputContentProps> = ({ onAnalyze, onAutocomp
|
||||
}, 300);
|
||||
}
|
||||
}}
|
||||
onPaste={handlePaste}
|
||||
onFocus={() => {
|
||||
if (searchType === 'name' && autocompleteResults.length > 0) {
|
||||
setShowAutocomplete(true);
|
||||
|
||||
@@ -376,7 +376,16 @@ const HeroSection: React.FC<HeroSectionProps> = ({ onAnalyze, onAutocomplete, on
|
||||
type="text"
|
||||
value={inputValue}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value;
|
||||
let value = e.target.value;
|
||||
|
||||
// URL 모드일 때 URL만 추출 (예: "[네이버 지도] https://...")
|
||||
if (searchType === 'url') {
|
||||
const urlMatch = value.match(/https?:\/\/\S+/);
|
||||
if (urlMatch && urlMatch[0] !== value) {
|
||||
value = urlMatch[0];
|
||||
}
|
||||
}
|
||||
|
||||
setInputValue(value);
|
||||
setHighlightedIndex(-1); // 입력 시 하이라이트 초기화
|
||||
if (localError) setLocalError('');
|
||||
@@ -391,6 +400,16 @@ const HeroSection: React.FC<HeroSectionProps> = ({ onAnalyze, onAutocomplete, on
|
||||
}, 300);
|
||||
}
|
||||
}}
|
||||
onPaste={(e: React.ClipboardEvent<HTMLInputElement>) => {
|
||||
if (searchType !== 'url') return;
|
||||
const pasted = e.clipboardData.getData('text');
|
||||
const urlMatch = pasted.match(/https?:\/\/[^\s]+/);
|
||||
if (urlMatch) {
|
||||
e.preventDefault();
|
||||
setInputValue(urlMatch[0]);
|
||||
if (localError) setLocalError('');
|
||||
}
|
||||
}}
|
||||
onFocus={() => {
|
||||
setIsFocused(true);
|
||||
if (searchType === 'name' && autocompleteResults.length > 0) {
|
||||
|
||||
Reference in new issue
Block a user