PageSourceSearch

https://www.xpark.ai/assets/AdminReviews-CELuGKbJ.js

js xpark.ai collected 2026-10-05 14:02:37 UTC 7,719 bytes, 1 lines download raw bytes

1import{a as q,r as l,j as e,B as h,q as B,f as F,aH as H,aJ as J,d as v,g as w}from"./index-FWKSGZPO.js";import{C as c,a as p,b as j,c as o}from"./card-DTQVPU97.js";import{B as U}from"./badge-Cpd-8HxK.js";import{S as A,a as M,b as R,c as k,d as n}from"./select-CNpOZwnZ.js";import{R as X}from"./refresh-ccw-B3ZBuFOd.js";import{E as G}from"./eye-off-DNM8AM-E.js";import"./index-BdQq_4o_.js";const T={pending:{label:"Pendente",cls:"bg-amber-500/10 text-amber-700 border-amber-500/30"},published:{label:"Publicada",cls:"bg-green-500/10 text-green-700 border-green-500/30"},rejected:{label:"Rejeitada",cls:"bg-red-500/10 text-red-700 border-red-500/30"}};function K({n:i}){return e.jsx("span",{className:"inline-flex items-center gap-0.5",children:[1,2,3,4,5].map(t=>e.jsx(B,{className:`h-3.5 w-3.5 ${t<=i?"fill-amber-500 text-amber-500":"text-muted-foreground/40"}`},t))})}function te(){const{user:i}=q(),[t,z]=l.useState([]),[S,_]=l.useState(!0),[m,E]=l.useState("all"),[x,D]=l.useState("all"),[f,y]=l.useState(null),[r,P]=l.useState([]);async function g(){_(!0);const{data:s,error:a}=await v.from("reviews").select("*").order("created_at",{ascending:!1}).limit(500);a&&w.error("Não foi possível carregar as avaliações."),z(s??[]);const{data:N}=await v.from("review_invites").select("id, booking_id, phone, sent_at, responded_at, follow_up_count, bookings(customer_name)").order("sent_at",{ascending:!1}).limit(500);P(N??[]),_(!1)}l.useEffect(()=>{g()},[]);const C=l.useMemo(()=>t.filter(s=>(m==="all"||s.status===m)&&(x==="all"||s.airport===x)),[t,m,x]),d=l.useMemo(()=>t.filter(s=>s.status==="published"),[t]),I=d.length?d.reduce((s,a)=>s+a.rating,0)/d.length:0,L=l.useMemo(()=>{const s={5:0,4:0,3:0,2:0,1:0};for(const a of t)s[a.rating]=(s[a.rating]??0)+1;return s},[t]),O=l.useMemo(()=>Array.from(new Set(t.map(s=>
1s.airport).filter(Boolean))),[t]),u=l.useMemo(()=>r.filter(s=>!s.responded_at),[r]),V=r.length?Math.round((r.length-u.length)/r.length*100):0,$=s=>Math.max(0,Math.round((Date.now()-new Date(s).getTime())/36e5));async function b(s,a){y(s);const{error:N}=await v.from("reviews").update({status:a,published_at:a==="published"?new Date().toISOString():null,moderated_by:(i==null?void 0:i.id)??null}).eq("id",s);if(y(null),N){w.error("Falha ao atualizar a avaliação.");return}w.success(a==="published"?"Avaliação publicada.":a==="rejected"?"Avaliação rejeitada.":"Avaliação ocultada."),g()}return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Avaliações"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Moderação das avaliações da experiência de compra com o xpark."})]}),e.jsxs(h,{variant:"outline",size:"sm",onClick:g,disabled:S,children:[e.jsx(X,{className:"mr-2 h-4 w-4"})," Atualizar"]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs(c,{children:[e.jsx(p,{className:"pb-2",children:e.jsx(j,{className:"text-sm font-medium text-muted-foreground",children:"Total recebidas"})}),e.jsx(o,{className:"text-3xl font-bold",children:t.length})]}),e.jsxs(c,{children:[e.jsx(p,{className:"pb-2",children:e.jsx(j,{className:"text-sm font-medium text-muted-foreground",children:"Média (publicadas)"})}),e.jsxs(o,{children:[e.jsx("div",{className:"text-3xl font-bold",children:d.length?I.toFixed(2).replace(".",","):"-"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[d.length," publicadas"]})]})]}),e.jsxs(c,{children:[e.jsx(p,{className:"pb-2",children:e.jsx(j,{className:"text-sm font-medium text-muted-foreground",children:"Distribuição"})}),e.jsx(o,{className:"space-y-1 text-sm",children:[5,4,3,2,1].map(s=>e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[s," ",e.jsx(B,{className:"h-3 w-3 fill-amber-500 text-amber-500"})]}),e.jsx("span",{className:"font-medium",children:L[s]??0})]},s))})]})]}),e.jsxs(c,{children:[e.jsx(p,{className:"pb-2",children:e.jsx(j,{className:"text-sm font-medium text-muted-foreground",children:"Convites de avaliação"})}),e.jsxs(o,{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap gap-6 text-sm",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"enviados"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:u.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"sem resposta"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[V,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"taxa de resposta"})]})]}),u.length>0&&e.jsx("div",{className:"max-h-64 space-y-1 overflow-y-auto rounded-lg border p-2 text-sm",children:u.map(s=>{var a;return e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-1 py-1",children:[e.jsxs("span",{className:"font-medium",children:[((a=s.bookings)==null?void 0:a.customer_name)??"Cliente"," ",e.jsx("span",{className:"font-normal text-muted-foreground",children:s.phone??""})]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["há ",$(s.sent_at),"h",s.follow_up_count>0?` · ${s.follow_up_count} follow-up(s)`:""]})]},s.id)})})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs(A,{value:m,onValueChange:E,children:[e.jsx(M,{className:"w-[180px]",children:e.jsx(R,{placeholder:"Status"})}),e.jsxs(k,{children:[e.jsx(n,{value:"all",children:"Todos os status"}),e.jsx(n,{value:"pending",children:"Pendentes"}),e.jsx(n,{value:"published",children:"Publicadas"}),e.jsx(n,{value:"rejected",children:"Rejeitadas"})]})]}),e.jsxs(A,{value:x,onValueChange:D,children:[e.jsx(M,{className:"w-[180px]",children:e.jsx(R,{placeholder:"Aeroporto"})}),e.jsxs(k,{children:[e.jsx(n,{value:"all",children:"Todos os aeroportos"}),O.map(s=>e.jsx(n,{value:s,children:s},s))]})]})]}),S?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(F,{className:"h-4 w-4 animate-spin"})," Carregando..."]}):C.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Nenhuma avaliação com esses filtros."}):e.jsx("div",{className:"space-y-3",children:C.map(s=>e.jsx(c,{children:e.jsxs(o,{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{n:s.rating}),e.jsx("span",{className:"font-medium",children:s.customer_name??"Sem nome"}),e.jsx(U,{variant:"outline",className:T[s.status].cls,children:T[s.status].label})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(s.created_at).toLocaleStr
1ing("pt-BR")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:[s.unit_name,s.airport,s.category,`origem: ${s.source??"-"}`].filter(Boolean).join(" · ")}),s.comment&&e.jsx("p",{className:"text-sm",children:s.comment}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.status!=="published"&&e.jsxs(h,{size:"sm",disabled:f===s.id,onClick:()=>b(s.id,"published"),children:[e.jsx(H,{className:"mr-2 h-4 w-4"})," Publicar"]}),s.status==="published"&&e.jsxs(h,{size:"sm",variant:"outline",disabled:f===s.id,onClick:()=>b(s.id,"pending"),children:[e.jsx(G,{className:"mr-2 h-4 w-4"})," Ocultar"]}),s.status!=="rejected"&&e.jsxs(h,{size:"sm",variant:"outline",disabled:f===s.id,onClick:()=>b(s.id,"rejected"),children:[e.jsx(J,{className:"mr-2 h-4 w-4"})," Rejeitar"]})]})]})},s.id))})]})}export{te 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.