PageSourceSearch

https://ai-impact-tracker--ds236.replit.app/assets/history-DWABwyTU.js

js ai-impact-tracker--ds236.replit.app collected 2026-10-03 03:47:20 UTC 6,504 bytes, 2 lines download raw bytes

1import{n as G,r as u,l as Q,o as F,p as K,q as L,s as M,j as e,B as n,t as _,v as B,w as R,x as W,y as v,C as z,a as O,z as N,A as $,E as H,F as U,G as Z,H as V,I as J,J as X,K as Y}from"./index-DwWRJRew.js";import{B as ee}from"./badge-CnrCW1E2.js";import{D as te}from"./download-HJnTYweI.js";import{T as se}from"./trash-2-gz8Xrp_y.js";import{C as ae}from"./circle-alert-Dn58URVy.js";const re=[["path",{d:"M12.531 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14v6a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341l.427-.473",key:"ol2ft2"}],["path",{d:"m16.5 3.5 5 5",key:"15e6fa"}],["path",{d:"m21.5 3.5-5 5",key:"m0lwru"}]],le=G("funnel-x",re),h=10;function me(){const[x,o]=u.useState(1),[a,p]=u.useState("all"),{data:b}=Q(),S={limit:h,offset:(x-1)*h,...a!=="all"&&{toolId:parseInt(a)}},{data:i,isLoading:C}=F(S),f=K(),c=L(),{toast:d}=M(),[y,g]=u.useState(!1),E=async()=>{g(!0);try{const m=[],A=a!=="all"?{toolId:parseInt(a)}:{};for(let s=0;;s+=500){const r=await Z({limit:500,offset:s,...A});if(m.push(...r),r.length<500)break}const I=["Date","Tool","Activity Type","Duration (min)","Complexity","Query Count","Water (ml)","CO2 (g)","Energy (Wh)","Notes"],T=s=>{if(s==null)return"";const r=String(s);return/[",\n\r]/.test(r)?`"${r.replace(/"/g,'""')}"`:r},k=m.map(s=>[s.sessionDate??s.createdAt,s.toolName,s.activityType??"",s.durationMinutes??"",s.complexity,s.queryCount,s.waterMl,s.co2G,s.energyWh,s.notes??""]),q=[I,...k].map(s=>s.map(T).join(",")).join(`
2`),D=new Blob([`\uFEFF${q}`],{type:"text/csv;charset=utf-8"}),j=URL.createObjectURL(D),l=document.createElement("a");l.href=j;const P=new Date().toISOString().slice(0,10);l.download=`ai-impact-sessions-${P}.csv`,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(j),d({title:"Export complete",description:`${m.length} session${m.length===1?"":"s"} downloaded.`})}catch{d({title:"Export failed",description:"Could not download your session history.",variant:"destructive"})}finally{g(!1)}},w=t=>{confirm("Are you sure you want to delete this session?")&&f.mutate({id:t},{onSuccess:()=>{c.invalidateQueries({queryKey:V()}),c.invalidateQueries({queryKey:J()}),c.invalidateQueries({queryKey:X()}),c.invalidateQueries({queryKey:Y()}),d({title:"Session deleted",description:"The session has been removed from your history."})},onError:()=>{d({title:"Error",description:"Failed to delete session.",variant:"destructive"})}})};return e.jsxs("div",{className:"space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-500",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-end justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Session History"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"A complete record of your tracked AI interactions."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(n,{variant:"outline",onClick:E,disabled:y,"data-testid":"button-export-csv",children:[e.jsx(te,{className:"w-4 h-4 mr-2"}),y?"Exporting…":"Download CSV"]}),e.jsxs(_,{value:a,onValueChange:t=>{p(t),o(1)},children:[e.jsx(B,{className:"w-[200px] bg-background",children:e.jsx(R,{placeholder:"Filter by tool"})}),e.jsxs(W,{children:[e.jsx(v,{value:"all",children:"All Tools"}),b?.map(t=>e.jsx(v,{value:t.id.toString(),children:t.name},t.id))]})]}),a!=="all"&&e.jsx(n,{variant:"ghost",size:"icon",onClick:()=>{p("all"),o(1)},title:"Clear filter",children:e.jsx(le,{className:"w-4 h-4 text-muted-foreground"})})]})]}),C?e.jsx("div",{className:"space-y-4",children:[1,2,3,4,5].map(t=>e.jsx("div",{className:"h-24 bg-muted rounded-xl animate-pulse"},t))}):i&&i.length>0?e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"space-y-4",children:i.map(t=>e.jsx(z,{className:"shadow-sm",children:e.jsxs(O,{className:"p-5 flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold",children:t.toolName}),e.jsx(ee,{variant:"secondary",className:"capitalize text-xs font-normal",children:t.complexity}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.sessionDate?N(t.sessionDate):N(t.createdAt)})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:t.activityType&&t.durationMinutes?e.jsxs("span",{className:"capitalize",children:[t.activityType," · ",t.durationMinutes," min"]}):e.jsxs("span",{children:[t.queryCount," ",t.queryCount===1?"query":"queries"]})}),t.notes&&e.jsx("div",{className:"mt-2 text-sm bg-muted/50 p-2 rounded-md border text-muted-foreground",children:t.notes})]}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"flex gap-4 text-sm font-mono",children:[e.jsxs("div",{className:"flex flex-col items-end",children:[e.jsx("span",{className:"text-chart-1 font-semibold",children:$(t.waterMl)}),e.jsx("span",{className:"text-xs text-muted-foreground uppercase",children:"Water"})]}),e.jsxs("div",{className:"flex flex-col items-end",children:[e.jsx("span",{className:"text-chart-2 font-semibold",children:H(t.co2G)}),e.jsx("span",{className:"text-xs text-muted-foreground uppercase",children:"CO2"})]}),e.jsxs("div",{className:"flex flex-col items-end",children:[e.jsx("span",{className:"text-chart-3 font-semibold",children:U(t.energyWh)}),e.jsx("span",{className:"text-xs text-muted-foreground uppercase",children:"Energy"})]})]}),e.jsx(n,{variant:"ghost",size:"icon",onClick:()=>w(t.id),className:"text-muted-foreground hover:text-destructive hover:bg-destructive/10",disabled:f.isPending,children:e.jsx(se,{className:"w-4 h-4"})})]})]})},t.id))}),e.jsxs("div",{className:"flex items-center justify-between pt-4",children:[e.jsx(n,{variant:"outline",onClick:()=>o(t=>Math.max(1,t-1)),disabled:x===1,children:"Previous"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",x]}),e.jsx(n,{variant:"outline",onClick:()=>o(t=>t+1),disabled:i.length<h,children:"Next"})]})]}):e.jsxs("div",{className:"text-center py-20 bg-muted/30 rounded-xl border border-dashed flex flex-col items-center",children:[e.jsx(ae,{className:"w-10 h-10 text-muted-foreground mb-4 opacity-50"}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"No sessions foun
2d"}),e.jsx("p",{className:"text-muted-foreground max-w-sm",children:"No recorded AI usage matches your filters."})]})]})}export{me 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.