PageSourceSearch

https://opravdovezlociny.cz/assets/AdminStatsEshop-BeChBg8b.js

js opravdovezlociny.cz collected 2026-10-02 04:56:29 UTC 10,997 bytes, 6 lines download raw bytes

1import{e as B,r as v,m as D,j as e,aW as G,ai as m,s as K}from"./index-Cbf19BJ2.js";import{A as Z,T as E}from"./AdminLayout-BO09t3h9.js";import{C as h,a as j,b as y,c as p}from"./card-DgudV2Qs.js";import{S as H,a as U,b as Y,c as X,d as I}from"./select-B8fJMIbm.js";import{S as Q}from"./shopping-cart-J9DiLkwU.js";import{P as J}from"./package-C0aFhqOE.js";import{g as ee,L as M,X as b,Y as g,f as te,R as C,C as se,a as w,T as A,b as q,A as L,B as P,c as re}from"./ComposedChart-C6FWem8s.js";import{B as ae,A as oe,a as ie}from"./BarChart-DwWuhoaH.js";import"./wallet-DiTxM8js.js";import"./list-D4zz6wAQ.js";import"./plus-BhsMqakM.js";import"./users-Xzu6q5UA.js";import"./zap-bic735yl.js";import"./circle-dot-BggEKS0Q.js";import"./truck-CiBM9Qd9.js";import"./mic-B7DTX7IA.js";import"./eye-Bp1ggn78.js";import"./upload-C7UHHK-4.js";import"./code-cui-3nIF.js";import"./file-code-Dc3Knbwk.js";import"./refresh-cw-jn-MXuPZ.js";import"./shield-CfgkgLd3.js";import"./credit-card-u85TQkWj.js";import"./globe-CgQQH_HA.js";import"./search-BLo06ZQ6.js";import"./ticket-G16NpKMh.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const le=B("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);var ne=ee({chartName:"LineChart",GraphicalChild:M,axisComponents:[{axisType:"xAxis",AxisComp:b},{axisType:"yAxis",AxisComp:g}],formatAxisMap:te});function n(l){return new Intl.NumberFormat("cs-CZ",{style:"currency",currency:"CZK",maximumFractionDigits:0}).format(l)}function z(l){return new Intl.NumberFormat("cs-CZ").format(l)}function Le(){const[l,F]=v.useState("all"),{data:a,isLoading:_}=D({queryKey:["stats-eshop-monthly"],queryFn:async()=>{const{data:t,error:s}=await K.from("oz1_kalendar_mesice").select("*").order("mesic",{ascending:!0});if(s)throw s;return t||[]}}),{data:N,isLoading:T}=D({queryKey:["stats-eshop-daily"],queryFn:async()=>{const t=new Date;t.setDate(t.getDate()-90);const{data:s,error:r}=await K.from("oz1_kalendar").select("datum, oz_pocet, oz_trzba, eshop_uip, eshop_view").gte("datum",t.toISOString().split("T")[0]).order("datum",{ascending:!0});if(r)throw r;return s||[]}}),{data:R,isLoading:O}=D({queryKey:["stats-eshop-top-products"],queryFn:async()=>{const{data:t,error:s}=await K.from("oz1_eshop_orders_items").select("title, mnozstvi, cena_celkem, db_id").eq("eshop","oz").not("title","is",null).order("id",{ascending:!1}).limit(1e3);if(s)throw s;const r=new Map;for(const x of t||[]){const c=x.title||"N/A",i=r.get(c)||{title:c,qty:0,revenue:0};i.qty+=x.mnozstvi||1,i.revenue+=x.cena_celkem||0,r.set(c,i)}return Array.from(r.values()).sort((x,c)=>c.qty-x.qty).slice(0,10)}}),$=v.useMemo(()=>{if(!a)return[];const t=new Set(a.map(s=>{var r;return(r=s.mesic)==null?void 0:r.split("-")[0]}).filter(Boolean));return Array.from(t).sort().reverse()},[a]),o=v.useMemo(()=>a?a.filter(t=>{var s;return l==="all"||((s=t.mesic)==null?void 0:s.startsWith(l))}).map(t=>({month:t.mesic,revenue:t.trzba_oz||0,orders:t.pocet_oz||0,vouchers:t.trzba_poukaz||0,voucherCount:t.pocet_poukaz||0,google:t.google||0})):[],[a,l]),d=v.useMemo(()=>{if(!o.length)return null;const t=o.reduce((u,f)=>u+f.revenue,0),s=o.reduce((u,f)=>u+f.orders,0),r=s>0?t/s:0,x=o.reduce((u,f)=>u+f.vouchers,0),c=o[o.length-1],i=o[o.length-2],V=i&&i.revenue>0?(c.revenue-i.revenue)/i.revenue*100:0,W=i&&i.orders>0?(c.orders-i.orders)/i.orders*100:0;return{totalRevenue:t,totalOrders:s,avgOrderValue:r,totalVouchers:x,revChange:V,ordChange:W}},[o]),k=_||T;return e.jsx(Z,{title:"Statistiky – E-shop",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(G,{className:"w-5 h-5 text-gray-500"}),e.jsxs(H,{value:l,onValueChange:F,children:[e.jsx(U,{className:"w-40",children:e.jsx(Y,{placeholder:"Rok"})}),e.jsxs(X,{children:[e.jsx(I,{value:"all",children:"Vše"}),$.map(t=>e.jsx(I,{value:t,children:t},t))]})]})]}),k?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[...Array(4)].map((t,s)=>e.jsx(m,{className:"h-28"},s))}):d&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(S,{title:"Celkové tržby",value:n(d.totalRevenue),change:d.revChange,icon:e.jsx(le,{className:"w-5 h-5"}),color:"text-yellow-600 bg-yellow-50"}),e.jsx(S,{title:"Počet objednávek",value:z(d.totalOrders),change:d.ordChange,icon:e.jsx(Q,{className:"w-5 h-5"}),color:"text-blue-600 bg-blue-50"}),e.jsx(S,{title:"Průměrná objednávka",value:n(d.avgOrderValue),icon:e.jsx(E,{className:"w-5 h-5"}),color:"text-green-600 bg-green-50"}),e.jsx(S,{title:"Tržby z poukazů",value:n(d.totalVouchers),icon:e.jsx(J,{className:"w-5 h-5"}),color:"text-purple-600 bg-purple-50"})]}),e.jsxs(h,{children:[e.jsx(j,{children:e.jsx(y,{className:"text-lg",children:"Tržby a objednávky po měsících"})}),e.jsx(p,{children:k?e.jsx(m,{className:"h-80"}):e.jsx(C,{width:"100%",height:350,children:e.jsxs(se,{data:o,children:[e.jsx(w,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),e.jsx(b,{dataKey:"month",tick:{fontSize:12}}),e.jsx(g,{yAxisId:"left",tickFormatter:t=>`${(t/1e3).toFixed(0)}k`}),e.jsx(g,{yAxisId:"right",orientation:"right"}
6),e.jsx(A,{formatter:(t,s)=>s==="Tržby"?n(t):z(t),labelFormatter:t=>`Měsíc: ${t}`}),e.jsx(q,{}),e.jsx(L,{yAxisId:"left",type:"monotone",dataKey:"revenue",name:"Tržby",fill:"#fbbf2440",stroke:"#f59e0b",strokeWidth:2}),e.jsx(P,{yAxisId:"right",dataKey:"orders",name:"Objednávky",fill:"#3b82f6",radius:[4,4,0,0],barSize:20})]})})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(h,{children:[e.jsx(j,{children:e.jsx(y,{className:"text-lg",children:"Denní návštěvnost e-shopu (90 dní)"})}),e.jsx(p,{children:T?e.jsx(m,{className:"h-64"}):e.jsx(C,{width:"100%",height:280,children:e.jsxs(re,{data:N||[],children:[e.jsx(w,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),e.jsx(b,{dataKey:"datum",tick:{fontSize:10},tickFormatter:t=>t==null?void 0:t.slice(5)}),e.jsx(g,{}),e.jsx(A,{labelFormatter:t=>`Den: ${t}`}),e.jsx(q,{}),e.jsx(L,{type:"monotone",dataKey:"eshop_uip",name:"Unikáty",fill:"#3b82f640",stroke:"#3b82f6",strokeWidth:2}),e.jsx(L,{type:"monotone",dataKey:"eshop_view",name:"Zobrazení",fill:"#10b98140",stroke:"#10b981",strokeWidth:1})]})})})]}),e.jsxs(h,{children:[e.jsx(j,{children:e.jsx(y,{className:"text-lg",children:"Denní tržby e-shopu (90 dní)"})}),e.jsx(p,{children:T?e.jsx(m,{className:"h-64"}):e.jsx(C,{width:"100%",height:280,children:e.jsxs(ae,{data:N||[],children:[e.jsx(w,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),e.jsx(b,{dataKey:"datum",tick:{fontSize:10},tickFormatter:t=>t==null?void 0:t.slice(5)}),e.jsx(g,{tickFormatter:t=>`${(t/1e3).toFixed(0)}k`}),e.jsx(A,{formatter:t=>n(t),labelFormatter:t=>`Den: ${t}`}),e.jsx(P,{dataKey:"oz_trzba",name:"Tržby",fill:"#f59e0b",radius:[2,2,0,0]})]})})})]})]}),e.jsxs(h,{children:[e.jsx(j,{children:e.jsx(y,{className:"text-lg",children:"Google Ads náklady vs. Tržby"})}),e.jsx(p,{children:k?e.jsx(m,{className:"h-72"}):e.jsx(C,{width:"100%",height:300,children:e.jsxs(ne,{data:o,children:[e.jsx(w,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),e.jsx(b,{dataKey:"month",tick:{fontSize:12}}),e.jsx(g,{tickFormatter:t=>`${(t/1e3).toFixed(0)}k`}),e.jsx(A,{formatter:t=>n(t)}),e.jsx(q,{}),e.jsx(M,{type:"monotone",dataKey:"revenue",name:"Tržby e-shop",stroke:"#f59e0b",strokeWidth:2,dot:{r:3}}),e.jsx(M,{type:"monotone",dataKey:"google",name:"Google Ads",stroke:"#ef4444",strokeWidth:2,dot:{r:3}})]})})})]}),e.jsxs(h,{children:[e.jsx(j,{children:e.jsx(y,{className:"text-lg",children:"Top 10 produktů"})}),e.jsx(p,{children:O?e.jsx(m,{className:"h-64"}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-200",children:[e.jsx("th",{className:"text-left py-3 px-2 font-medium text-gray-500",children:"#"}),e.jsx("th",{className:"text-left py-3 px-2 font-medium text-gray-500",children:"Produkt"}),e.jsx("th",{className:"text-right py-3 px-2 font-medium text-gray-500",children:"Prodáno ks"}),e.jsx("th",{className:"text-right py-3 px-2 font-medium text-gray-500",children:"Tržby"})]})}),e.jsx("tbody",{children:(R||[]).map((t,s)=>e.jsxs("tr",{className:"border-b border-gray-100 hover:bg-gray-50",children:[e.jsx("td",{className:"py-2 px-2 text-gray-400",children:s+1}),e.jsx("td",{className:"py-2 px-2 font-medium",children:t.title}),e.jsx("td",{className:"py-2 px-2 text-right",children:z(t.qty)}),e.jsx("td",{className:"py-2 px-2 text-right font-medium",children:n(t.revenue)})]},s))})]})})})]}),e.jsxs(h,{children:[e.jsx(j,{children:e.jsx(y,{className:"text-lg",children:"Měsíční přehled"})}),e.jsx(p,{children:k?e.jsx(m,{className:"h-64"}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-200",children:[e.jsx("th",{className:"text-left py-3 px-2 font-medium text-gray-500",children:"Měsíc"}),e.jsx("th",{className:"text-right py-3 px-2 font-medium text-gray-500",children:"Objednávky"}),e.jsx("th",{className:"text-right py-3 px-2 font-medium text-gray-500",children:"Tržby"}),e.jsx("th",{className:"text-right py-3 px-2 font-medium text-gray-500",children:"Poukazy"}),e.jsx("th",{className:"text-right py-3 px-2 font-medium text-gray-500",children:"Google Ads"}),e.jsx("th",{className:"text-right py-3 px-2 font-medium text-gray-500",children:"ROAS"})]})}),e.jsx("tbody",{children:[...o].reverse().map((t,s)=>{const r=t.google>0?(t.revenue/t.google).toFixed(2):"–";return e.jsxs("tr",{className:"border-b border-gray-100 hover:bg-gray-50",children:[e.jsx("td",{className:"py-2 px-2 font-medium",children:t.month}),e.jsx("td",{className:"py-2 px-2 text-right",children:z(t.orders)}),e.jsx("td",{className:"py-2 px-2 text-right font-medium",children:n(t.revenue)}),e.jsx("td",{className:"py-2 px-2 text-right",children:n(t.vouchers)}),e.jsx("td",{className:"py-2 px-2 text-right",children:n(t.google)}),e.jsxs("td",{className:"py-2 px-2 text-right font-medium",children:[r,"×"]})]},s)})})]})})})]})]})})}function S({title:l,value:F,change:a,icon:_,color:N}){return e.jsx(h,{children:e.jsxs(p,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("span",{className:"text-sm text-gray-500",children:l}),e.jsx("div",{className:`p-2 rounded-lg ${N}`,children:_})]}),e.jsx("div",{className:"text-2xl font-bold text-gray-900",children:F}),a!==void 0&&a!==0&&e.jsxs("div",{className:`flex items-center gap-1 mt-1 text-sm ${a>0?"text-green-600":"text-red-600"}`,children:[a>0?e.jsx(oe,{className:"w-4 h-4"}):e.jsx(ie,{className:"w-4 h-4"}),e.jsxs("span",{children:[Math.abs(a).toFixed(1),"% vs. předchozí měsíc"]})]})]})})}export{Le 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.