1import{a as w,c as R,s as v,j as e,B as T}from"./index-C3IesLzV.js";import{i as N,u as k,R as D}from"./vendor-BOYdj2Dv.js";import{T as L,a as Q,b as S,c as q}from"./tabs-BUyhb98X.js";import{C as u}from"./checkbox-1WeNscG0.js";import{M as _}from"./MetaTags-BeiLWqU-.js";import{T as A,a as H,b as x,c,d as M,e as i}from"./table-B6RZwQCI.js";import{D as U}from"./download-kIMUOS_U.js";import{f as j}from"./format-CJK0YJCs.js";import"./index-DD6QXj4d.js";import"./index-c_qV4LxL.js";import"./check-BrTrZS8H.js";import"./en-US-mnfF38hn.js";function W(){const[b]=N(),p=k(),f=b.get("tab")||"analytics",{user:m}=w(),[n,d]=D.useState([]),{data:r,isLoading:y}=R({queryKey:["qrCodes",m?.id],queryFn:async()=>{const{data:a,error:s}=await v.from("qr_codes").select("*").eq("user_id",m?.id).order("created_at",{ascending:!1});if(s)throw s;return a}}),C=()=>{if(!r)return;const a=r.filter(t=>n.includes(t.id)),s=[["Name","Destination URL","Created At","Scan Count"],...a.map(t=>[t.name,t.content.value,j(new Date(t.created_at),"yyyy-MM-dd HH:mm:ss"),t.scan_count.toString()])].map(t=>t.join(",")).join(` 2`),o=new Blob([s],{type:"text/csv"}),h=window.URL.createObjectURL(o),l=document.createElement("a");l.href=h,l.download="qr-codes.csv",l.click(),window.URL.revokeObjectURL(h)};if(y)return e.jsx("div",{children:"Loading..."});const g=a=>{p(`/dashboard?tab=${a}`,{replace:!0})};return e.jsxs("div",{className:"container mx-auto py-8",children:[e.jsx(_,{title:"Dashboard - QR Code Analytics | QRtracker.io",description:"View all your QR codes and their performance metrics. Export data, manage campaigns, and track ROI."}),e.jsxs(L,{value:f,onValueChange:g,className:"space-y-6",children:[e.jsx(Q,{children:e.jsx(S,{value:"analytics",children:"QR Analytics"})}),e.jsx(q,{value:"analytics",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"QR Code Analytics"}),e.jsxs(T,{onClick:C,disabled:n.length===0,className:"flex items-center gap-2",children:[e.jsx(U,{className:"h-4 w-4"}),"Download CSV"]})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(A,{children:[e.jsx(H,{children:e.jsxs(x,{children:[e.jsx(c,{className:"w-12",children:e.jsx(u,{checked:r?.length===n.length&&r?.length>0,onCheckedChange:a=>{d(a?r?.map(s=>s.id)||[]:[])}})}),e.jsx(c,{children:"Name"}),e.jsx(c,{children:"Destination URL"}),e.jsx(c,{children:"Created At"}),e.jsx(c,{children:"Scan Count"})]})}),e.jsx(M,{children:r?.map(a=>e.jsxs(x,{children:[e.jsx(i,{children:e.jsx(u,{checked:n.includes(a.id),onCheckedChange:s=>{d(s?[...n,a.id]:n.filter(o=>o!==a.id))}})}),e.jsx(i,{children:a.name}),e.jsx(i,{children:a.content.value}),e.jsx(i,{children:j(new Date(a.created_at),"yyyy-MM-dd HH:mm:ss")}),e.jsx(i,{children:a.scan_count})]},a.id))})]})})]})})]})]})}export{W 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.