1import{u as y,j as e}from"./vendor-query-CmFN4-M1.js";import{r as A}from"./vendor-react-7PyNDetJ.js";import{r as b,v as S,x as C,y as I,z as t,p as T,av as R,aR as F,at as i,aS as D,ab as m,b as j,X as E,c as B}from"./index-BZSaBQD0.js";import{T as H,a as q,b as o,c as n,d as L,e as s}from"./table-BEgIk-tI.js";import{aR as M}from"./vendor-ui-DjI1iuvA.js";import{p as z}from"./pt-BR-DOx-ZqcW.js";import"./vendor-supabase-BfoV2C50.js";function G(){const[l,p]=A.useState("all"),f=async()=>{try{let a=j.from("ai_credits_ledger").select("id, created_at, user_id, feature_used, amount, description").order("created_at",{ascending:!1}).limit(100);l!=="all"&&(a=a.eq("feature_used",l));const{data:r,error:h}=await a;if(h)throw h;const N=[...new Set((r==null?void 0:r.map(c=>c.user_id))||[])],{data:d}=await j.from("profiles").select("id, full_name").in("id",N);return(r||[]).map(c=>{var x;return{...c,user_name:((x=d==null?void 0:d.find(_=>_.id===c.user_id))==null?void 0:x.full_name)||"Desconhecido"}})}catch(a){throw E.error("Error fetching logs:",a),B.error("Erro ao carregar logs"),a}},{data:u=[],isLoading:g,refetch:v}=y({queryKey:["admin-users-activity",l],queryFn:f,staleTime:6e4,refetchOnWindowFocus:!1}),w=a=>({"ai-generate-conclusion":"Conclusão AI","ai-suggestion-review":"Sugestões AI","ai-rads-classification":"RADS AI","ai-dictation-polish":"Corretor AI","radreport-chat":"Chat AI","ai-inline-edit":"Edição Inline","ai-voice-inline-edit":"Edição Voz",monthly_renewal:"Renovação Mensal",signup_bonus:"Bônus Cadastro"})[a||""]||a||"-";return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(b,{value:l,onValueChange:p,children:[e.jsx(S,{className:"w-[200px]",children:e.jsx(C,{placeholder:"Filtrar por feature"})}),e.jsxs(I,{children:[e.jsx(t,{value:"all",children:"Todas as Features"}),e.jsx(t,{value:"ai-generate-conclusion",children:"Conclusão AI"}),e.jsx(t,{value:"ai-suggestion-review",children:"Sugestões AI"}),e.jsx(t,{value:"ai-rads-classification",children:"RADS AI"}),e.jsx(t,{value:"ai-dictation-polish",children:"Corretor AI"}),e.jsx(t,{value:"radreport-chat",children:"Chat AI"}),e.jsx(t,{value:"monthly_renewal",children:"Renovação Mensal"})]})]}),e.jsx(T,{variant:"outline",size:"icon",onClick:()=>{v()},children:e.jsx(M,{className:"h-4 w-4"})})]}),e.jsx(R,{children:e.jsx(F,{className:"h-[500px]",children:e.jsxs(H,{children:[e.jsx(q,{children:e.jsxs(o,{children:[e.jsx(n,{children:"Data/Hora"}),e.jsx(n,{children:"Usuário"}),e.jsx(n,{children:"Feature"}),e.jsx(n,{className:"text-center",children:"Créditos"}),e.jsx(n,{children:"Descrição"})]})}),e.jsx(L,{children:g?[...Array(5)].map((a,r)=>e.jsxs(o,{children:[e.jsx(s,{children:e.jsx(i,{className:"h-4 w-24"})}),e.jsx(s,{children:e.jsx(i,{className:"h-4 w-32"})}),e.jsx(s,{children:e.jsx(i,{className:"h-5 w-20"})}),e.jsx(s,{children:e.jsx(i,{className:"h-4 w-12 mx-auto"})}),e.jsx(s,{children:e.jsx(i,{className:"h-4 w-40"})})]},r)):u.length===0?e.jsx(o,{children:e.jsx(s,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"Nenhuma atividade encontrada"})}):u.map(a=>e.jsxs(o,{children:[e.jsx(s,{className:"text-sm text-muted-foreground whitespace-nowrap",children:D(new Date(a.created_at),"dd/MM HH:mm",{locale:z})}),e.jsx(s,{className:"font-medium",children:a.user_name}),e.jsx(s,{children:e.jsx(m,{variant:"outline",children:w(a.feature_used)})}),e.jsx(s,{className:"text-center",children:e.jsxs(m,{variant:a.amount<0?"destructive":"secondary",children:[a.amount>0?"+":"",a.amount]})}),e.jsx(s,{className:"text-sm text-muted-foreground max-w-[200px] truncate",children:a.description||"-"})]},a.id))})]})})})]})}export{G 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.