mirror of
https://github.com/complexcaresolutions/cms.c2sgmbh.git
synced 2026-03-17 16:14:12 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
parent
06c93ba05c
commit
826e404955
1 changed files with 11 additions and 6 deletions
|
|
@ -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<string, { label: string; className: string }> = {
|
||||
|
|
@ -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 = () => {
|
|||
>
|
||||
<option value="all">Alle Kanäle</option>
|
||||
{channels.map((ch) => (
|
||||
<option key={ch.id} value={ch.slug}>
|
||||
<option key={ch.id} value={ch.id}>
|
||||
{ch.name}
|
||||
</option>
|
||||
))}
|
||||
|
|
@ -807,7 +807,12 @@ export const YouTubeAnalyticsDashboard: React.FC = () => {
|
|||
<button
|
||||
key={tab.key}
|
||||
className={`yt-analytics__tab ${activeTab === tab.key ? 'yt-analytics__tab--active' : ''}`}
|
||||
onClick={() => setActiveTab(tab.key)}
|
||||
onClick={() => {
|
||||
if (tab.key !== activeTab) {
|
||||
setData(null)
|
||||
setActiveTab(tab.key)
|
||||
}
|
||||
}}
|
||||
>
|
||||
{tab.icon}
|
||||
{tab.label}
|
||||
|
|
|
|||
Loading…
Reference in a new issue