From 826e404955bb58c9d3ad7add6dade60b6ea3a567 Mon Sep 17 00:00:00 2001 From: Martin Porwoll Date: Fri, 13 Feb 2026 14:00:35 +0000 Subject: [PATCH] fix(youtube-analytics): fix tab-switch crash and channel selector - Clear data state on tab switch to prevent stale data type mismatch - Add defensive null guards in all render functions (?.stats, ?.pipeline) - Use channel ID instead of slug for API filtering Co-Authored-By: Claude Opus 4.6 --- .../admin/YouTubeAnalyticsDashboard.tsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/admin/YouTubeAnalyticsDashboard.tsx b/src/components/admin/YouTubeAnalyticsDashboard.tsx index 003addf..33ca489 100644 --- a/src/components/admin/YouTubeAnalyticsDashboard.tsx +++ b/src/components/admin/YouTubeAnalyticsDashboard.tsx @@ -272,7 +272,7 @@ export const YouTubeAnalyticsDashboard: React.FC = () => { const renderPerformance = () => { const perfData = data as PerformanceData - if (!perfData) return null + if (!perfData?.stats) return null return ( <> @@ -435,7 +435,7 @@ export const YouTubeAnalyticsDashboard: React.FC = () => { const renderPipeline = () => { const pipeData = data as PipelineData - if (!pipeData) return null + if (!pipeData?.pipeline) return null // Group statuses for pipeline bar const statusGroups: Record = { @@ -557,7 +557,7 @@ export const YouTubeAnalyticsDashboard: React.FC = () => { const renderGoals = () => { const goalsData = data as GoalsData - if (!goalsData) return null + if (!goalsData?.stats) return null return ( <> @@ -652,7 +652,7 @@ export const YouTubeAnalyticsDashboard: React.FC = () => { const renderCommunity = () => { const commData = data as CommunityData - if (!commData) return null + if (!commData?.stats) return null const sentimentMax = Math.max(...Object.values(commData.sentiment)) @@ -765,7 +765,7 @@ export const YouTubeAnalyticsDashboard: React.FC = () => { > {channels.map((ch) => ( - ))} @@ -807,7 +807,12 @@ export const YouTubeAnalyticsDashboard: React.FC = () => {