ado2 삭제 부분 수정, 브랜드 페이지 작업, 버그 fix .
This commit is contained in:
1 parent
e997b2b5af
commit
cac825de19
5 files changed
+641
-355
No files matched your search
@@ -1,7 +1,6 @@
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import { CrawlingResponse } from '../../types/api';
|
||||
import GeometricChart, { USP } from './GeometricChart';
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import { CrawlingResponse, TargetPersona, SellingPoint } from '../../types/api';
|
||||
|
||||
interface AnalysisResultSectionProps {
|
||||
onBack: () => void;
|
||||
@@ -9,242 +8,6 @@ interface AnalysisResultSectionProps {
|
||||
data: CrawlingResponse;
|
||||
}
|
||||
|
||||
type MarkdownBlock =
|
||||
| { type: 'heading'; level: number; text: string }
|
||||
| { type: 'list'; ordered: boolean; items: string[] }
|
||||
| { type: 'paragraph'; text: string };
|
||||
|
||||
const parseMarkdownBlocks = (text: string): MarkdownBlock[] => {
|
||||
const lines = text.split(/\r?\n/);
|
||||
const blocks: MarkdownBlock[] = [];
|
||||
let paragraphLines: string[] = [];
|
||||
let listItems: string[] = [];
|
||||
let listOrdered = false;
|
||||
|
||||
const flushParagraph = () => {
|
||||
if (paragraphLines.length === 0) return;
|
||||
blocks.push({ type: 'paragraph', text: paragraphLines.join(' ') });
|
||||
paragraphLines = [];
|
||||
};
|
||||
|
||||
const flushList = () => {
|
||||
if (listItems.length === 0) return;
|
||||
blocks.push({ type: 'list', ordered: listOrdered, items: listItems });
|
||||
listItems = [];
|
||||
listOrdered = false;
|
||||
};
|
||||
|
||||
lines.forEach((line) => {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed) {
|
||||
flushParagraph();
|
||||
flushList();
|
||||
return;
|
||||
}
|
||||
|
||||
const headingMatch = trimmed.match(/^(#{1,6})\s+(.*)$/);
|
||||
if (headingMatch) {
|
||||
flushParagraph();
|
||||
flushList();
|
||||
blocks.push({
|
||||
type: 'heading',
|
||||
level: headingMatch[1].length,
|
||||
text: headingMatch[2].trim(),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const listMatch = trimmed.match(/^([-*+]|\d+\.)\s+(.*)$/);
|
||||
if (listMatch) {
|
||||
flushParagraph();
|
||||
listOrdered = listMatch[1].endsWith('.');
|
||||
listItems.push(listMatch[2].trim());
|
||||
return;
|
||||
}
|
||||
|
||||
flushList();
|
||||
paragraphLines.push(trimmed);
|
||||
});
|
||||
|
||||
flushParagraph();
|
||||
flushList();
|
||||
|
||||
return blocks;
|
||||
};
|
||||
|
||||
const renderInlineMarkdown = (text: string): React.ReactNode[] => {
|
||||
// Use non-greedy .+? instead of [^*]+ to handle edge cases better
|
||||
const parts = text.split(/(\*\*.+?\*\*|`[^`]+`|#[^\s#]+)/g).filter(Boolean);
|
||||
return parts.map((part, idx) => {
|
||||
if (part.startsWith('**') && part.endsWith('**')) {
|
||||
return (
|
||||
<strong key={idx} className="text-white font-semibold">
|
||||
{part.slice(2, -2)}
|
||||
</strong>
|
||||
);
|
||||
}
|
||||
if (part.startsWith('`') && part.endsWith('`')) {
|
||||
return (
|
||||
<code key={idx} className="px-1 py-0.5 rounded bg-brand-bg/60 text-brand-accent text-xs">
|
||||
{part.slice(1, -1)}
|
||||
</code>
|
||||
);
|
||||
}
|
||||
if (part.startsWith('#')) {
|
||||
return (
|
||||
<span key={idx} className="text-brand-purple font-semibold">
|
||||
{part}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
return <span key={idx}>{part}</span>;
|
||||
});
|
||||
};
|
||||
|
||||
const renderMarkdown = (text: string) => {
|
||||
const blocks = parseMarkdownBlocks(text);
|
||||
|
||||
return blocks.map((block, idx) => {
|
||||
if (block.type === 'heading') {
|
||||
return (
|
||||
<h4
|
||||
key={idx}
|
||||
className="text-sm font-semibold text-brand-accent uppercase tracking-wider mt-4 first:mt-0"
|
||||
>
|
||||
{block.text}
|
||||
</h4>
|
||||
);
|
||||
}
|
||||
if (block.type === 'list') {
|
||||
const ListTag = block.ordered ? 'ol' : 'ul';
|
||||
const listClass = block.ordered ? 'list-decimal' : 'list-disc';
|
||||
return (
|
||||
<ListTag key={idx} className={`space-y-1 text-sm text-brand-text/90 ${listClass} pl-4`}>
|
||||
{block.items.map((item, itemIdx) => (
|
||||
<li key={itemIdx}>{renderInlineMarkdown(item)}</li>
|
||||
))}
|
||||
</ListTag>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<p key={idx} className="text-sm text-brand-text/80 leading-relaxed">
|
||||
{renderInlineMarkdown(block.text)}
|
||||
</p>
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const splitMarkdownSections = (text: string) => {
|
||||
const blocks = parseMarkdownBlocks(text);
|
||||
const sections: Array<{ title: string; content: string }> = [];
|
||||
let currentTitle = '본문';
|
||||
let contentLines: string[] = [];
|
||||
|
||||
blocks.forEach((block) => {
|
||||
if (block.type === 'heading') {
|
||||
if (contentLines.length > 0) {
|
||||
sections.push({ title: currentTitle, content: contentLines.join('\n') });
|
||||
}
|
||||
currentTitle = block.text;
|
||||
contentLines = [];
|
||||
return;
|
||||
}
|
||||
if (block.type === 'list') {
|
||||
contentLines.push(block.items.map((item) => `- ${item}`).join('\n'));
|
||||
return;
|
||||
}
|
||||
contentLines.push(block.text);
|
||||
});
|
||||
|
||||
if (contentLines.length > 0) {
|
||||
sections.push({ title: currentTitle, content: contentLines.join('\n') });
|
||||
}
|
||||
|
||||
return sections;
|
||||
};
|
||||
|
||||
const pickSectionContent = (sections: Array<{ title: string; content: string }>, keywords: string[]) => {
|
||||
const lowered = keywords.map((keyword) => keyword.toLowerCase());
|
||||
const match = sections.find((section) =>
|
||||
lowered.some((keyword) => section.title.toLowerCase().includes(keyword))
|
||||
);
|
||||
return match?.content || '';
|
||||
};
|
||||
|
||||
const buildUSPs = (facilities: string[], tags: string[]) => {
|
||||
const candidates = [...facilities, ...tags.filter((tag) => !facilities.includes(tag))];
|
||||
const labels = candidates.slice(0, 7);
|
||||
const subLabels = ['CONCEPT', 'PRIVACY', 'LOCAL', 'MOOD', 'TRUST', 'STAY', 'PHOTO', 'HEALING'];
|
||||
|
||||
if (labels.length < 3) {
|
||||
return [
|
||||
{
|
||||
label: '브랜드 컨셉',
|
||||
subLabel: 'CONCEPT',
|
||||
score: 88,
|
||||
description: '분석 데이터 기반 컨셉 도출',
|
||||
},
|
||||
{
|
||||
label: '프라이버시',
|
||||
subLabel: 'PRIVACY',
|
||||
score: 84,
|
||||
description: '프라이빗 경험 강조 포인트',
|
||||
},
|
||||
{
|
||||
label: '무드',
|
||||
subLabel: 'MOOD',
|
||||
score: 82,
|
||||
description: '감성적 장면 강조',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return labels.map((label, idx) => ({
|
||||
label,
|
||||
subLabel: subLabels[idx % subLabels.length],
|
||||
score: Math.min(96, 78 + idx * 3 + (label.length % 6)),
|
||||
description: tags[idx] ? `키워드: ${tags[idx]}` : label,
|
||||
}));
|
||||
};
|
||||
|
||||
const buildTargets = (sectionText: string, tags: string[]) => {
|
||||
if (!sectionText.trim()) {
|
||||
return [
|
||||
{
|
||||
segment: '타겟 고객',
|
||||
age: '',
|
||||
needs: tags.slice(0, 3),
|
||||
triggers: [],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
const blocks = parseMarkdownBlocks(sectionText);
|
||||
const listBlock = blocks.find((block) => block.type === 'list') as
|
||||
| { type: 'list'; ordered: boolean; items: string[] }
|
||||
| undefined;
|
||||
const rawItems = listBlock?.items ?? sectionText.split(/\r?\n/).filter(Boolean);
|
||||
|
||||
return rawItems.slice(0, 3).map((item, idx) => {
|
||||
const [segmentPart, detailPart] = item.split(':');
|
||||
const segment = (segmentPart || item).trim();
|
||||
const detail = (detailPart || '').trim();
|
||||
const needs = detail
|
||||
? detail
|
||||
.split(/[,/·]/)
|
||||
.map((value) => value.trim())
|
||||
.filter(Boolean)
|
||||
: tags.slice(idx * 2, idx * 2 + 3);
|
||||
const ageMatch = segment.match(/(\d{2}~\d{2}세|\d{2}대|\d{2}s)/);
|
||||
return {
|
||||
segment,
|
||||
age: ageMatch ? ageMatch[0] : '',
|
||||
needs,
|
||||
triggers: [],
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
const SparklesIcon = ({ className = '' }: { className?: string }) => (
|
||||
<svg className={className} viewBox="0 0 24 24" fill="currentColor" aria-hidden>
|
||||
<path d="M12 2l2.4 6.8L22 12l-7.6 3.2L12 22l-2.4-6.8L2 12l7.6-3.2L12 2z" />
|
||||
@@ -274,13 +37,6 @@ const UsersIcon = () => (
|
||||
</svg>
|
||||
);
|
||||
|
||||
const TrendingUpIcon = () => (
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<path d="M3 17l6-6 4 4 7-7" />
|
||||
<path d="M14 7h7v7" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
const LayoutGridIcon = () => (
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<rect x="3" y="3" width="7" height="7" />
|
||||
@@ -290,28 +46,388 @@ const LayoutGridIcon = () => (
|
||||
</svg>
|
||||
);
|
||||
|
||||
const ChartIcon = () => (
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<path d="M18 20V10M12 20V4M6 20v-6" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
// 범용 애니메이션 아이템 컴포넌트
|
||||
interface AnimatedItemProps {
|
||||
children: React.ReactNode;
|
||||
index: number;
|
||||
baseDelay?: number;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const AnimatedItem: React.FC<AnimatedItemProps> = ({ children, index, baseDelay = 0, className = '' }) => {
|
||||
const [isVisible, setIsVisible] = useState(false);
|
||||
const delay = baseDelay + index * 150;
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(() => {
|
||||
setIsVisible(true);
|
||||
}, delay);
|
||||
return () => clearTimeout(timer);
|
||||
}, [delay]);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`transition-all duration-500 ${
|
||||
isVisible ? 'opacity-100 translate-y-0' : 'opacity-0 -translate-y-4'
|
||||
} ${className}`}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// 애니메이션 숫자 카운터 컴포넌트
|
||||
interface AnimatedScoreProps {
|
||||
score: number;
|
||||
duration?: number;
|
||||
delay?: number;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const AnimatedScore: React.FC<AnimatedScoreProps> = ({ score, duration = 1000, delay = 0, className = '' }) => {
|
||||
const [displayScore, setDisplayScore] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(() => {
|
||||
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);
|
||||
|
||||
setDisplayScore(Math.round(score * easeProgress));
|
||||
|
||||
if (progress < 1) {
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
};
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}, delay);
|
||||
|
||||
return () => clearTimeout(timer);
|
||||
}, [score, duration, delay]);
|
||||
|
||||
return <span className={className}>{displayScore}</span>;
|
||||
};
|
||||
|
||||
// 애니메이션 USP 아이템 컴포넌트
|
||||
interface AnimatedUSPItemProps {
|
||||
usp: { category: string; description: string; score: number };
|
||||
index: number;
|
||||
isTop?: boolean;
|
||||
getScoreColor: (score: number) => string;
|
||||
}
|
||||
|
||||
const AnimatedUSPItem: React.FC<AnimatedUSPItemProps> = ({ usp, index, isTop = false, getScoreColor }) => {
|
||||
const [isVisible, setIsVisible] = useState(false);
|
||||
const delay = index * 150; // 각 아이템마다 150ms 딜레이
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(() => {
|
||||
setIsVisible(true);
|
||||
}, delay);
|
||||
return () => clearTimeout(timer);
|
||||
}, [delay]);
|
||||
|
||||
if (isTop) {
|
||||
return (
|
||||
<div
|
||||
className={`mb-6 p-5 rounded-xl bg-gradient-to-r from-brand-accent/10 to-brand-purple/10 border border-brand-accent/30 relative overflow-hidden transition-all duration-500 ${
|
||||
isVisible ? 'opacity-100 translate-y-0' : 'opacity-0 -translate-y-4'
|
||||
}`}
|
||||
>
|
||||
<div className="absolute top-0 right-0 w-20 h-20 bg-brand-accent/5 rounded-full -translate-y-1/2 translate-x-1/2"></div>
|
||||
<div className="relative z-10 flex justify-between items-center">
|
||||
<div>
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
<span className="text-xs text-brand-accent font-bold uppercase tracking-wider">{usp.category}</span>
|
||||
<span className="text-xs bg-brand-accent/20 text-brand-accent px-2 py-0.5 rounded font-semibold">TOP</span>
|
||||
</div>
|
||||
<div className="text-lg font-bold text-white">{usp.description}</div>
|
||||
</div>
|
||||
<AnimatedScore
|
||||
score={usp.score}
|
||||
delay={delay + 300}
|
||||
duration={1200}
|
||||
className={`text-4xl font-bold ${getScoreColor(usp.score)}`}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`p-4 rounded-xl bg-brand-bg/40 border border-white/5 hover:bg-brand-bg/60 transition-all duration-500 flex justify-between items-center ${
|
||||
isVisible ? 'opacity-100 translate-y-0' : 'opacity-0 -translate-y-4'
|
||||
}`}
|
||||
>
|
||||
<div>
|
||||
<div className="text-xs text-brand-muted font-bold uppercase tracking-tight mb-1">{usp.category}</div>
|
||||
<div className="text-base font-bold text-white">{usp.description}</div>
|
||||
</div>
|
||||
<AnimatedScore
|
||||
score={usp.score}
|
||||
delay={delay + 300}
|
||||
duration={1000}
|
||||
className={`text-3xl font-bold ${getScoreColor(usp.score)} ml-4`}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// 레이더 차트 컴포넌트
|
||||
interface RadarChartProps {
|
||||
data: { category: string; description: string; score: number }[];
|
||||
size?: number;
|
||||
}
|
||||
|
||||
const RadarChart: React.FC<RadarChartProps> = ({ data, size = 280 }) => {
|
||||
// 애니메이션을 위한 현재 점수 상태 (0에서 시작)
|
||||
const [animatedScores, setAnimatedScores] = useState<number[]>(data.map(() => 0));
|
||||
const [isAnimating, setIsAnimating] = useState(true);
|
||||
|
||||
// 애니메이션 효과
|
||||
useEffect(() => {
|
||||
const targetScores = data.map(item => item.score);
|
||||
const duration = 1500; // 1.5초
|
||||
const startTime = Date.now();
|
||||
|
||||
const animate = () => {
|
||||
const elapsed = Date.now() - startTime;
|
||||
const progress = Math.min(elapsed / duration, 1);
|
||||
|
||||
// easeOutCubic 이징 함수 적용
|
||||
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 = 60;
|
||||
const center = size / 2 + padding; // padding 만큼 오프셋
|
||||
const maxRadius = size / 2 - 20; // 차트 반지름
|
||||
const levels = 5; // 동심원 개수
|
||||
|
||||
// 각 축의 각도 계산
|
||||
const angleStep = (2 * Math.PI) / data.length;
|
||||
|
||||
// 점수를 좌표로 변환 (0-100 점수를 반지름으로)
|
||||
const getPoint = (index: number, score: number) => {
|
||||
const angle = angleStep * index - Math.PI / 2; // -90도에서 시작 (12시 방향)
|
||||
const radius = (score / 100) * maxRadius;
|
||||
return {
|
||||
x: center + radius * Math.cos(angle),
|
||||
y: center + radius * Math.sin(angle),
|
||||
};
|
||||
};
|
||||
|
||||
// 라벨 위치 계산
|
||||
const getLabelPosition = (index: number) => {
|
||||
const angle = angleStep * index - Math.PI / 2;
|
||||
const radius = maxRadius + 20;
|
||||
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}`;
|
||||
});
|
||||
|
||||
// SVG 전체 크기 (padding 포함)
|
||||
const svgSize = size + padding * 2;
|
||||
|
||||
return (
|
||||
<div className="relative flex justify-center items-center" style={{ overflow: 'visible' }}>
|
||||
<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.1)"
|
||||
strokeWidth="1"
|
||||
/>
|
||||
))}
|
||||
|
||||
{/* 축 라인 */}
|
||||
{axisLines.map((path, i) => (
|
||||
<path
|
||||
key={`axis-${i}`}
|
||||
d={path}
|
||||
fill="none"
|
||||
stroke="rgba(255,255,255,0.1)"
|
||||
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 pos = getLabelPosition(i);
|
||||
const isLeft = pos.x < center - 10;
|
||||
const isRight = pos.x > center + 10;
|
||||
const isTop = pos.y < center - 10;
|
||||
const isBottom = pos.y > center + 10;
|
||||
|
||||
let textAnchor: 'start' | 'middle' | 'end' = 'middle';
|
||||
let dy = 0;
|
||||
|
||||
if (isLeft) textAnchor = 'end';
|
||||
else if (isRight) textAnchor = 'start';
|
||||
|
||||
if (isTop && !isLeft && !isRight) dy = -8;
|
||||
else if (isBottom && !isLeft && !isRight) dy = 5;
|
||||
|
||||
return (
|
||||
<g key={`label-${i}`}>
|
||||
{/* 한글 설명 (메인 라벨) */}
|
||||
<text
|
||||
x={pos.x}
|
||||
y={pos.y}
|
||||
dy={dy}
|
||||
textAnchor={textAnchor}
|
||||
fill="rgba(255,255,255,0.9)"
|
||||
fontSize="11"
|
||||
fontWeight="600"
|
||||
>
|
||||
{item.description}
|
||||
</text>
|
||||
{/* 영어 카테고리 (서브 라벨) */}
|
||||
<text
|
||||
x={pos.x}
|
||||
y={pos.y}
|
||||
dy={dy + 12}
|
||||
textAnchor={textAnchor}
|
||||
fill="rgba(255,255,255,0.4)"
|
||||
fontSize="8"
|
||||
fontWeight="400"
|
||||
>
|
||||
{item.category}
|
||||
</text>
|
||||
</g>
|
||||
);
|
||||
})}
|
||||
</svg>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
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 = useMemo(
|
||||
() => splitMarkdownSections(marketing_analysis?.report || ''),
|
||||
[marketing_analysis?.report]
|
||||
);
|
||||
const locationAnalysis =
|
||||
pickSectionContent(reportSections, ['지역', '입지']) || reportSections[0]?.content || '';
|
||||
const conceptAnalysis =
|
||||
pickSectionContent(reportSections, ['핵심', '차별', '컨셉', '콘셉트']) || reportSections[1]?.content || '';
|
||||
const targetSection = pickSectionContent(reportSections, ['타겟', '고객']);
|
||||
const positioningCategory = facilities.length > 0 ? facilities.join(' · ') : '정보 없음';
|
||||
const positioningCore =
|
||||
pickSectionContent(reportSections, ['핵심 가치', '핵심', '차별']) || tags.slice(0, 3).join(' · ') || '정보 없음';
|
||||
const usps: USP[] = useMemo(() => buildUSPs(facilities, tags), [facilities, tags]);
|
||||
const topUSP = useMemo(
|
||||
() => [...usps].sort((a, b) => b.score - a.score)[0],
|
||||
[usps]
|
||||
);
|
||||
const targets = useMemo(() => buildTargets(targetSection, tags), [targetSection, tags]);
|
||||
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;
|
||||
const targetPersonas = marketing_analysis?.target_persona || [];
|
||||
const sellingPoints = marketing_analysis?.selling_points || [];
|
||||
const targetKeywords = marketing_analysis?.target_keywords || [];
|
||||
|
||||
// 컨테이너 기준으로 버튼 위치 계산
|
||||
useEffect(() => {
|
||||
const updateButtonPosition = () => {
|
||||
if (containerRef.current) {
|
||||
const rect = containerRef.current.getBoundingClientRect();
|
||||
setButtonPosition({ left: rect.left, width: rect.width });
|
||||
}
|
||||
};
|
||||
|
||||
updateButtonPosition();
|
||||
window.addEventListener('resize', updateButtonPosition);
|
||||
|
||||
// MutationObserver로 사이드바 변화 감지
|
||||
const observer = new MutationObserver(updateButtonPosition);
|
||||
observer.observe(document.body, { attributes: true, subtree: true, attributeFilter: ['class'] });
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('resize', updateButtonPosition);
|
||||
observer.disconnect();
|
||||
};
|
||||
}, []);
|
||||
|
||||
// 가장 높은 점수의 USP 찾기
|
||||
const topUSP = sellingPoints.length > 0
|
||||
? [...sellingPoints].sort((a, b) => b.score - a.score)[0]
|
||||
: null;
|
||||
|
||||
// 점수에 따른 색상
|
||||
const getScoreColor = (score: number) => {
|
||||
if (score >= 90) return 'text-brand-accent';
|
||||
if (score >= 85) return 'text-green-400';
|
||||
if (score >= 80) return 'text-yellow-400';
|
||||
return 'text-gray-400';
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-brand-bg text-brand-text pb-24 selection:bg-brand-accent/30 font-sans">
|
||||
@@ -336,8 +452,10 @@ const AnalysisResultSection: React.FC<AnalysisResultSectionProps> = ({ onBack, o
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="max-w-7xl mx-auto px-4 md:px-8 grid grid-cols-1 lg:grid-cols-2 gap-8">
|
||||
<div ref={containerRef} className="max-w-7xl mx-auto px-4 md:px-8 grid grid-cols-1 lg:grid-cols-2 gap-8">
|
||||
{/* 왼쪽 컬럼 */}
|
||||
<div className="space-y-6">
|
||||
{/* 브랜드 정체성 카드 */}
|
||||
<div className="bg-brand-card rounded-3xl p-8 border border-brand-muted/10 shadow-lg relative overflow-hidden group hover:border-brand-accent/20 transition-all duration-500">
|
||||
<div className="absolute top-0 left-0 w-1.5 h-full bg-gradient-to-b from-brand-accent to-brand-purple"></div>
|
||||
<div className="mb-4 flex items-center gap-2">
|
||||
@@ -356,131 +474,138 @@ const AnalysisResultSection: React.FC<AnalysisResultSectionProps> = ({ onBack, o
|
||||
</div>
|
||||
|
||||
<div className="space-y-5 text-gray-300 leading-relaxed border-t border-white/5 pt-5">
|
||||
<div>
|
||||
<AnimatedItem index={0} baseDelay={100}>
|
||||
<h3 className="text-white font-semibold mb-2 text-sm text-brand-muted">입지 특성 분석</h3>
|
||||
{locationAnalysis ? renderMarkdown(locationAnalysis) : <p className="text-sm opacity-90">정보 없음</p>}
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-sm opacity-90">{brandIdentity?.location_feature_analysis || '정보 없음'}</p>
|
||||
</AnimatedItem>
|
||||
<AnimatedItem index={1} baseDelay={100}>
|
||||
<h3 className="text-white font-semibold mb-2 text-sm text-brand-muted">컨셉 확장성</h3>
|
||||
{conceptAnalysis ? renderMarkdown(conceptAnalysis) : <p className="text-sm opacity-90">정보 없음</p>}
|
||||
</div>
|
||||
<p className="text-sm opacity-90">{brandIdentity?.concept_scalability || '정보 없음'}</p>
|
||||
</AnimatedItem>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 시장 포지셔닝 카드 */}
|
||||
<div className="bg-brand-card rounded-3xl p-8 border border-brand-muted/10">
|
||||
<h3 className="text-xl font-bold mb-6 flex items-center gap-2 text-white">
|
||||
<TargetIcon /> 시장 포지셔닝
|
||||
</h3>
|
||||
|
||||
<div className="grid grid-cols-1 gap-4">
|
||||
<div className="bg-brand-bg/50 p-5 rounded-xl border border-brand-muted/20 hover:border-brand-accent/30 transition-colors group">
|
||||
<span className="block text-xs text-brand-muted mb-1 group-hover:text-brand-accent transition-colors">
|
||||
카테고리 정의
|
||||
</span>
|
||||
<div className="font-bold text-lg text-white">{renderMarkdown(positioningCategory)}</div>
|
||||
</div>
|
||||
<div className="bg-gradient-to-r from-brand-bg/50 to-brand-cardHover p-5 rounded-xl border border-brand-muted/20 border-l-4 border-l-brand-accent">
|
||||
<span className="block text-xs text-brand-accent mb-1 font-semibold">핵심 가치 (Core Value)</span>
|
||||
<div className="font-semibold text-white">{renderMarkdown(positioningCore)}</div>
|
||||
</div>
|
||||
<AnimatedItem index={0} baseDelay={200}>
|
||||
<div className="bg-gradient-to-r from-brand-bg/50 to-brand-cardHover p-5 rounded-xl border border-brand-muted/20 border-l-4 border-l-brand-accent">
|
||||
<span className="block text-xs text-brand-accent mb-1 font-semibold">핵심 가치 (Core Value)</span>
|
||||
<div className="font-semibold text-white">{marketPositioning?.core_value || '정보 없음'}</div>
|
||||
</div>
|
||||
</AnimatedItem>
|
||||
<AnimatedItem index={1} baseDelay={200}>
|
||||
<div className="bg-brand-bg/50 p-5 rounded-xl border border-brand-muted/20 hover:border-brand-accent/30 transition-colors group">
|
||||
<span className="block text-xs text-brand-muted mb-1 group-hover:text-brand-accent transition-colors">
|
||||
카테고리 정의
|
||||
</span>
|
||||
<div className="font-bold text-lg text-white">{marketPositioning?.category_definition || '정보 없음'}</div>
|
||||
</div>
|
||||
</AnimatedItem>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 타겟 페르소나 카드 */}
|
||||
<div className="bg-brand-card rounded-3xl p-8 border border-brand-muted/10">
|
||||
<h3 className="text-xl font-bold mb-6 flex items-center gap-2 text-white">
|
||||
<UsersIcon /> 타겟 페르소나
|
||||
</h3>
|
||||
<div className="space-y-4">
|
||||
{targets.map((target, idx) => (
|
||||
<div
|
||||
key={idx}
|
||||
className="flex flex-col sm:flex-row sm:items-center gap-4 p-4 bg-brand-bg/30 rounded-xl border border-white/5 hover:border-brand-accent/20 transition-all group"
|
||||
>
|
||||
<div className="min-w-[120px]">
|
||||
<div className="font-bold text-white group-hover:text-brand-accent transition-colors">
|
||||
{renderInlineMarkdown(target.segment)}
|
||||
{targetPersonas.length === 0 && <p className="text-sm text-brand-muted">정보 없음</p>}
|
||||
{targetPersonas.map((persona: TargetPersona, idx: number) => (
|
||||
<AnimatedItem key={idx} index={idx} baseDelay={300}>
|
||||
<div className="p-4 bg-brand-bg/30 rounded-xl border border-white/5 hover:border-brand-accent/20 transition-all group">
|
||||
<div className="mb-3">
|
||||
<div className="font-bold text-white group-hover:text-brand-accent transition-colors mb-1">
|
||||
{persona.persona}
|
||||
</div>
|
||||
<div className="text-xs text-brand-muted">
|
||||
{persona.age.min_age}~{persona.age.max_age}세
|
||||
</div>
|
||||
</div>
|
||||
{target.age && <div className="text-xs text-brand-muted">{target.age}</div>}
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
{target.needs.length > 0 && (
|
||||
<div className="flex flex-wrap gap-1.5 mb-2">
|
||||
{target.needs.map((need, i) => (
|
||||
|
||||
{persona.favor_target.length > 0 && (
|
||||
<div className="flex flex-wrap gap-1.5 mb-3">
|
||||
{persona.favor_target.map((favor: string, i: number) => (
|
||||
<span
|
||||
key={i}
|
||||
className="text-[10px] px-2 py-0.5 bg-brand-accent/10 text-brand-accent rounded-sm font-medium"
|
||||
>
|
||||
{renderInlineMarkdown(need)}
|
||||
{favor}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{target.triggers.length > 0 && (
|
||||
|
||||
{persona.decision_trigger && (
|
||||
<p className="text-xs text-gray-400 border-t border-white/5 pt-2 mt-2">
|
||||
<span className="text-brand-muted">Trigger:</span> {target.triggers.map((t: string, i: number) => <span key={i}>{i > 0 && ', '}{renderInlineMarkdown(t)}</span>)}
|
||||
<span className="text-brand-muted font-semibold">Trigger:</span> {persona.decision_trigger}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</AnimatedItem>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 오른쪽 컬럼 */}
|
||||
<div className="space-y-6">
|
||||
{/* 주요 셀링 포인트 카드 */}
|
||||
<div className="bg-brand-card rounded-3xl p-8 border border-brand-muted/10 min-h-[500px] flex flex-col relative overflow-hidden">
|
||||
<div className="flex justify-between items-center mb-2 z-10">
|
||||
<h3 className="text-xl font-bold text-white">주요 셀링 포인트 (USP)</h3>
|
||||
<div className="flex justify-between items-center mb-6 z-10">
|
||||
<h3 className="text-xl font-bold text-white flex items-center gap-2">
|
||||
<ChartIcon /> 주요 셀링 포인트 (USP)
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 flex items-center justify-center relative z-10 -my-4">
|
||||
<GeometricChart data={usps} />
|
||||
</div>
|
||||
|
||||
{topUSP && (
|
||||
<div className="mt-2 mb-6 p-4 rounded-xl bg-brand-card border border-brand-muted/20 relative overflow-hidden">
|
||||
<div className="relative z-10 flex justify-between items-center">
|
||||
<div>
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
<span className="text-xs text-brand-accent font-bold uppercase tracking-wider">{topUSP.subLabel}</span>
|
||||
<span className="text-xs bg-brand-muted/30 text-white px-2 py-0.5 rounded font-semibold">CORE</span>
|
||||
</div>
|
||||
<div className="text-lg font-bold text-white mb-1">{topUSP.label}</div>
|
||||
<div className="text-sm text-brand-muted">{topUSP.description}</div>
|
||||
</div>
|
||||
<div className="text-4xl font-bold text-brand-muted">{topUSP.score}</div>
|
||||
</div>
|
||||
{/* 레이더 차트 */}
|
||||
{sellingPoints.length > 0 && (
|
||||
<div className="mb-6">
|
||||
<RadarChart data={sellingPoints} size={320} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-3 z-10">
|
||||
{usps
|
||||
.filter((usp) => usp.label !== topUSP?.label)
|
||||
.map((usp, idx) => (
|
||||
<div
|
||||
{/* Top USP 하이라이트 */}
|
||||
{topUSP && (
|
||||
<AnimatedUSPItem
|
||||
usp={topUSP}
|
||||
index={0}
|
||||
isTop={true}
|
||||
getScoreColor={getScoreColor}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* 나머지 USP 리스트 */}
|
||||
<div className="space-y-3 z-10 flex-1">
|
||||
{sellingPoints.length === 0 && <p className="text-sm text-brand-muted">정보 없음</p>}
|
||||
{sellingPoints
|
||||
.filter((usp: SellingPoint) => usp.category !== topUSP?.category)
|
||||
.map((usp: SellingPoint, idx: number) => (
|
||||
<AnimatedUSPItem
|
||||
key={idx}
|
||||
className="p-4 rounded-xl bg-brand-bg/40 border border-white/5 hover:bg-brand-bg/60 transition-colors flex justify-between items-center"
|
||||
>
|
||||
<div>
|
||||
<div className="text-xs text-brand-muted font-bold uppercase tracking-tight mb-1">{usp.subLabel}</div>
|
||||
<div className="text-base font-bold text-white mb-1">{usp.label}</div>
|
||||
<div className="text-sm text-gray-400">{usp.description}</div>
|
||||
</div>
|
||||
<div className="text-3xl font-bold text-brand-muted ml-4">{usp.score}</div>
|
||||
</div>
|
||||
usp={usp}
|
||||
index={idx + 1}
|
||||
isTop={false}
|
||||
getScoreColor={getScoreColor}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 추천 타겟 키워드 */}
|
||||
<div className="max-w-7xl mx-auto px-4 md:px-8 mt-8">
|
||||
<div className="bg-brand-card rounded-3xl p-8 border border-brand-muted/10 relative overflow-hidden">
|
||||
<h3 className="text-xl font-bold mb-6 text-white">추천 타겟 키워드</h3>
|
||||
<div className="flex flex-wrap gap-3 relative z-10">
|
||||
{tags.length === 0 && <span className="text-sm text-brand-muted">정보 없음</span>}
|
||||
{tags.map((keyword, idx) => (
|
||||
{targetKeywords.length === 0 && <span className="text-sm text-brand-muted">정보 없음</span>}
|
||||
{targetKeywords.map((keyword: string, idx: number) => (
|
||||
<span
|
||||
key={idx}
|
||||
className="px-5 py-2.5 rounded-full bg-brand-card border border-brand-muted/30 text-white text-sm hover:border-brand-accent/50 transition-colors"
|
||||
@@ -492,7 +617,11 @@ const AnalysisResultSection: React.FC<AnalysisResultSectionProps> = ({ onBack, o
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="fixed bottom-8 left-0 right-0 flex justify-center z-50 pointer-events-none">
|
||||
{/* 콘텐츠 생성 버튼 */}
|
||||
<div
|
||||
className="fixed bottom-8 flex justify-center z-50 pointer-events-none"
|
||||
style={{ left: buttonPosition.left, width: buttonPosition.width }}
|
||||
>
|
||||
<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"
|
||||
|
||||
Reference in new issue
Block a user