Files
MoneyFlix/public/assets/js/alpine/components/tasks-summary.js
T
1sonhador 8542395fbe Add public campaign analytics functionality
- Add PublicCampaignsController for public campaign analytics
- Add public routes for /public/analytics/{slug} and /api/campaigns/{slug}
- Add public campaign analytics view with charts and KPIs
- Support for campaign sharing via custom slugs
- Real-time analytics with ApexCharts integration
2025-10-15 00:30:00 +01:00

1 line
768 B
JavaScript

function tasksSummary(t){return{tasks:[],completed:0,total:0,loading:!0,error:null,async fetchTasks(){try{this.loading=!0,this.error=null;const s=await fetch(t);if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const a=await s.json();a&&Array.isArray(a)?(this.tasks=a,this.total=a.length,this.completed=a.filter(t=>t.completed).length):a&&a.tasks?(this.tasks=a.tasks,this.total=a.total||a.tasks.length,this.completed=a.completed||a.tasks.filter(t=>t.completed).length):(this.tasks=[],this.total=0,this.completed=0)}catch(t){console.error("Error fetching tasks data:",t),this.error=t.message,this.tasks=[],this.total=0,this.completed=0}finally{this.loading=!1}},init(){this.fetchTasks(),setInterval(()=>{this.fetchTasks()},18e4)}}}export default tasksSummary;