PageSourceSearch

https://beautiqa.pl/assets/AdminView-CSEP2pk9.js

js beautiqa.pl collected 2026-09-24 15:10:26 UTC 6,564 bytes, 1 lines download raw bytes

1import{p as D,b as T}from"./index-BwLWZljh.js";import{f as O,r as d,g as S,b as o,c as l,h as t,k,F as u,m as y,B as N,s as B,t as a,l as h,i as I,j as M,u as j,p as g,q as K}from"./vue-BuP3QEGM.js";const W={class:"max-w-6xl mx-auto p-4 pb-32"},V={class:"flex items-center gap-2 mb-6"},$=["onClick"],F={key:0,class:"text-center py-12 text-gray-400"},U={key:1,class:"text-center py-12"},R={class:"text-red-500 mb-3"},q={class:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-6"},G={class:"bg-white rounded-lg shadow-sm p-4"},H={class:"text-2xl font-bold text-gray-800"},L={class:"bg-white rounded-lg shadow-sm p-4"},Y={class:"text-2xl font-bold text-green-700"},Z={class:"text-[10px] text-gray-400"},J={class:"bg-white rounded-lg shadow-sm p-4"},P={class:"text-2xl font-bold text-gray-800"},Q={class:"bg-white rounded-lg shadow-sm p-4"},X={class:"text-sm font-bold text-gray-800 truncate"},tt={class:"text-[10px] text-gray-400"},et={class:"bg-white rounded-lg shadow-sm p-4 mb-6"},st={key:0,class:"text-sm text-gray-400 py-6 text-center"},at={key:1,class:"flex items-end gap-1 h-40 overflow-x-auto pb-6"},ot=["title"],lt={class:"text-[10px] font-medium text-gray-600"},nt={class:"text-[9px] text-gray-500 whitespace-nowrap"},rt={class:"bg-white rounded-lg shadow-sm p-4 mb-6"},it={class:"w-full text-sm"},ct={class:"py-2 font-medium text-gray-800"},dt={class:"py-2 text-right"},ut={class:"py-2 text-right text-green-700"},xt={class:"py-2 text-right text-gray-500"},pt={key:0},yt={class:"bg-white rounded-lg shadow-sm p-4"},gt={class:"space-y-1"},_t={class:"text-xs text-gray-400 w-6"},mt={class:"text-pink-600 font-medium"},kt={class:"text-gray-700 ml-1"},ht={class:"text-sm font-bold text-gray-800"},bt={key:0,class:"text-center text-gray-400 py-6 text-sm"},b="beautiqa-admin-token",Nt=O({__name:"AdminView",setup(ft){const x=d(30),n=d(null),_=d(!1),i=d(null),c=d(localStorage.getItem(b)??"");function f(){const r=window.prompt("Wpisz ADMIN_TOKEN (otrzymany od administratora backendu):");r&&r.trim()&&(c.value=r.trim(),localStorage.setItem(b,c.value),p())}async function p(){if(!c.value){f();return}_.value=!0,i.value=null;try{n.value=await T.getAdminStats(c.value,x.value)}catch(r){const e=r.message;e==="UNAUTHORIZED"?(i.value="Nieprawidłowy token. Wyloguj i spróbuj ponownie.",localStorage.removeItem(b),c.value=""):e==="NOT_CONFIGURED"?i.value="Dashboard niezkonfigurowany — brakuje ADMIN_TOKEN w środowisku backendu.":i.value=e}finally{_.value=!1}}function z(r){x.value=r,p()}const m=g(()=>n.value?.by_store.reduce((r,e)=>r+e.total_clicks,0)??0),v=g(()=>n.value?.by_store.reduce((r,e)=>r+e.affiliate_clicks,0)??0),E=g(()=>m.value===0?0:Math.round(v.value/m.value*100)),C=g(()=>Math.max(1,...n.value?.daily.map(r=>r.count)??[1]));return S(p),(r,e)=>{const A=K("router-link");return o(),l("div",W,[e[10]||(e[10]=t("h1",{class:"text-2xl font-bold text-gray-800 mb-2"},"Admin — analytics klików",-1)),e[11]||(e[11]=t("p",{class:"text-xs text-gray-500 mb-6"},[k(" Dane z tabeli "),t("code",{class:"bg-gray-100 px-1 rounded"},"clicks"),k(". Wymagana autoryzacja przez "),t("code",{class:"bg-gray-100 px-1 rounded"},"ADMIN_TOKEN"),k(". ")],-1)),t("div",V,[e[0]||(e[0]=t("span",{class:"text-sm text-gray-600"},"Okres:",-1)),(o(),l(u,null,y([1,7,30,90],s=>t("button",{key:s,onClick:w=>z(s),class:B(["px-3 py-1 rounded-full text-sm transition-colors",x.value===s?"bg-accent-500 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"]),style:N(x.value===s?"background-color: #D89E8E;":"")},a(s===1?"24h":`${s}d`),15,$)),64)),t("button",{onClick:p,class:"ml-2 text-xs text-gray-500 hover:text-gray-700 underline"}," Odśwież ")]),_.value?(o(),l("div",F,"Ładuję...")):i.value?(o(),l("div",U,[t("p",R,a(i.value),1),t("button",{onClick:f,class:"px-4 py-2 text-white rounded-full hover:opacity-90",style:{"background-color":"#D89E8E"}}," Wpisz token ponownie ")])):n.value?(o(),l(u,{key:2},[t("div",q,[t("div",G,[e[1]||(e[1]=t("p",{class:"text-xs text-gray-500"},"Wszystkich klików",-1)),t("p",H,a(m.value),1)]),t("div",L,[e[2]||(e[2]=t("p",{class:"text-xs text-gray-500"},"Affiliate kliki",-1)),t("p",Y,a(v.value),1),t("p",Z,a(E.value)+"%",1)]),t("div",J,[e[3]||(e[3]=t("p",{class:"text-xs text-gray-500"},"Sklepów aktywnych",-1)),t("p",P,a(n.value.by_store.length),1)]),t("div",Q,[e[4]||(e[4]=t("p",{class:"text-xs text-gray-500"},"Top produkt",-1)),t("p",X,a(n.value.top_products[0]?.product_name??"—"),1),t("p",tt,a(n.value.top_products[0]?.total_clicks??0)+" klik.",1)])]),t("section",et,[e[5]||
1(e[5]=t("h2",{class:"text-base font-bold text-gray-800 mb-3"},"Kliki dziennie",-1)),n.value.daily.length===0?(o(),l("div",st," Brak danych w wybranym okresie ")):(o(),l("div",at,[(o(!0),l(u,null,y(n.value.daily,s=>(o(),l("div",{key:s.day,class:"flex-shrink-0 flex flex-col items-center justify-end gap-1 h-full",title:`${s.day}: ${s.count} klik.`},[t("span",lt,a(s.count),1),t("div",{class:"w-6 rounded-t",style:N(`background-color: #E3B7AC; height: ${s.count/C.value*100}%; min-height: 2px;`)},null,4),t("span",nt,a(s.day.slice(5)),1)],8,ot))),128))]))]),t("section",rt,[e[8]||(e[8]=t("h2",{class:"text-base font-bold text-gray-800 mb-3"},"Sklepy — klikalność",-1)),t("table",it,[e[7]||(e[7]=t("thead",null,[t("tr",{class:"text-left text-gray-500 border-b"},[t("th",{class:"py-2"},"Sklep"),t("th",{class:"py-2 text-right"},"Wszystkie"),t("th",{class:"py-2 text-right"},"Affiliate"),t("th",{class:"py-2 text-right"},"% afil.")])],-1)),t("tbody",null,[(o(!0),l(u,null,y(n.value.by_store,s=>(o(),l("tr",{key:s.store_name,class:"border-b border-gray-100"},[t("td",ct,a(s.store_name),1),t("td",dt,a(s.total_clicks),1),t("td",ut,a(s.affiliate_clicks),1),t("td",xt,a(s.total_clicks>0?Math.round(s.affiliate_clicks/s.total_clicks*100):0)+"% ",1)]))),128)),n.value.by_store.length===0?(o(),l("tr",pt,[...e[6]||(e[6]=[t("td",{colspan:"4",class:"py-6 text-center text-gray-400"},"Brak klików",-1)])])):h("",!0)])])]),t("section",yt,[e[9]||(e[9]=t("h2",{class:"text-base font-bold text-gray-800 mb-3"},"Top 20 produktów",-1)),t("ol",gt,[(o(!0),l(u,null,y(n.value.top_products,(s,w)=>(o(),l("li",{key:s.product_id,class:"flex items-center gap-2 py-1 px-2 hover:bg-gray-50 rounded"},[t("span",_t,a(w+1)+".",1),I(A,{to:j(D)({id:s.product_id,brand:s.brand,name:s.product_name}),class:"flex-1 truncate text-sm"},{default:M(()=>[t("span",mt,a(s.brand),1),t("span",kt,a(s.product_name),1)]),_:2},1032,["to"]),t("span",ht,a(s.total_clicks),1)]))),128)),n.value.top_products.length===0?(o(),l("li",bt," Brak klików ")):h("",!0)])])],64)):h("",!0)])}}});export{Nt 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.