PageSourceSearch

https://ssda1.lovable.app/assets/AdminFeedback-DejtO1s6.js

js ssda1.lovable.app collected 2026-10-03 04:39:29 UTC 8,438 bytes, 1 lines download raw bytes

1import{a7 as k,j as e,s as f,a2 as c,V as E,W as P}from"./index-c3jeBoxr.js";import{C as T}from"./card-D6xXGE6Y.js";import{T as C,a as S,b as h,c as i,d as A,e as a}from"./table-B3tvAL7u.js";import{B as K}from"./badge-Bd0VWmP7.js";import{D as L,a as F,c as R,d as B}from"./dialog-DE6ClJdi.js";import{L as w}from"./loader-circle-B6aCQFw3.js";import{S as D}from"./star-BU8es6QH.js";import{f as v}from"./format-D--iGIR9.js";import"./index-Eg0JDQbp.js";const H=t=>t?t.startsWith("VIP+")?"VIP+":t.startsWith("PRO+")?"PRO+":t.startsWith("MATE")?"MATE":null:null,O=t=>{const n=t==="PRO+"?"bg-[#F6920A] text-white":t==="VIP+"?"bg-primary text-primary-foreground":"bg-cyan-600 text-white";return e.jsx(K,{className:`${n} text-[10px] px-1.5 py-0`,children:t})},$=()=>{const{data:t,isLoading:n}=k({queryKey:["admin_promo_usage_log"],queryFn:async()=>{const{data:s,error:r}=await f.from("bookings").select("id, booking_code, guest_email, guest_name, promo_code_used, created_at, check_in_date, total_price, status").or("promo_code_used.ilike.VIP+%,promo_code_used.ilike.MATE%,promo_code_used.ilike.PRO+%").order("created_at",{ascending:!1}).limit(300);if(r)throw r;const l=Array.from(new Set((s??[]).map(m=>m.promo_code_used).filter(Boolean)));let j={};if(l.length>0){const{data:m}=await f.from("promo_codes").select("code, affiliate_guest_email").in("code",l);(m??[]).forEach(u=>{j[u.code]=u.affiliate_guest_email})}return(s??[]).map(m=>({...m,owner_email:j[m.promo_code_used]??null}))}});return n?e.jsx("div",{className:"py-4",children:e.jsx(w,{className:"h-4 w-4 animate-spin"})}):e.jsx(T,{children:e.jsxs(C,{children:[e.jsx(S,{children:e.jsxs(h,{children:[e.jsx(i,{className:"w-[140px]",children:"Kasutuse aeg"}),e.jsx(i,{className:"w-[70px]",children:"Tüüp"}),e.jsx(i,{children:"Kood"}),e.jsx(i,{children:"Kasutaja"}),e.jsx(i,{children:"Koodi omanik"}),e.jsx(i,{children:"Broneering"}),e.jsx(i,{className:"text-right",children:"Summa"})]})}),e.jsxs(A,{children:[t==null?void 0:t.map(s=>{const r=H(s.promo_code_used);return e.jsxs(h,{children:[e.jsx(a,{className:"text-xs",children:v(new Date(s.created_at),"dd.MM.yyyy HH:mm")}),e.jsx(a,{children:r&&O(r)}),e.jsx(a,{className:"font-mono text-xs",children:s.promo_code_used}),e.jsxs(a,{className:"text-xs",children:[e.jsx("div",{className:"font-medium",children:s.guest_name}),e.jsx("div",{className:"text-muted-foreground",children:s.guest_email})]}),e.jsx(a,{className:"text-xs text-muted-foreground",children:s.owner_email??"—"}),e.jsxs(a,{className:"text-xs",children:[e.jsx("div",{className:"font-mono",children:s.booking_code??s.id.slice(0,8)}),e.jsxs("div",{className:"text-muted-foreground",children:[v(new Date(s.check_in_date),"dd.MM.yyyy")," · ",s.status]})]}),e.jsxs(a,{className:"text-right text-xs",children:[Number(s.total_price??0).toFixed(0)," €"]})]},s.id)}),!(t!=null&&t.length)&&e.jsx(h,{children:e.jsx(a,{colSpan:7,className:"text-center text-muted-foreground py-8",children:"Koodide kasutusi pole veel."})})]})]})})},I=({photos:t})=>{const n=c.useMemo(()=>Array.isArray(t)?t.filter(Boolean):[],[t]),[s,r]=c.useState(!1),[l,j]=c.useState([]),[m,u]=c.useState(!1),[p,g]=c.useState(0),M=async()=>{if(r(!0),g(0),l.length||!n.length)return;u(!0);const d=n.map(N=>String(N).replace(/^.*feedback-photos\//,"")),{data:x}=await f.storage.from("feedback-photos").createSignedUrls(d,3600);j((x??[]).map(N=>N.signedUrl).filter(Boolean)),u(!1)},o=l.length,_=c.useCallback(()=>g(d=>(d-1+o)%o),[o]),y=c.useCallback(()=>g(d=>(d+1)%o),[o]);return c.useEffect(()=>{if(!s||o<2)return;const d=x=>{x.key==="ArrowLeft"&&_(),x.key==="ArrowRight"&&y()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s,o,_,y]),n.length?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"text-primary underline text-xs",onClick:M,children:[n.length," foto",n.length>1?"t":""]}),e.jsx(L,{open:s,onOpenChange:r,children:e.jsxs(F,{className:"max-w-5xl",children:[e.jsx(R,{children:e.jsxs(B,{children:["Tagasiside fotod ",o?`(${p+1}/${o})`:`(${n.length})`]})}),m?e.jsx("div",{className:"py-8 flex justify-center",children:e.jsx(w,{className:"h-5 w-5 animate-spin"})}):o?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative bg-muted/40 rounded-lg flex items-center justify-center",children:[e.jsx("img",{src:l[p],alt:`Tagasiside foto ${p+1}`,className:"max-h-[65vh] w-auto max-w-full object-contain rounded-lg"}),o>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:_,"aria-label":"Eelmine",className:"absolute left-2 top-1/2 -translate-y-1/2 roun
1ded-full bg-background/80 hover:bg-background border p-2",children:e.jsx(E,{className:"h-5 w-5"})}),e.jsx("button",{type:"button",onClick:y,"aria-label":"Järgmine",className:"absolute right-2 top-1/2 -translate-y-1/2 rounded-full bg-background/80 hover:bg-background border p-2",children:e.jsx(P,{className:"h-5 w-5"})})]})]}),e.jsx("div",{className:"flex items-center gap-2 overflow-x-auto pb-1",children:l.map((d,x)=>e.jsx("button",{type:"button",onClick:()=>g(x),className:`shrink-0 h-16 w-16 rounded-md overflow-hidden ring-2 ${x===p?"ring-primary":"ring-border"}`,children:e.jsx("img",{src:d,alt:"",className:"h-full w-full object-cover",loading:"lazy"})},x))}),e.jsx("div",{className:"text-right",children:e.jsx("a",{href:l[p],target:"_blank",rel:"noreferrer",className:"text-xs text-primary underline",children:"Ava originaal"})})]}):e.jsx("div",{className:"text-sm text-muted-foreground",children:"Fotosid ei õnnestunud laadida."})]})})]}):e.jsx("span",{className:"text-muted-foreground",children:"0"})},b=({text:t})=>{const[n,s]=c.useState(!1);if(!t)return e.jsx("span",{className:"text-muted-foreground",children:"—"});const r=t.length>60;return e.jsx("div",{className:`text-xs ${r?"cursor-pointer":""} ${n?"whitespace-pre-wrap":"line-clamp-2"}`,title:r&&!n?"Kliki, et näha kogu teksti":void 0,onClick:()=>r&&s(l=>!l),children:t})},Y=()=>{const{data:t,isLoading:n}=k({queryKey:["guest_feedback_admin"],queryFn:async()=>{const{data:s,error:r}=await f.from("guest_feedback").select("*").order("created_at",{ascending:!1}).limit(200);if(r)throw r;return s||[]}});return n?e.jsx("div",{className:"p-6",children:e.jsx(w,{className:"h-6 w-6 animate-spin"})}):e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold mb-3",children:"Tagasiside"}),e.jsx(T,{children:e.jsxs(C,{children:[e.jsx(S,{children:e.jsxs(h,{children:[e.jsx(i,{children:"Aeg"}),e.jsx(i,{children:"Hinnang"}),e.jsx(i,{children:"Meeldis"}),e.jsx(i,{children:"Parandada"}),e.jsx(i,{children:"Soovitab"}),e.jsx(i,{children:"Sõber"}),e.jsx(i,{children:"Koodid"}),e.jsx(i,{children:"Fotod"})]})}),e.jsxs(A,{children:[t==null?void 0:t.map(s=>e.jsxs(h,{children:[e.jsx(a,{className:"text-xs",children:v(new Date(s.created_at),"dd.MM.yyyy HH:mm")}),e.jsx(a,{children:e.jsx("div",{className:"flex",children:Array.from({length:s.rating||0}).map((r,l)=>e.jsx(D,{className:"h-3 w-3 fill-primary text-primary"},l))})}),e.jsx(a,{className:"max-w-[280px] align-top",children:e.jsx(b,{text:s.liked_most})}),e.jsx(a,{className:"max-w-[280px] align-top",children:e.jsx(b,{text:s.improvement})}),e.jsxs(a,{className:"text-xs align-top",children:[e.jsx("div",{children:s.would_recommend===!0?"Jah":s.would_recommend===!1?"Ei":"—"}),s.recommend_comment&&e.jsx(b,{text:s.recommend_comment})]}),e.jsx(a,{className:"text-xs",children:s.friend_invite_sent?e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.friend_name}),e.jsx("div",{className:"text-muted-foreground",children:s.friend_email}),s.friend_whatsapp&&e.jsxs("div",{className:"text-green-600",children:["WA: ",s.friend_whatsapp]}),s.friend_invite_skipped_reason&&e.jsxs("div",{className:"text-yellow-600",children:["Skip: ",s.friend_invite_skipped_reason]})]}):"—"}),e.jsxs(a,{className:"text-xs",children:[s.vip_code&&e.jsx("div",{className:"text-primary",children:s.vip_code}),s.mate_code&&e.jsx("div",{className:"text-cyan-600",children:s.mate_code})]}),e.jsx(a,{className:"text-xs",children:e.jsx(I,{photos:s.photos})})]},s.id)),!(t!=null&&t.length)&&e.jsx(h,{children:e.jsx(a,{colSpan:8,className:"text-center text-muted-foreground py-8",children:"Tagasisidet pole veel."})})]})]})})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3",children:"VIP+/MATE/PRO+ koodide kasutuslogi"}),e.jsx($,{})]})]})};export{Y 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.