PageSourceSearch

https://liptov.travel/assets/AdminRewards-BlalX5dJ.js

js liptov.travel collected 2026-09-25 09:20:29 UTC 12,589 bytes, 11 lines download raw bytes

1import{j as e}from"./vendor-query-ClTBLi42.js";import{r as l}from"./vendor-react-BqRewklv.js";import{A as re}from"./AdminLayout-QL9o9cOy.js";import{u as le}from"./useAutoTranslate-BGmo2zId.js";import{C as w,b as _,c as C,a as S}from"./card-DPTViJzM.js";import{c as D,B as m,X as ie,s as x}from"./index-DGpp3eJC.js";import{I as g}from"./input-CKnX-Jhw.js";import{L as o}from"./label-GGeZhsGQ.js";import{T as ne}from"./textarea-9ZFeI_Oe.js";import{S as T,a as U,b as V,c as A,d as O}from"./select-BHSnos8o.js";import{S as oe}from"./switch-CzGQXmFL.js";import{B as I}from"./badge-B5wz_y8q.js";import{u as i}from"./index-COB36PEp.js";import{L as B}from"./useLoyalty-CqTl_ZWd.js";import{C as ce}from"./calculator-CY3GzRXX.js";import{P as F}from"./pencil-D7Ut4hC9.js";import{P as de}from"./plus-BXiaRCE9.js";import{L as q}from"./loader-circle-DxghVRV2.js";import{G}from"./gift-DjR9WRP9.js";import{T as me}from"./trash-2-DPhdOip7.js";import"./index-BtUkuaxN.js";import"./index-DzVnluf7.js";import"./vendor-supabase-Clqdqihj.js";import"./index-vlChlfhG.js";import"./sparkles-Cksq33fz.js";import"./qr-code-CnLrZIQ4.js";import"./users-DMSel5sO.js";import"./newspaper-D2WBcztj.js";import"./mail-BulA7arx.js";import"./image-Dg87EHdT.js";import"./map-pin-yq2QYqsc.js";import"./file-text-MvZK9k2z.js";import"./trending-up-CdBRmtkC.js";import"./shield-check-badJAafZ.js";import"./shield-BZD8Pqny.js";import"./eye-D9HWoTra.js";import"./vendor-helmet-B3WFvB_A.js";import"./vendor-i18n-CzlVjiK3.js";import"./index-CIJXpiZ_.js";import"./index-BFLjGiQW.js";import"./index-CqyPM0RU.js";import"./chevron-up-eYdkrTS1.js";import"./check-1uH3r8mc.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const xe=D("ImagePlus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const pe=D("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]),K=[{value:"wellness",label:"Wellness"},{value:"dining",label:"Gastro"},{value:"experience",label:"Zážitok"},{value:"accommodation",label:"Ubytovanie"},{value:"merchandise",label:"Merchandise"}],ls=()=>{const[j,H]=l.useState([]),{translate:Z,isTranslating:ue}=le({table:"rewards"}),[$,W]=l.useState(!0),[P,p]=l.useState(!1),[c,z]=l.useState(null),[f,X]=l.useState(""),d=f?Math.ceil(parseFloat(f)*20/5)*5:0,[N,u]=l.useState(null),[L,h]=l.useState(null),[he,y]=l.useState(!1),E=l.useRef(null),[t,r]=l.useState({name:"",description:"",points_cost:"",category:"experience",min_level:"explorer",is_active:!0,stock:"",image_url:""}),M=()=>{r({name:"",description:"",points_cost:"",category:"experience",min_level:"explorer",is_active:!0,stock:"",image_url:null}),z(null),u(null),h(null)},b=async()=>{const{data:s,error:a}=await x.from("rewards").select("*").order("points_cost",{ascending:!0});if(a){i.error("Chyba pri načítaní odmien");return}H(s),W(!1)};l.useEffect(()=>{b()},[]);const J=s=>{z(s.id),r({name:s.name,description:s.description,points_cost:String(s.points_cost),category:s.category,min_level:s.min_level,is_active:s.is_active,stock:s.stock!==null?String(s.stock):"",image_url:s.image_url}),h(s.image_url),u(null)},Q=s=>{var n;const a=(n=s.target.files)==null?void 0:n[0];if(a){if(a.size>5*1024*1024){i.error("Obrázok max 5 MB");return}u(a),h(URL.createObjectURL(a))}},Y=async()=>{if(!N)return t.image_url||null;y(!0);const s=N.name.split(".").pop(),a=`rewards/${Date.now()}.${s}`,{error:n}=await x.storage.from("gallery").upload(a,N,{upsert:!0});if(n)return i.error("Chyba pri nahrávaní obrázka"),y(!1),null;const{data:v}=x.storage.from("gallery").getPublicUrl(a);return y(!1),v.publicUrl},ee=async()=>{var v,R;if(!((v=t.name)!=null&&v.trim())||!((R=t.points_cost)!=null&&R.trim())){i.error("Vyplňte názov a cenu v bodoch");return}p(!0);const s=await Y(),a={name:t.name,description:t.description,points_cost:parseInt(t.points_cost),category:t.category,min_level:t.min_level,is_active:t.is_active,stock:t.stock?parseInt(t.stock):null,image_url:s};let n=c;if(c){const{error:k}=await x.from("rewards").update(a).eq("id",c);if(k){i.error("Chyba pri ukladaní"),p(!1);return}i.success("Odmena aktualizovaná")}else{const{data:k,error:te}=await x.from("rewards").insert(a).select("id").single();if(te){i.error("Chyba pri vytváraní"),p(!1);return}n=k.id,i.success("Odmena vytvorená")}M(),p(!1),b(),n&&Z(n,{name:a.name,description:a.description})},se=async s=>{if(!confirm("Naozaj chcete odstrániť túto odmenu?"))return;const{error:a}=await x.from("rewards").delete().eq("id",s);if(a){i.error("Chyba pri mazaní");return}i.success("Odmena odstránená"),b()},ae=()=>{d>0&&(r(s=>({...s,points_cost:String(d)}
11)),i.success(`Nastavených ${d} bodov`))};return e.jsx(re,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-display font-bold",children:"Odmeny za body"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Správa katalógu odmien pre vernostný program"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-1 space-y-6",children:[e.jsxs(w,{className:"shadow-soft",children:[e.jsx(_,{className:"pb-3",children:e.jsxs(C,{className:"font-display flex items-center gap-2 text-base",children:[e.jsx(ce,{className:"w-5 h-5"}),"Kalkulačka bodov"]})}),e.jsxs(S,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(o,{htmlFor:"calc-eur",className:"text-xs text-muted-foreground",children:"Hodnota v €"}),e.jsx(g,{id:"calc-eur",type:"number",min:"0",step:"0.01",inputMode:"decimal",value:f,onChange:s=>X(s.target.value),placeholder:"30",className:"mt-1"})]}),e.jsx("div",{className:"text-2xl text-muted-foreground pt-5",children:"="}),e.jsxs("div",{className:"flex-1",children:[e.jsx(o,{className:"text-xs text-muted-foreground",children:"Bodov"}),e.jsx("div",{className:"mt-1 h-10 flex items-center px-3 bg-primary/5 border border-primary/20 rounded-md",children:e.jsx("span",{className:"font-bold text-primary text-lg",children:d})})]})]}),d>0&&e.jsxs(m,{variant:"outline",size:"sm",className:"w-full mt-3",onClick:ae,children:["Použiť ",d," bodov vo formulári"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"€ × 20 bodov • Zaokrúhlenie na 5 nahor • Návratnosť 5%"})]})]}),e.jsxs(w,{className:"shadow-soft",children:[e.jsx(_,{className:"pb-3",children:e.jsxs(C,{className:"font-display flex items-center gap-2 text-base",children:[c?e.jsx(F,{className:"w-5 h-5"}):e.jsx(de,{className:"w-5 h-5"}),c?"Upraviť odmenu":"Nová odmena"]})}),e.jsxs(S,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(o,{children:"Názov"}),e.jsx(g,{value:t.name,onChange:s=>r(a=>({...a,name:s.target.value})),placeholder:"Napr. Tričko Naši z Račkovej",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Popis"}),e.jsx(ne,{value:t.description,onChange:s=>r(a=>({...a,description:s.target.value})),placeholder:"Popis odmeny...",className:"mt-1",rows:3})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(o,{children:"Cena (body)"}),e.jsx(g,{type:"number",value:t.points_cost,onChange:s=>r(a=>({...a,points_cost:s.target.value})),placeholder:"Napr. 100",className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Sklad (ks)"}),e.jsx(g,{type:"number",value:t.stock,onChange:s=>r(a=>({...a,stock:s.target.value})),placeholder:"∞",className:"mt-1"})]})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Kategória"}),e.jsxs(T,{value:t.category,onValueChange:s=>r(a=>({...a,category:s})),children:[e.jsx(U,{className:"mt-1",children:e.jsx(V,{})}),e.jsx(A,{children:K.map(s=>e.jsx(O,{value:s.value,children:s.label},s.value))})]})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Min. úroveň"}),e.jsxs(T,{value:t.min_level,onValueChange:s=>r(a=>({...a,min_level:s})),children:[e.jsx(U,{className:"mt-1",children:e.jsx(V,{})}),e.jsx(A,{children:Object.entries(B).map(([s,a])=>e.jsx(O,{value:s,children:a},s))})]})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Obrázok"}),e.jsx("input",{ref:E,type:"file",accept:"image/*",onChange:Q,className:"hidden"}),L?e.jsxs("div",{className:"mt-1 relative w-full aspect-video rounded-lg overflow-hidden border",children:[e.jsx("img",{src:L,alt:"Náhľad",className:"w-full h-full object-cover"}),e.jsx(m,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>{u(null),h(null),r(s=>({...s,image_url:null}))},children:e.jsx(ie,{className:"w-4 h-4"})})]}):e.jsxs("button",{type:"button",onClick:()=>{var s;return(s=E.current)==null?void 0:s.click()},className:"mt-1 w-full aspect-video rounded-lg border-2 border-dashed border-muted-foreground
11/30 flex flex-col items-center justify-center gap-2 text-muted-foreground hover:border-primary/50 hover:text-primary transition-colors",children:[e.jsx(xe,{className:"w-8 h-8"}),e.jsx("span",{className:"text-xs",children:"Kliknite pre nahratie"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(o,{children:"Aktívna"}),e.jsx(oe,{checked:t.is_active,onCheckedChange:s=>r(a=>({...a,is_active:s}))})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(m,{onClick:ee,disabled:P,className:"flex-1",children:[P?e.jsx(q,{className:"w-4 h-4 animate-spin mr-2"}):null,c?"Uložiť":"Vytvoriť"]}),c&&e.jsx(m,{variant:"outline",onClick:M,children:"Zrušiť"})]})]})]})]}),e.jsx("div",{className:"lg:col-span-2",children:e.jsxs(w,{className:"shadow-soft",children:[e.jsx(_,{className:"pb-3",children:e.jsxs(C,{className:"font-display flex items-center gap-2 text-base",children:[e.jsx(G,{className:"w-5 h-5"}),"Katalóg odmien",e.jsx(I,{variant:"secondary",className:"ml-auto",children:j.length})]})}),e.jsx(S,{children:$?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(q,{className:"w-8 h-8 animate-spin text-primary"})}):j.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(pe,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{children:"Žiadne odmeny"}),e.jsx("p",{className:"text-sm mt-1",children:"Pridajte prvú odmenu pomocou formulára"})]}):e.jsx("div",{className:"space-y-3",children:j.map(s=>{var a;return e.jsxs("div",{className:"flex items-center gap-4 p-4 border rounded-xl hover:bg-muted/50 transition-colors",children:[s.image_url?e.jsx("img",{src:s.image_url,alt:s.name,className:"w-14 h-14 rounded-lg object-cover shrink-0"}):e.jsx("div",{className:"w-14 h-14 rounded-lg bg-muted flex items-center justify-center shrink-0",children:e.jsx(G,{className:"w-6 h-6 text-muted-foreground/40"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-semibold",children:s.name}),!s.is_active&&e.jsx(I,{variant:"outline",className:"text-xs",children:"Neaktívna"}),e.jsx(I,{variant:"secondary",className:"text-xs",children:(a=K.find(n=>n.value===s.category))==null?void 0:a.label})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5 truncate",children:s.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Min: ",B[s.min_level]]}),s.stock!==null&&e.jsxs("span",{children:["Sklad: ",s.stock," ks"]})]})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsx("div",{className:"font-bold text-primary text-lg",children:s.points_cost}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"bodov"})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx(m,{variant:"ghost",size:"icon",onClick:()=>J(s),children:e.jsx(F,{className:"w-4 h-4"})}),e.jsx(m,{variant:"ghost",size:"icon",onClick:()=>se(s.id),children:e.jsx(me,{className:"w-4 h-4 text-destructive"})})]})]},s.id)})})})]})})]})]})})};export{ls 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.