Files
MoneyFlix/public/assets/js/alpine/dashboards/dashboard-nft.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
1.5 KiB
JavaScript

function dashboardNft(){return{recentSales:[],topCollections:[],trendingCollections:[],totalVolume:0,activeUsers:0,loading:!0,error:null,async init(){this.loading=!0;try{await this.loadDashboardData()}catch(t){console.error("Error initializing NFT dashboard:",t),this.error="Failed to load dashboard data"}finally{this.loading=!1}},async loadDashboardData(){try{const[t,a,o]=await Promise.all([fetch("/api/nft/dashboard/recent-sales"),fetch("/api/nft/dashboard/top-collections"),fetch("/api/nft/dashboard/summary")]);if(t.ok?this.recentSales=await t.json():(this.recentSales=[],console.warn("Failed to load recent sales")),a.ok?this.topCollections=await a.json():(this.topCollections=[],console.warn("Failed to load top collections")),o.ok){const t=await o.json();this.totalVolume=t.total_volume||0,this.activeUsers=t.active_users||0,this.trendingCollections=t.trending_collections||[]}else console.warn("Failed to load NFT summary")}catch(t){console.error("Error loading NFT dashboard data:",t),this.recentSales=[],this.topCollections=[],this.trendingCollections=[],this.totalVolume=0,this.activeUsers=0}},async refresh(){await this.loadDashboardData()},formatCurrency:t=>new Intl.NumberFormat("pt-PT",{style:"currency",currency:"EUR"}).format(t),formatNumber:t=>t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":t.toString(),formatDate:t=>new Date(t).toLocaleDateString("pt-PT",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})}}export default dashboardNft;