PageSourceSearch

https://app.waspito.com/build/assets/ItemDashboard-D4vqivrK.js

js waspito.com collected 2026-10-07 03:08:43 UTC 10,219 bytes, 1 lines download raw bytes

1import{a as i}from"./axios-BCn5QfZZ.js";import l from"./LineCard-DadL_z_9.js";import n from"./PieCard-9tzYF5Cy.js";import o from"./BarCard-CoMbz6XT.js";import c from"./TopListCard-DsEYR9G_.js";import{n as d}from"./floating-vue-oSNsZTHH.js";import"./loadChart-nuoei8-_.js";import"./vendor-ChPhPn7X.js";import"./realtime-wyMA-lNS.js";import"./lodash-Bj48HpQF.js";const r=()=>({mode:"subscription",window:{from:"—",to:"—"},kpis:{},previous_kpis:{},trend_daily:[],by_status:[],by_buyer_type:[],by_country:[],by_currency:[],renewals:[],payment_health:[],by_payment_method:[],promo_usage:[],commission:null,failed_sections:[]}),u={name:"CatalogItemDashboard",components:{LineCard:l,PieCard:n,BarCard:o,TopListCard:c},props:{analyticsRoute:{type:String,required:!0},entityId:{type:[String,Number],required:!0},mode:{type:String,default:"subscription"},currency:{type:String,default:"XAF"},start_date:String,end_date:String,status:String,payer_type:String,search:String},data:()=>({data:r(),loading:!0,err:null,timer:null}),computed:{isSubscription(){return(this.data.mode||this.mode)==="subscription"},trendLabels(){return(this.data.trend_daily||[]).map(a=>a.date)},trendCounts(){return(this.data.trend_daily||[]).map(a=>Number(a.cnt||0))},trendRevenue(){return(this.data.trend_daily||[]).map(a=>Number(a.revenue||0))},renewalLabels(){return(this.data.renewals||[]).map(a=>a.label)},renewalValues(){return(this.data.renewals||[]).map(a=>Number(a.cnt||0))},promoRows(){return(this.data.promo_usage||[]).map(a=>({...a,revenue:a.discount_total}))},kpiCards(){const a=this.data.kpis||{},t=this.data.previous_kpis||{};return this.isSubscription?[{label:this.$t("catalog.kpi_total_subs"),icon:"users",bar:"bg-theme-1/40",value:this.num(a.total_count),...this.delta(a.total_count,t.total_count)},{label:this.$t("catalog.kpi_active"),icon:"check-badge",bar:"bg-green-400",value:this.num(a.active_count),accent:"text-green-600"},{label:this.$t("catalog.kpi_expiring"),icon:"clock",bar:"bg-orange-400",value:this.num(a.expiring_soon_count),accent:"text-orange-500"},{label:this.$t("catalog.kpi_expired"),icon:"x-circle",bar:"bg-red-400",value:this.num(a.expired_count),accent:"text-red-600"},{label:this.$t("catalog.kpi_cancelled"),icon:"cancel",bar:"bg-gray-400",value:this.num(a.canceled_count),accent:"text-gray-500"},{label:this.$t("catalog.kpi_revenue"),icon:"banknotes",bar:"bg-green-400",value:this.money(a.total_revenue),accent:"text-green-600",...this.delta(a.total_revenue,t.total_revenue)},{label:this.$t("catalog.kpi_avg_value"),icon:"chart-bar",bar:"bg-theme-1/40",value:this.money(a.avg_value)},{label:this.$t("catalog.kpi_renewal_rate"),icon:"trending-up",bar:"bg-theme-1/40",value:a.renewal_rate_pct==null?"—":a.renewal_rate_pct+"%"}]:[{label:this.$t("catalog.kpi_units_sold"),icon:"shopping-bag",bar:"bg-theme-1/40",value:this.num(a.units_sold),...this.delta(a.units_sold,t.units_sold)},{label:this.$t("catalog.kpi_revenue"),icon:"banknotes",bar:"bg-green-400",value:this.money(a.total_revenue),accent:"text-green-600",...this.delta(a.total_revenue,t.total_revenue)},{label:this.$t("catalog.kpi_avg_price"),icon:"chart-bar",bar:"bg-theme-1/40",value:this.money(a.avg_price)},{label:this.$t("catalog.kpi_unique_buyers"),icon:"users",bar:"bg-theme-1/40",value:this.num(a.unique_buyers)},{label:this.$t("catalog.kpi_success_rate"),icon:"check-badge",bar:"bg-green-400",value:a.success_rate_pct==null?"—":a.success_rate_pct+"%",accent:"text-green-600"},{label:this.$t("catalog.kpi_failed"),icon:"x-circle",bar:"bg-red-400",value:this.num(a.failed_count),accent:"text-red-600"},{label:this.$t("catalog.kpi_discount_given"),icon:"tag",bar:"bg-orange-400",value:this.money(a.total_discount),accent:"text-orange-500"}]}},watch:{start_date:"schedule",end_date:"schedule",status:"schedule",payer_type:"schedule",search:"schedule",entityId:"fetch"},created(){this.fetch()},beforeDestroy(){this.timer&&window.clearTimeout(this.timer)},methods:{schedule(){this.timer&&window.clearTimeout(this.timer),this.timer=window.setTimeout(()=>this.fetch(),300)},async fetch(){this.loading=!0;
1try{const a={id:this.entityId};for(const e of["start_date","end_date","status","payer_type","search"])this[e]!==void 0&&this[e]!==null&&this[e]!==""&&(a[e]=this[e]);const{data:t}=await i.get(this.route(this.analyticsRoute,a));this.err=null,this.data={...r(),...t}}catch(a){this.err=a.response&&a.response.data&&a.response.data.message||a.message}finally{this.loading=!1}},pie(a,t,e){return(a||[]).map(s=>({label:s[t]==null||s[t]===""?"—":String(s[t]),value:Number(s[e]||0)}))},num(a){return Number(a||0).toLocaleString()},money(a){return Number(a||0).toLocaleString()+" "+(this.currency||"XAF")},delta(a,t){if(t==null||t===0)return{};const e=Math.round((Number(a||0)-t)/t*1e3)/10;return!isFinite(e)||e===0?{}:{sub:(e>0?"▲ ":"▼ ")+Math.abs(e)+"% "+this.$t("catalog.vs_previous"),deltaClass:e>0?"text-green-600":"text-red-600"}}}};var g=function(){var t=this,e=t._self._c;return e("div",{staticClass:"w-full space-y-6"},[e("div",{staticClass:"flex flex-wrap items-center justify-between gap-2 text-xs"},[e("div",{staticClass:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300 font-medium"},[e("icon",{staticClass:"w-3.5 h-3.5",attrs:{name:"calendar"}}),t._v(" "+t._s(t.data.window.from)+" → "+t._s(t.data.window.to)+" ")],1),e("div",{staticClass:"flex items-center gap-3"},[t.loading?e("span",{staticClass:"inline-flex items-center gap-1.5 text-gray-400"},[e("icon",{staticClass:"w-3.5 h-3.5 animate-spin",attrs:{name:"loading"}}),t._v(" "+t._s(t.$t("general.loading"))+"… ")],1):t._e(),(t.data.failed_sections||[]).length?e("span",{staticClass:"inline-flex items-center gap-1.5 text-amber-600"},[e("icon",{staticClass:"w-3.5 h-3.5",attrs:{name:"exclamation-circle"}}),t._v(" "+t._s(t.$t("catalog.degraded_sections"))+": "+t._s(t.data.failed_sections.join(", "))+" ")],1):t._e()])]),t.err?e("div",{staticClass:"rounded-xl border border-red-200 bg-red-50 text-red-700 px-4 py-3 text-sm flex items-center gap-2"},[e("icon",{staticClass:"w-4 h-4 shrink-0",attrs:{name:"exclamation-circle"}}),t._v(" "+t._s(t.$t("catalog.dashboard_error"))+": "+t._s(t.err)+" ")],1):t._e(),e("div",{staticClass:"grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4"},t._l(t.kpiCards,function(s){return e("div",{key:s.label,staticClass:"relative bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-4 overflow-hidden"},[e("div",{staticClass:"absolute top-0 left-0 h-full w-1",class:s.bar||"bg-theme-1/30"}),e("div",{staticClass:"pl-1.5"},[e("div",{staticClass:"flex items-center gap-1.5 text-[11px] uppercase tracking-wide text-gray-400"},[s.icon?e("icon",{staticClass:"w-3 h-3",attrs:{name:s.icon}}):t._e(),t._v(" "+t._s(s.label)+" ")],1),e("div",{staticClass:"text-2xl font-bold mt-1 tabular-nums",class:s.accent||"text-gray-900 dark:text-gray-100"},[t._v(" "+t._s(s.value)+" ")]),s.sub?e("div",{staticClass:"text-xs mt-1 font-medium",class:s.deltaClass||"text-gray-500"},[t._v(t._s(s.sub))]):t._e()])])}),0),e("div",[e("p",{staticClass:"text-[11px] font-semibold uppercase tracking-wider text-gray-400 mb-2.5"},[t._v(t._s(t.$t("catalog.section_trend")))]),e("div",{staticClass:"grid grid-cols-1 lg:grid-cols-2 gap-6"},[e("LineCard",{attrs:{title:t.isSubscription?t.$t("catalog.chart_sales_per_day"):t.$t("catalog.chart_units_per_day"),labels:t.trendLabels,values:t.trendCounts}}),e("LineCard",{attrs:{title:t.$t("catalog.chart_revenue_per_day"),labels:t.trendLabels,values:t.trendRevenue}})],1)]),t.isSubscription?[e("div",[e("p",{staticClass:"text-[11px] font-semibold uppercase tracking-wider text-gray-400 mb-2.5"},[t._v(t._s(t.$t("catalog.section_breakdowns")))]),e("div",{staticClass:"grid grid-cols-1 lg:grid-cols-3 gap-6"},[e("PieCard",{attrs:{title:t.$t("catalog.by_status"),items:t.pie(t.data.by_status,"status_label","cnt")}}),e("PieCard",{attrs:{title:t.$t("catalog.by_buyer_type"),items:t.pie(t.data.by_buyer_type,"buyer_type","cnt")}}),e("PieCard",{attrs:{title:t.$t("catalog.by_currency"),items:t.pie(t.data.by_currency,"currency","total")}})],1)]),e("div",{staticClass:"grid grid-cols-1 lg:grid-cols-2 gap-6"},[e("BarCard",{attrs:{title:t.$t("catalog.upcoming_renewals"),labels:t.renewalLabels,values:t.renewalValues}}),e("TopListCard",{attrs:{title:t.$t("catalog.by_country"),rows:t.data.by_country||[],"label-key":"country","value-key":"cnt"}})],1),t.data.commission?e("div",{staticClass:"relative bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-4 overflow-hidden"},[e("div",{staticClass:"absolute top-0 left-0 h-full w-1 bg-green-400"}),e("div",{staticClass:"pl-1.5 flex flex-wrap items-center justify-between gap-3"},[e("span",{staticClass:"inline-flex items-center gap-2 font-medium text-gray-700 dark:text-gray-200"},[e("icon",{staticClass:"w-4 h-4 text-green-600",attrs:{name:"commission"}}),t._v(" "+t._s(t.$t("catalog.commission_earned"))+" ")],1),e("span",{staticClass:"text-xl font-bold text-green-600 tabular-nums"},[t._v(t._s(t.money(t.data.commission.total_earned)))])]),e("p",{staticClass:"pl-1.5 text-xs text-gray-500 mt-1"},[t._v(" "+t._s(t.$t("catalog.commission_hint",{count:t.data.commission.count}))+" ")])]):t._e()]:[e("div",[e("p",{staticClass:"text-[11px] font-semibold uppercase tracking-wider text-gray-400 mb-2.5"},[t._v(t._s(t.$t("catalog.section_breakdowns")))]),e("div",{staticClass:"grid grid-cols-1 lg:grid-cols-3 gap-6"},[e("PieCard",{attrs:{title:t.$t("catalog.payment_health"),items:t.pie(t.data.payment_health,"status_label","cnt")}}),e("PieCard",{attrs:{title:t.$t("catalog.by_payment_method"),items:t.pie(t.data.by_payment_method,"payment_method_label","cnt")}}),e("PieCard",{attrs:{title:t.$t("catalog.by_buyer_type"),items:t.pie(t.data.by_buyer_type,"buyer_type","cnt")}})],1)]),e("div",{staticClass:"grid grid-cols-1 lg:grid-cols-2 gap-6"},[e("TopListCard",{attrs:{title:t.$t("catalog.by_country"),rows:t.data.by_country||[],"label-key":"country","value-key":"cnt"}}),e("TopListCard",{attrs:{title:t.$t("catalog.promo_usage"),rows:t.promoRows,"label-key":"code","value-key":"cnt"}})],1)]],2)},_=[],m=d(u,g,_,!1,null,null);const $=m.exports;export{$ as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.