3 lines
15 KiB
JavaScript
3 lines
15 KiB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/js/react-apexcharts.min-CeFxfyVu.js","assets/js/chunk-UIGDSWPH-BhuNDbxn.js"])))=>i.map(i=>d[i]);
|
|
import{u as X,r as o,j as t,L as J,_ as Z}from"./chunk-UIGDSWPH-BhuNDbxn.js";import{b as ee,d as te,P as _,n as W,e as se,g as ae,h as re,i as le,j as oe,k as ne}from"./main-af3pcbZa.js";import{C as c}from"./ComponentCard-C2b5w2__.js";import{P as $}from"./ProgressBar-0v269fGL.js";import{W as de}from"./WorkflowPipeline-Ck3TPaPI.js";import{E as y}from"./EnhancedMetricCard-YOSFdLZV.js";import{S as ie}from"./arrow-right-DC7G5FiV.js";import{S as ue}from"./group-Dnur-I7a.js";import{P as ce}from"./PageHeader-iXTYKDGo.js";import"./check-circle--AtVWUy0.js";import"./Tooltip-D9yIUHzL.js";import"./arrow-up-Ba39LAbN.js";const M=o.lazy(()=>Z(()=>import("./react-apexcharts.min-CeFxfyVu.js").then(m=>m.r),__vite__mapDeps([0,1])).then(m=>({default:m.default})));function Se(){const m=X(),{activeSite:g}=ee(),{activeSector:l}=te(),[e,B]=o.useState(null),[z,O]=o.useState(!0),[q,Q]=o.useState(new Date),[b,D]=o.useState({keywords:0,clusters:0,ideas:0}),f=async()=>{try{O(!0);const[a,i,r,h]=await Promise.all([re({page_size:1e3,sector_id:l==null?void 0:l.id}),le({page_size:1e3,sector_id:l==null?void 0:l.id}),oe({page_size:1e3,sector_id:l==null?void 0:l.id}),ne({page_size:1e3,sector_id:l==null?void 0:l.id})]),n=a.results||[],R=n.filter(s=>s.cluster&&s.cluster.length>0),T=n.filter(s=>!s.cluster||s.cluster.length===0),S={},C={};n.forEach(s=>{S[s.status||"unknown"]=(S[s.status||"unknown"]||0)+1,s.intent&&(C[s.intent]=(C[s.intent]||0)+1)});const d=i.results||[],L=d.filter(s=>s.keywords_count>0),G=d.reduce((s,x)=>s+(x.volume||0),0),A=d.reduce((s,x)=>s+(x.keywords_count||0),0),V=d.length>0?Math.round(A/d.length):0,U=[...d].sort((s,x)=>(x.volume||0)-(s.volume||0)).slice(0,5).map(s=>({id:s.id,name:s.name||"Unnamed Cluster",volume:s.volume||0,keywords_count:s.keywords_count||0})),u=r.results||[],Y=new Set(u.map(s=>s.id)),I=(h.results||[]).filter(s=>s.idea&&Y.has(s.idea)).length,H=u.length-I,F={},P={};u.forEach(s=>{F[s.status||"new"]=(F[s.status||"new"]||0)+1,s.content_type&&(P[s.content_type]=(P[s.content_type]||0)+1)}),e&&D({keywords:n.length-e.keywords.total,clusters:d.length-e.clusters.total,ideas:u.length-e.ideas.total}),B({keywords:{total:n.length,mapped:R.length,unmapped:T.length,byStatus:S,byIntent:C},clusters:{total:d.length,withIdeas:L.length,withoutIdeas:d.length-L.length,totalVolume:G,avgKeywords:V,topClusters:U},ideas:{total:u.length,queued:I,notQueued:H,byStatus:F,byContentType:P},workflow:{keywordsReady:n.length>0,clustersBuilt:d.length>0,ideasGenerated:u.length>0,readyForWriter:I>0}}),Q(new Date)}catch(a){console.error("Error fetching dashboard data:",a)}finally{O(!1)}};o.useEffect(()=>{f();const a=setInterval(f,3e4);return()=>clearInterval(a)},[l==null?void 0:l.id,g==null?void 0:g.id]);const p=o.useMemo(()=>!e||e.keywords.total===0?0:Math.round(e.keywords.mapped/e.keywords.total*100),[e]),w=o.useMemo(()=>!e||e.clusters.total===0?0:Math.round(e.clusters.withIdeas/e.clusters.total*100),[e]),j=o.useMemo(()=>!e||e.ideas.total===0?0:Math.round(e.ideas.queued/e.ideas.total*100),[e]),k=o.useMemo(()=>{if(!e)return null;const a={chart:{type:"donut",fontFamily:"Outfit, sans-serif",toolbar:{show:!1}},labels:Object.keys(e.keywords.byStatus).filter(r=>e.keywords.byStatus[r]>0),colors:["#465FFF","#10B981","#F59E0B","#EF4444","#8B5CF6"],legend:{position:"bottom",fontFamily:"Outfit",show:!0},dataLabels:{enabled:!1},tooltip:{enabled:!0,y:{formatter:(r,{seriesIndex:h,w:n})=>`${n.globals.labels[h]||""}: ${r}`}},plotOptions:{pie:{donut:{size:"70%",labels:{show:!0,name:{show:!1},value:{show:!0,fontSize:"24px",fontWeight:700,color:"#465FFF",fontFamily:"Outfit",formatter:()=>{const r=Object.values(e.keywords.byStatus).reduce((h,n)=>h+n,0);return r>0?r.toString():"0"}},total:{show:!1}}}}}},i=Object.keys(e.keywords.byStatus).filter(r=>e.keywords.byStatus[r]>0).map(r=>e.keywords.byStatus[r]);return{options:a,series:i}},[e]),v=o.useMemo(()=>{if(!e)return null;const a={chart:{type:"bar",fontFamily:"Outfit, sans-serif",toolbar:{show:!1},height:250},colors:["#465FFF"],plotOptions:{bar:{horizontal:!1,columnWidth:"55%",borderRadius:5}},dataLabels:{enabled:!0},xaxis:{categories:Object.keys(e.ideas.byStatus),labels:{style:{fontFamily:"Outfit"}}},yaxis:{labels:{style:{fontFamily:"Outfit"}}},grid:{strokeDashArray:4}},i=[{name:"Ideas",data:Object.values(e.ideas.byStatus)}];return{options:a,series:i}},[e]),N=o.useMemo(()=>{if(!e||e.clusters.topClusters.length===0)return null;const a={chart:{type:"bar",fontFamily:"Outfit, sans-serif",toolbar:{show:!1},height:300},colors:["#10B981"],plotOptions:{bar:{horizontal:!0,borderRadius:5,dataLabels:{position:"top"}}},dataLabels:{enabled:!0,formatter:r=>r.toLocaleString(),offsetX:10},xaxis:{categories:e.clusters.topClusters.map(r=>r.name),labels:{style:{fontFamily:"Outfit",fontSize:"12px"}}},yaxis:{labels:{style:{fontFamily:"Outfit"}}},tooltip:{y:{formatter:r=>`${r.toLocaleString()} volume`}}},i=[{name:"Search Volume",data:e.clusters.topClusters.map(r=>r.volume)}];return{options:a,series:i}},[e]);if(z&&!e)return t.jsxs(t.Fragment,{children:[t.jsx(_,{title:"Planner Dashboard - IGNY8",description:"Content planning overview"}),t.jsx("div",{className:"flex items-center justify-center h-96",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"inline-block animate-spin rounded-full h-12 w-12 border-4 border-brand-500 border-t-transparent"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading dashboard data..."})]})})]});if(!e&&!z)return t.jsxs(t.Fragment,{children:[t.jsx(_,{title:"Planner Dashboard - IGNY8",description:"Content planning overview"}),t.jsx("div",{className:"text-center py-12",children:t.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:l?"No data available for the selected sector.":"No data available. Select a sector or wait for data to load."})})]});if(!e)return null;const E=[{number:1,title:"Add Keywords",status:e.workflow.keywordsReady?"completed":"pending",count:e.keywords.total,path:"/planner/keywords"},{number:2,title:"Auto Cluster",status:e.workflow.clustersBuilt?"completed":"pending",count:e.clusters.total,path:"/planner/clusters"},{number:3,title:"Generate Ideas",status:e.workflow.ideasGenerated?"completed":"pending",count:e.ideas.total,path:"/planner/ideas"},{number:4,title:"Queue to Writer",status:e.workflow.readyForWriter?"completed":"pending",count:e.ideas.queued,path:"/writer/tasks"}],K=[...e.keywords.unmapped>0?[{text:`${e.keywords.unmapped} keywords unmapped`,action:"Map Keywords",path:"/planner/keywords"}]:[],...e.clusters.withoutIdeas>0?[{text:`${e.clusters.withoutIdeas} clusters without ideas`,action:"Generate Ideas",path:"/planner/clusters"}]:[],...e.ideas.notQueued>0?[{text:`${e.ideas.notQueued} ideas not queued to writer`,action:"Queue to Writer",path:"/planner/ideas"}]:[]];return t.jsxs(t.Fragment,{children:[t.jsx(_,{title:"Planner Dashboard - IGNY8",description:"Content planning overview"}),t.jsxs("div",{className:"space-y-5 sm:space-y-6",children:[t.jsx(ce,{title:"Planner Dashboard",lastUpdated:q,showRefresh:!0,onRefresh:f,badge:{icon:t.jsx(W,{}),color:"blue"}}),t.jsx("div",{className:"rounded-2xl border border-gray-200 bg-gradient-to-br from-brand-50 to-white dark:from-brand-500/10 dark:to-gray-800/50 dark:border-gray-800 p-6 md:p-8",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-gray-600 dark:text-gray-400",children:"Planning Progress"}),t.jsx("h3",{className:"mt-2 text-3xl font-bold text-gray-800 dark:text-white/90",children:e.ideas.queued>0?t.jsxs(t.Fragment,{children:[e.ideas.queued," Ideas Ready for Content Generation"]}):e.ideas.total>0?t.jsxs(t.Fragment,{children:[e.ideas.total," Ideas Generated"]}):e.clusters.total>0?t.jsxs(t.Fragment,{children:[e.clusters.total," Clusters Built"]}):t.jsxs(t.Fragment,{children:[e.keywords.total," Keywords Ready"]})}),t.jsxs("p",{className:"mt-2 text-sm text-gray-500 dark:text-gray-400",children:[e.keywords.total," keywords • ",e.clusters.total," clusters • ",e.ideas.total," ideas"]})]}),t.jsxs("div",{className:"hidden md:flex items-center gap-4",children:[t.jsxs("div",{className:"text-center",children:[t.jsxs("div",{className:"text-2xl font-bold text-brand-500",children:[p,"%"]}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Mapped"})]}),t.jsxs("div",{className:"text-center",children:[t.jsxs("div",{className:"text-2xl font-bold text-success-500",children:[w,"%"]}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"With Ideas"})]}),t.jsxs("div",{className:"text-center",children:[t.jsxs("div",{className:"text-2xl font-bold text-warning-500",children:[j,"%"]}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Queued"})]})]})]})}),t.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-4 md:gap-6",children:[t.jsx(y,{title:"Keywords Ready",value:e.keywords.total,subtitle:`${e.keywords.mapped} mapped • ${e.keywords.unmapped} unmapped`,trend:b.keywords,icon:t.jsx(se,{className:"size-6"}),accentColor:"blue",href:"/planner/keywords",details:[{label:"Total Keywords",value:e.keywords.total},{label:"Mapped",value:e.keywords.mapped},{label:"Unmapped",value:e.keywords.unmapped},{label:"Active",value:e.keywords.byStatus.active||0},{label:"Pending",value:e.keywords.byStatus.pending||0}]}),t.jsx(y,{title:"Clusters Built",value:e.clusters.total,subtitle:`${e.clusters.totalVolume.toLocaleString()} total volume • ${e.clusters.avgKeywords} avg keywords`,trend:b.clusters,icon:t.jsx(ue,{className:"size-6"}),accentColor:"green",href:"/planner/clusters",details:[{label:"Total Clusters",value:e.clusters.total},{label:"With Ideas",value:e.clusters.withIdeas},{label:"Without Ideas",value:e.clusters.withoutIdeas},{label:"Total Volume",value:e.clusters.totalVolume.toLocaleString()},{label:"Avg Keywords",value:e.clusters.avgKeywords}]}),t.jsx(y,{title:"Ideas Generated",value:e.ideas.total,subtitle:`${e.ideas.queued} queued • ${e.ideas.notQueued} pending`,trend:b.ideas,icon:t.jsx(ae,{className:"size-6"}),accentColor:"orange",href:"/planner/ideas",details:[{label:"Total Ideas",value:e.ideas.total},{label:"Queued",value:e.ideas.queued},{label:"Not Queued",value:e.ideas.notQueued},{label:"New",value:e.ideas.byStatus.new||0},{label:"Scheduled",value:e.ideas.byStatus.scheduled||0}]}),t.jsx(y,{title:"Mapping Progress",value:`${p}%`,subtitle:`${e.keywords.mapped} of ${e.keywords.total} keywords mapped`,icon:t.jsx(W,{className:"size-6"}),accentColor:"purple",href:"/planner/keywords",details:[{label:"Mapping Progress",value:`${p}%`},{label:"Mapped Keywords",value:e.keywords.mapped},{label:"Total Keywords",value:e.keywords.total},{label:"Unmapped",value:e.keywords.unmapped}]})]}),t.jsx(c,{title:"Planner Workflow Pipeline",desc:"Track your planning progress through each stage",children:t.jsx(de,{steps:E.map(a=>({number:a.number,title:a.title,status:a.status==="completed"?"completed":a.status==="in_progress"?"in_progress":"pending",count:a.count||0,path:a.path,description:a.title,details:a.status==="completed"?`✓ ${a.title} completed with ${a.count} items`:a.status==="pending"?`→ ${a.title} pending - ${a.count} items ready`:`⟳ ${a.title} in progress`})),onStepClick:a=>{m(a.path)},showConnections:!0})}),t.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-3",children:[t.jsx(c,{title:"Progress & Readiness Summary",desc:"Planning workflow progress tracking",className:"lg:col-span-1",children:t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Keyword Mapping"}),t.jsxs("span",{className:"text-sm font-semibold text-gray-800 dark:text-white/90",children:[p,"%"]})]}),t.jsx($,{value:p,color:"primary",size:"md"}),t.jsxs("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:[e.keywords.mapped," of ",e.keywords.total," keywords mapped"]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Clusters With Ideas"}),t.jsxs("span",{className:"text-sm font-semibold text-gray-800 dark:text-white/90",children:[w,"%"]})]}),t.jsx($,{value:w,color:"success",size:"md"}),t.jsxs("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:[e.clusters.withIdeas," of ",e.clusters.total," clusters have ideas"]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Ideas Queued to Writer"}),t.jsxs("span",{className:"text-sm font-semibold text-gray-800 dark:text-white/90",children:[j,"%"]})]}),t.jsx($,{value:j,color:"warning",size:"md"}),t.jsxs("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:[e.ideas.queued," of ",e.ideas.total," ideas queued"]})]})]})}),t.jsx(c,{title:"Top 5 Clusters by Volume",desc:"Highest volume keyword clusters",className:"lg:col-span-2",children:N?t.jsx(o.Suspense,{fallback:t.jsx("div",{className:"flex items-center justify-center h-[300px]",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-4 border-brand-500 border-t-transparent"})}),children:t.jsx(M,{options:N.options,series:N.series,type:"bar",height:300})}):t.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No clusters data available"})})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[k&&t.jsx(c,{title:"Keywords by Status",desc:"Distribution of keywords across statuses",children:t.jsx(o.Suspense,{fallback:t.jsx("div",{className:"flex items-center justify-center h-[300px]",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-4 border-brand-500 border-t-transparent"})}),children:t.jsx(M,{options:k.options,series:k.series,type:"donut",height:300})})}),v&&t.jsx(c,{title:"Ideas by Status",desc:"Content ideas workflow status",children:t.jsx(o.Suspense,{fallback:t.jsx("div",{className:"flex items-center justify-center h-[300px]",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-4 border-brand-500 border-t-transparent"})}),children:t.jsx(M,{options:v.options,series:v.series,type:"bar",height:300})})})]}),K.length>0&&t.jsx(c,{title:"Next Actions",desc:"Actionable items requiring attention",children:t.jsx("div",{className:"space-y-3",children:K.map((a,i)=>t.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-gradient-to-r from-gray-50 to-white dark:from-gray-900/50 dark:to-gray-800/50 border border-gray-200 dark:border-gray-800 hover:border-brand-300 dark:hover:border-brand-500/30 transition-all group",children:[t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:a.text}),t.jsxs(J,{to:a.path,className:"inline-flex items-center gap-2 text-sm font-medium text-brand-500 hover:text-brand-600 group-hover:translate-x-1 transition-transform",children:[a.action,t.jsx(ie,{className:"size-4"})]})]},i))})})]})]})}export{Se as default};
|