fix: add Authorization header to all Edge Function calls + fix Vision Analysis

- All fetch calls to Supabase Edge Functions now include
  Authorization: Bearer <anon_key> (was missing → 401 errors)
- Fix Firecrawl screenshot API: remove invalid screenshotOptions,
  use "screenshot@fullPage" format (v2 API compatibility)
- Fix screenshot response handling: v2 returns URL not base64,
  now downloads and converts to base64 for Gemini Vision
- Add about page to Vision Analysis capture targets
- Add retry utility, channel error tracking, pipeline resume,
  enrichment retry, EmptyState improvements (Sprint 2-3)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Haewon KamandClaude Opus 4.6 committed 2026-04-05 10:08:03 +09:00
1 parent 2f2aa5a5b6
commit 79950925a1
12 files changed
+961 -214

No files matched your search

+86 -8
View File
@@ -1,19 +1,83 @@
import { motion } from 'motion/react';
import { Search } from 'lucide-react';
import { Search, AlertCircle, Info, RefreshCw } from 'lucide-react';
import { useEffect, useState } from 'react';
type EmptyStatus = 'loading' | 'error' | 'not_found' | 'timeout';
interface EmptyStateProps {
message?: string;
subtext?: string;
status?: EmptyStatus;
onRetry?: () => void;
/** Auto-timeout: switch to 'timeout' status after N seconds (default: 60) */
autoTimeoutSec?: number;
}
const STATUS_CONFIG: Record<EmptyStatus, {
icon: typeof Search;
iconColor: string;
bgColor: string;
defaultMessage: string;
defaultSubtext: string;
}> = {
loading: {
icon: Search,
iconColor: 'text-slate-400',
bgColor: 'bg-slate-100',
defaultMessage: '데이터 수집 중',
defaultSubtext: '채널 데이터 보강이 완료되면 자동으로 업데이트됩니다.',
},
error: {
icon: AlertCircle,
iconColor: 'text-red-400',
bgColor: 'bg-red-50',
defaultMessage: '데이터 수집 실패',
defaultSubtext: '일시적인 오류가 발생했습니다. 다시 시도해 주세요.',
},
not_found: {
icon: Info,
iconColor: 'text-blue-400',
bgColor: 'bg-blue-50',
defaultMessage: '채널을 찾을 수 없음',
defaultSubtext: '이 채널은 발견되지 않았거나 데이터가 없습니다.',
},
timeout: {
icon: AlertCircle,
iconColor: 'text-amber-400',
bgColor: 'bg-amber-50',
defaultMessage: '응답 시간 초과',
defaultSubtext: '데이터 수집에 시간이 오래 걸리고 있습니다.',
},
};
/**
* Shown inside report sections when data is not yet available
* (e.g., before enrichment completes or when a channel is not found).
* (e.g., before enrichment completes, when a channel is not found, or on error).
*/
export function EmptyState({
message = '데이터 수집 중',
subtext = '채널 데이터 보강이 완료되면 자동으로 업데이트됩니다.',
message,
subtext,
status = 'loading',
onRetry,
autoTimeoutSec = 60,
}: EmptyStateProps) {
const [currentStatus, setCurrentStatus] = useState<EmptyStatus>(status);
// Auto-timeout: switch from 'loading' to 'timeout' after N seconds
useEffect(() => {
if (status !== 'loading') return;
const timer = setTimeout(() => setCurrentStatus('timeout'), autoTimeoutSec * 1000);
return () => clearTimeout(timer);
}, [status, autoTimeoutSec]);
// Sync external status changes
useEffect(() => {
setCurrentStatus(status);
}, [status]);
const config = STATUS_CONFIG[currentStatus];
const Icon = config.icon;
return (
<motion.div
className="flex flex-col items-center justify-center py-12 text-center"
@@ -21,11 +85,25 @@ export function EmptyState({
animate={{ opacity: 1 }}
transition={{ duration: 0.4 }}
>
<div className="w-12 h-12 rounded-2xl bg-slate-100 flex items-center justify-center mb-4">
<Search size={20} className="text-slate-400" />
<div className={`w-12 h-12 rounded-2xl ${config.bgColor} flex items-center justify-center mb-4`}>
{currentStatus === 'loading' ? (
<div className="w-5 h-5 border-2 border-slate-300 border-t-slate-500 rounded-full animate-spin" />
) : (
<Icon size={20} className={config.iconColor} />
)}
</div>
<p className="text-sm font-medium text-slate-500">{message}</p>
<p className="text-xs text-slate-400 mt-1 max-w-xs">{subtext}</p>
<p className="text-sm font-medium text-slate-500">{message || config.defaultMessage}</p>
<p className="text-xs text-slate-400 mt-1 max-w-xs">{subtext || config.defaultSubtext}</p>
{onRetry && (currentStatus === 'error' || currentStatus === 'timeout') && (
<button
onClick={onRetry}
className="mt-4 flex items-center gap-1.5 px-4 py-1.5 text-xs font-medium text-purple-600 bg-purple-50 rounded-lg hover:bg-purple-100 transition-colors"
>
<RefreshCw size={12} />
다시 시도
</button>
)}
</motion.div>
);
}