Files
igny8/frontend/dist/assets/js/Home-whN-JQCS.js
IGNY8 VPS (Salman) 3c100be1cf more
2025-11-13 14:12:36 +00:00

2 lines
18 KiB
JavaScript

import{r as x,j as e,L as u,R as B}from"./chunk-UIGDSWPH-BhuNDbxn.js";import{c as E,f as F,a as K,u as U,b as M,d as O,P as W,S as Y,e as y,g as v,h as H,i as q,j as J,k as Q,l as V,m as X}from"./main-af3pcbZa.js";import{C as p}from"./ComponentCard-C2b5w2__.js";import{E as b}from"./EnhancedMetricCard-YOSFdLZV.js";import{C as h}from"./Card-CAsJMMfR.js";import{S as k}from"./check-circle--AtVWUy0.js";import{S as m}from"./file-CeG1FbGg.js";import{S as f}from"./arrow-right-DC7G5FiV.js";import{S as Z}from"./group-Dnur-I7a.js";import"./arrow-up-Ba39LAbN.js";const C=E((s,g)=>({balance:null,usageSummary:null,loading:!1,error:null,loadBalance:async()=>{s({loading:!0,error:null});try{const l=await K();s({balance:l,loading:!1})}catch(l){s({error:l.message,loading:!1})}},loadUsageSummary:async(l,n)=>{s({loading:!0,error:null});try{const c=await F(l,n);s({usageSummary:c,loading:!1})}catch(c){s({error:c.message,loading:!1})}},reset:()=>{s({balance:null,usageSummary:null,loading:!1,error:null})}}));function ee(){const{balance:s,loading:g,loadBalance:l}=C();if(x.useEffect(()=>{l()},[l]),g&&!s)return e.jsx(p,{title:"Credit Balance",desc:"Loading...",children:e.jsx("div",{className:"animate-pulse",children:"Loading credit balance..."})});if(!s)return null;const n=s.plan_credits_per_month>0?s.credits_used_this_month/s.plan_credits_per_month*100:0;return e.jsx(p,{title:"Credit Balance",desc:"Current credit status and usage",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Current Credits"}),e.jsx("span",{className:"text-2xl font-bold text-primary",children:s.credits})]})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Used This Month"}),e.jsxs("span",{className:"text-sm font-medium",children:[s.credits_used_this_month," / ",s.plan_credits_per_month]})]}),e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2.5 dark:bg-gray-700",children:e.jsx("div",{className:"bg-primary h-2.5 rounded-full transition-all",style:{width:`${Math.min(n,100)}%`}})})]}),e.jsx("div",{className:"pt-2 border-t border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Remaining"}),e.jsx("span",{className:"text-sm font-medium text-success",children:s.credits_remaining})]})})]})})}function te(){const{usageSummary:s,loading:g,loadUsageSummary:l}=C(),[n,c]=x.useState("month");return x.useEffect(()=>{const i=new Date;let o;n==="week"?o=new Date(i.getTime()-6048e5).toISOString().split("T")[0]:n==="month"?o=new Date(i.getFullYear(),i.getMonth(),1).toISOString().split("T")[0]:o=new Date(i.getFullYear(),0,1).toISOString().split("T")[0];const r=i.toISOString().split("T")[0];l(o,r)},[n,l]),g&&!s?e.jsx(p,{title:"Usage Summary",desc:"Loading...",children:e.jsx("div",{className:"animate-pulse",children:"Loading usage data..."})}):s?e.jsx(p,{title:"Usage Summary",desc:"Credit usage breakdown by operation and model",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end items-center mb-4",children:e.jsxs("select",{className:"h-9 rounded-lg border border-gray-300 bg-transparent px-3 py-2 text-sm shadow-theme-xs text-gray-800 focus:border-brand-300 focus:outline-hidden focus:ring-3 focus:ring-brand-500/10 dark:border-gray-700 dark:bg-gray-900 dark:text-white/90 dark:focus:border-brand-800",value:n,onChange:i=>c(i.target.value),children:[e.jsx("option",{value:"week",children:"Last 7 Days"}),e.jsx("option",{value:"month",children:"This Month"}),e.jsx("option",{value:"year",children:"This Year"})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Total Credits Used"}),e.jsx("div",{className:"text-2xl font-bold",children:s.total_credits_used})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Total Cost"}),e.jsxs("div",{className:"text-2xl font-bold",children:["$",(Number(s.total_cost_usd)||0).toFixed(2)]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-semibold mb-2",children:"By Operation"}),e.jsxs("div",{className:"space-y-2",children:[Object.entries(s.by_operation).map(([i,o])=>e.jsxs("div",{className:"flex justify-between items-center text-sm",children:[e.jsx("span",{className:"capitalize",children:i.replace("_"," ")}),e.jsxs("span",{className:"font-medium",children:[o.credits," credits ($",(Number(o.cost)||0).toFixed(2),")"]})]},i)),Object.keys(s.by_operation).length===0&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No usage data available"})]})]})]})}):null}const w=[{id:1,title:"Discover Keywords",description:"Find high-volume keywords from our global database",icon:e.jsx(y,{}),color:"blue",path:"/planner/keyword-opportunities"},{id:2,title:"Cluster Keywords",description:"Group related keywords into strategic clusters",icon:e.jsx(Z,{}),color:"purple",path:"/planner/clusters"},{id:3,title:"Generate Ideas",description:"AI creates content ideas from keyword clusters",icon:e.jsx(v,{}),color:"orange",path:"/planner/ideas"},{id:4,title:"Create Tasks",description:"Convert ideas into actionable writing tasks",icon:e.jsx(k,{}),color:"indigo",path:"/writer/tasks"},{id:5,title:"Write Content",description:"AI generates full content pieces automatically",icon:e.jsx(m,{}),color:"green",path:"/writer/content"},{id:6,title:"Generate Images",description:"Create featured and in-article images",icon:e.jsx(m,{}),color:"pink",path:"/writer/images"},{id:7,title:"Publish",description:"Content ready for publication",icon:e.jsx(k,{}),color:"success",path:"/writer/published"}];function ge(){const s=U(),{activeSite:g}=M(),{activeSector:l}=O(),[n,c]=x.useState(null),[i,o]=x.useState(!0),[r,d]=x.useState({keywords:{enabled:!1,keywordsPerCycle:50,autoCluster:!0,maxKeywordsPerCluster:10},ideas:{enabled:!1,autoGenerate:!0,ideasPerCluster:3},content:{enabled:!1,autoCreateTasks:!0,autoGenerateContent:!1},images:{enabled:!1,autoGenerate:!1}}),S=async()=>{try{o(!0);const[t,a,I,A,T,G]=await Promise.all([H({page_size:1,site_id:void 0}),q({page_size:1,site_id:void 0}),J({page_size:1,site_id:void 0}),Q({page_size:1,site_id:void 0}),V({page_size:1,site_id:void 0}),X({page_size:1,site_id:void 0})]),j=t.count||0,z=a.count||0,R=I.count||0,P=A.count||0,$=T.count||0,L=G.count||0,N=0,D=j>0?Math.round(N/j*100):0;c({totalKeywords:j,totalClusters:z,totalIdeas:R,totalTasks:P,totalContent:$,totalImages:L,publishedContent:N,workflowCompletionRate:D})}catch(t){console.error("Error fetching insights:",t),s.error(`Failed to load insights: ${t.message}`)}finally{o(!1)}};x.useEffect(()=>{S()},[g,l]);const _={blue:"bg-blue-100 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400",purple:"bg-purple-100 dark:bg-purple-900/20 text-purple-600 dark:text-purple-400",orange:"bg-orange-100 dark:bg-orange-900/20 text-orange-600 dark:text-orange-400",indigo:"bg-indigo-100 dark:bg-indigo-900/20 text-indigo-600 dark:text-indigo-400",green:"bg-green-100 dark:bg-green-900/20 text-green-600 dark:text-green-400",pink:"bg-pink-100 dark:bg-pink-900/20 text-pink-600 dark:text-pink-400",success:"bg-green-100 dark:bg-green-900/20 text-green-600 dark:text-green-400"};return e.jsxs(e.Fragment,{children:[e.jsx(W,{title:"Dashboard - IGNY8",description:"IGNY8 AI-Powered Content Creation Dashboard"}),e.jsx("div",{className:"mb-8",children:e.jsxs("div",{className:"bg-gradient-to-r from-brand-500 to-purple-600 rounded-2xl p-8 md:p-12 text-white relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-grid-white/10 [mask-image:linear-gradient(0deg,white,transparent)]"}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-4",children:"AI-Powered Content Creation Workflow"}),e.jsx("p",{className:"text-xl text-white/90 mb-6 max-w-2xl",children:"Transform keywords into published content with intelligent automation. From discovery to publication, IGNY8 streamlines your entire content creation process."}),e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs(u,{to:"/planner/keyword-opportunities",className:"px-6 py-3 bg-white text-brand-600 rounded-lg font-semibold hover:bg-gray-100 transition-colors inline-flex items-center gap-2",children:["Get Started",e.jsx(f,{className:"size-5"})]}),e.jsxs(u,{to:"/schedules",className:"px-6 py-3 bg-white/10 text-white rounded-lg font-semibold hover:bg-white/20 transition-colors inline-flex items-center gap-2 border border-white/20",children:["Configure Automation",e.jsx(Y,{className:"size-5"})]})]})]})]})}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Account-Wide Insights"}),e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"All sites aggregated"})]}),i?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[1,2,3,4].map(t=>e.jsx("div",{className:"h-32 bg-gray-200 dark:bg-gray-700 rounded-lg animate-pulse"},t))}):n?e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(b,{title:"Total Keywords",value:n.totalKeywords.toLocaleString(),icon:e.jsx(y,{}),accentColor:"blue",href:"/planner/keywords"}),e.jsx(b,{title:"Content Pieces",value:n.totalContent.toLocaleString(),icon:e.jsx(m,{}),accentColor:"green",href:"/writer/content"}),e.jsx(b,{title:"Images Generated",value:n.totalImages.toLocaleString(),icon:e.jsx(m,{}),accentColor:"purple",href:"/writer/images"}),e.jsx(b,{title:"Workflow Completion",value:`${n.workflowCompletionRate}%`,icon:e.jsx(k,{}),accentColor:"success"})]}):null]}),e.jsxs("div",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-6",children:"How It Works"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 xl:grid-cols-7 gap-4",children:w.map((t,a)=>e.jsx(u,{to:t.path,className:"group",children:e.jsx(h,{className:"p-6 hover:shadow-lg transition-all duration-200 border-2 hover:border-brand-500 dark:hover:border-brand-400 h-full",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:`w-16 h-16 rounded-xl ${_[t.color]} flex items-center justify-center mb-4 group-hover:scale-110 transition-transform`,children:e.jsx("div",{className:"w-8 h-8 flex items-center justify-center flex-shrink-0",children:B.cloneElement(t.icon,{className:"w-8 h-8 flex-shrink-0"})})}),e.jsxs("div",{className:"text-sm font-semibold text-gray-500 dark:text-gray-400 mb-1",children:["Step ",t.id]}),e.jsx("h3",{className:"text-lg font-bold text-gray-900 dark:text-white mb-2",children:t.title}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:t.description}),a<w.length-1&&e.jsx("div",{className:"hidden xl:block absolute top-1/2 -right-2 transform -translate-y-1/2 translate-x-full",children:e.jsx(f,{className:"size-6 text-gray-400"})})]})})},t.id))})]}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Automation Setup"}),e.jsxs(u,{to:"/schedules",className:"text-brand-600 dark:text-brand-400 hover:text-brand-700 dark:hover:text-brand-300 font-medium inline-flex items-center gap-2",children:["Advanced Settings",e.jsx(f,{className:"size-4"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs(h,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-100 dark:bg-blue-900/20 flex items-center justify-center",children:e.jsx(y,{className:"size-5 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900 dark:text-white",children:"Keywords Automation"})]}),e.jsx("button",{onClick:()=>d(t=>({...t,keywords:{...t.keywords,enabled:!t.keywords.enabled}})),className:`w-12 h-6 rounded-full transition-colors ${r.keywords.enabled?"bg-brand-500":"bg-gray-300 dark:bg-gray-600"}`,children:e.jsx("div",{className:`w-5 h-5 bg-white rounded-full transition-transform ${r.keywords.enabled?"translate-x-6":"translate-x-0.5"}`})})]}),r.keywords.enabled&&e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Keywords per cycle"}),e.jsx("input",{type:"number",value:r.keywords.keywordsPerCycle,onChange:t=>d(a=>({...a,keywords:{...a.keywords,keywordsPerCycle:parseInt(t.target.value)||0}})),className:"mt-1 w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:r.keywords.autoCluster,onChange:t=>d(a=>({...a,keywords:{...a.keywords,autoCluster:t.target.checked}})),className:"rounded"}),e.jsx("label",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Auto-cluster keywords"})]})]})]}),e.jsxs(h,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-orange-100 dark:bg-orange-900/20 flex items-center justify-center",children:e.jsx(v,{className:"size-5 text-orange-600 dark:text-orange-400"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900 dark:text-white",children:"Ideas Automation"})]}),e.jsx("button",{onClick:()=>d(t=>({...t,ideas:{...t.ideas,enabled:!t.ideas.enabled}})),className:`w-12 h-6 rounded-full transition-colors ${r.ideas.enabled?"bg-brand-500":"bg-gray-300 dark:bg-gray-600"}`,children:e.jsx("div",{className:`w-5 h-5 bg-white rounded-full transition-transform ${r.ideas.enabled?"translate-x-6":"translate-x-0.5"}`})})]}),r.ideas.enabled&&e.jsx("div",{className:"space-y-3 mt-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:r.ideas.autoGenerate,onChange:t=>d(a=>({...a,ideas:{...a.ideas,autoGenerate:t.target.checked}})),className:"rounded"}),e.jsx("label",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Auto-generate ideas from clusters"})]})})]}),e.jsxs(h,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-green-100 dark:bg-green-900/20 flex items-center justify-center",children:e.jsx(m,{className:"size-5 text-green-600 dark:text-green-400"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900 dark:text-white",children:"Content Automation"})]}),e.jsx("button",{onClick:()=>d(t=>({...t,content:{...t.content,enabled:!t.content.enabled}})),className:`w-12 h-6 rounded-full transition-colors ${r.content.enabled?"bg-brand-500":"bg-gray-300 dark:bg-gray-600"}`,children:e.jsx("div",{className:`w-5 h-5 bg-white rounded-full transition-transform ${r.content.enabled?"translate-x-6":"translate-x-0.5"}`})})]}),r.content.enabled&&e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:r.content.autoCreateTasks,onChange:t=>d(a=>({...a,content:{...a.content,autoCreateTasks:t.target.checked}})),className:"rounded"}),e.jsx("label",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Auto-create tasks from ideas"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:r.content.autoGenerateContent,onChange:t=>d(a=>({...a,content:{...a.content,autoGenerateContent:t.target.checked}})),className:"rounded"}),e.jsx("label",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Auto-generate content from tasks"})]})]})]}),e.jsxs(h,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-100 dark:bg-purple-900/20 flex items-center justify-center",children:e.jsx(m,{className:"size-5 text-purple-600 dark:text-purple-400"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900 dark:text-white",children:"Images Automation"})]}),e.jsx("button",{onClick:()=>d(t=>({...t,images:{...t.images,enabled:!t.images.enabled}})),className:`w-12 h-6 rounded-full transition-colors ${r.images.enabled?"bg-brand-500":"bg-gray-300 dark:bg-gray-600"}`,children:e.jsx("div",{className:`w-5 h-5 bg-white rounded-full transition-transform ${r.images.enabled?"translate-x-6":"translate-x-0.5"}`})})]}),r.images.enabled&&e.jsx("div",{className:"space-y-3 mt-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:r.images.autoGenerate,onChange:t=>d(a=>({...a,images:{...a.images,autoGenerate:t.target.checked}})),className:"rounded"}),e.jsx("label",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Auto-generate images for content"})]})})]})]})]}),e.jsxs("div",{className:"grid grid-cols-12 gap-4 md:gap-6",children:[e.jsx("div",{className:"col-span-12 xl:col-span-4",children:e.jsx(ee,{})}),e.jsx("div",{className:"col-span-12 xl:col-span-8",children:e.jsx(te,{})})]})]})}export{ge as default};