feat: P0 fixes — date formatting, channel labels, dynamic marketing plan

- ReportHeader/PlanHeader: format ISO dates as Korean (2026년 4월 2일)
- ChannelOverview: map API keys to Korean labels (naverBlog → 네이버 블로그)
- useMarketingPlan: replace mockPlan with real DB-based plan generation
- transformPlan: build MarketingPlan from report data (channels, pillars, calendar)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Haewon KamandClaude Opus 4.6 committed 2026-04-02 13:58:40 +09:00
1 parent bd7bc45192
commit 4484ac788a
5 files changed
+302 -12

No files matched your search

+41 -9
View File
@@ -1,6 +1,8 @@
import { useState, useEffect } from 'react';
import { useLocation } from 'react-router';
import type { MarketingPlan } from '../types/plan';
import { mockPlan } from '../data/mockPlan';
import { fetchReportById } from '../lib/supabase';
import { transformReportToPlan } from '../lib/transformPlan';
interface UseMarketingPlanResult {
data: MarketingPlan | null;
@@ -8,10 +10,17 @@ interface UseMarketingPlanResult {
error: string | null;
}
interface LocationState {
report?: Record<string, unknown>;
metadata?: Record<string, unknown>;
reportId?: string;
}
export function useMarketingPlan(id: string | undefined): UseMarketingPlanResult {
const [data, setData] = useState<MarketingPlan | null>(null);
const [isLoading, setIsLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const location = useLocation();
useEffect(() => {
if (!id) {
@@ -20,15 +29,38 @@ export function useMarketingPlan(id: string | undefined): UseMarketingPlanResult
return;
}
// Phase 1: Return mock data
// Phase 2+: Replace with real API call
const timer = setTimeout(() => {
setData(mockPlan);
setIsLoading(false);
}, 100);
const state = location.state as LocationState | undefined;
return () => clearTimeout(timer);
}, [id]);
// Source 1: Report data passed via navigation state
if (state?.report && state?.metadata) {
try {
const plan = transformReportToPlan({
id: (state.reportId || id),
url: (state.metadata.url as string) || '',
clinic_name: (state.metadata.clinicName as string) || '',
report: state.report,
created_at: (state.metadata.generatedAt as string) || new Date().toISOString(),
});
setData(plan);
setIsLoading(false);
} catch (err) {
setError(err instanceof Error ? err.message : 'Failed to build marketing plan');
setIsLoading(false);
}
return;
}
// Source 2: Fetch report from Supabase and transform to plan
fetchReportById(id)
.then((row) => {
const plan = transformReportToPlan(row);
setData(plan);
})
.catch((err) => {
setError(err instanceof Error ? err.message : 'Failed to fetch marketing plan');
})
.finally(() => setIsLoading(false));
}, [id, location.state]);
return { data, isLoading, error };
}