PageSourceSearch

https://mentivy.ai/assets/AdminPlans-DiFa_MbV.js

js mentivy.ai collected 2026-10-05 13:30:55 UTC 10,134 bytes, 3 lines download raw bytes

1import{r as w,j as e}from"./vendor-react-B08oK9DT.js";import{b as U,u,c as E}from"./vendor-tanstack-BD-qdQ_O.js";import{A as B}from"./AdminLayout-By0VmuDw.js";import{C as g,b as D,c as K,a as j}from"./card-BaEvUbxc.js";import{B as v,u as o,s as m}from"./index-BPwE7_cH.js";import{I as n}from"./input-B-f6cjV7.js";import{L as r}from"./label-CKfV1scg.js";import{T as p}from"./textarea-BY4a6svY.js";import{S as x}from"./switch-pG-Z9bYh.js";import{D as L,a as Q,b as Z,c as I}from"./dialog-fcdK5khF.js";import{B as h}from"./badge-DYhUR5lN.js";import{i as R,a8 as q,ay as V,aE as H}from"./vendor-icons-5rcrfB29.js";const te=()=>{const y=U(),[a,i]=w.useState(null),[_,f]=w.useState(""),{data:N=[],isLoading:z}=u({queryKey:["admin-plans"],queryFn:async()=>{const{data:s,error:t}=await m.from("membership_plans").select("*").order("sort_order");if(t)throw t;return(s??[]).map(l=>({...l,monthly_price:Number(l.monthly_price),yearly_price:l.yearly_price?Number(l.yearly_price):null,features:l.features??[]}))}}),{data:F={}}=u({queryKey:["member-counts"],queryFn:async()=>{const{data:s,error:t}=await m.from("profiles").select("membership_tier");if(t)throw t;const l={};return(s??[]).forEach(d=>{const k=d.membership_tier;l[k]=(l[k]||0)+1}),l}}),b=m,{data:C=[]}=u({queryKey:["admin-top-up-packs"],queryFn:async()=>{const{data:s,error:t}=await b.from("top_up_packs").select("*").order("sort_order");if(t)throw t;return s??[]}}),P=E({mutationFn:async s=>{const{error:t}=await b.from("top_up_packs").update({is_active:!s.is_active}).eq("id",s.id);if(t)throw t},onSuccess:()=>{y.invalidateQueries({queryKey:["admin-top-up-packs"]}),o.success("Balík aktualizovaný")},onError:()=>o.error("Chyba pri prepínaní balíka")}),c=E({mutationFn:async s=>{const{id:t,...l}=s,{error:d}=await m.from("membership_plans").update(l).eq("id",t);if(d)throw d},onSuccess:()=>{y.invalidateQueries({queryKey:["admin-plans"]}),o.success("Plán aktualizovaný"),i(null)},onError:()=>o.error("Chyba pri ukladaní")}),T=s=>{c.mutate({id:s.id,is_active:!s.is_active})},A=s=>{c.mutate({id:s.id,is_visible:!s.is_visible})},S=s=>{i(s),f(s.features.join(`
2`))},$=()=>{if(!a)return;const s=_.split(`
3`).filter(t=>t.trim());c.mutate({id:a.id,name:a.name,emoji:a.emoji,tagline:a.tagline,description:a.description,features:s,monthly_price:a.monthly_price,yearly_price:a.yearly_price,yearly_months_charged:a.yearly_months_charged,cta_text:a.cta_text,is_highlighted:a.is_highlighted,highlight_label:a.highlight_label,max_slots:a.max_slots,trial_hours:a.trial_hours,trial_expiry_message:a.trial_expiry_message,trial_expiry_cta:a.trial_expiry_cta})};return e.jsxs(B,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground",children:"Členské plány"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Spravuj ceny, obsah a viditeľnosť plánov"})]}),e.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:N.map(s=>e.jsxs(g,{children:[e.jsx(D,{className:"pb-2",children:e.jsxs(K,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx("span",{children:s.emoji})," ",s.name]})}),e.jsxs(j,{children:[e.jsx("div",{className:"text-2xl font-bold type-stat",children:F[s.slug]||0}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["aktívnych členov",s.max_slots&&` / ${s.max_slots} miest`]})]})]},s.id))}),z?e.jsx("div",{className:"flex justify-center py-10",children:e.jsx("div",{className:"w-8 h-8 border-2 border-primary border-t-transparent rounded-full animate-spin"})}):e.jsx("div",{className:"space-y-4",children:N.map(s=>e.jsx(g,{children:e.jsx(j,{className:"p-5",children:e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("span",{className:"text-2xl",children:s.emoji}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:s.name}),s.is_highlighted&&e.jsxs(h,{variant:"default",className:"text-xs",children:[e.jsx(R,{className:"h-3 w-3 mr-1"}),"Zvýraznený"]}),!s.is_visible&&e.jsxs(h,{variant:"secondary",className:"text-xs",children:[e.jsx(q,{className:"h-3 w-3 mr-1"}),"Skrytý"]}),!s.is_active&&e.jsx(h,{variant:"destructive",className:"text-xs",children:"Neaktívny"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.monthly_price===0?"Zadarmo":`${s.monthly_price} €/mes`,s.yearly_price?` · ${s.yearly_price} €/rok`:"",s.max_slots?` · Limit: ${s.max_slots} miest`:""]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mr-4",children:[e.jsx(r,{htmlFor:`active-${s.id}`,className:"text-xs text-muted-foreground",children:"Aktívny"}),e.jsx(x,{id:`active-${s.id}`,checked:s.is_active,onCheckedChange:()=>T(s)})]}),e.jsxs("div",{className:"flex items-center gap-2 mr-4",children:[e.jsx(r,{htmlFor:`visible-${s.id}`,className:"text-xs text-muted-foreground",children:"Viditeľný"}),e.jsx(x,{id:`visible-${s.id}`,checked:s.is_visible,onCheckedChange:()=>A(s)})]}),e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>S(s),children:[e.jsx(V,{className:"h-4 w-4 mr-1"}),"Upraviť"]})]})]})})},s.id))}),e.jsxs("div",{className:"pt-6",children:[e.jsxs("div",{className:"mb-3",children:[e.jsxs("h2",{className:"text-xl font-semibold text-foreground flex items-center gap-2",children:[e.jsx(H,{className:"h-5 w-5"}),"Top-up balíky tréningov"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Doplnkové balíky navyše k mesačnému limitu. Kým sú vypnuté, používateľom sa v UI nezobrazia."})]}),e.jsxs("div",{className:"space-y-3",children:[C.map(s=>e.jsx(g,{children:e.jsxs(j,{className:"p-4 flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:s.name}),!s.is_active&&e.jsxs(h,{variant:"secondary",className:"text-xs",children:[e.jsx(q,{className:"h-3 w-3 mr-1"}),"Vypnutý"]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["+",s.trainings," tréningov · ",Number(s.price_eur)," € ·"," ","pre plány: ",s.eligible_plans.join(", ")||"—"]}
3)]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{className:"text-xs text-muted-foreground",children:"Aktívny"}),e.jsx(x,{checked:s.is_active,onCheckedChange:()=>P.mutate(s)})]})]})},s.id)),C.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Žiadne balíky."})]})]})]}),e.jsx(L,{open:!!a,onOpenChange:s=>!s&&i(null),children:e.jsxs(Q,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Z,{children:e.jsxs(I,{children:["Upraviť plán: ",a==null?void 0:a.name]})}),a&&e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(r,{children:"Názov"}),e.jsx(n,{value:a.name,onChange:s=>i({...a,name:s.target.value})})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Emoji"}),e.jsx(n,{value:a.emoji,onChange:s=>i({...a,emoji:s.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Tagline"}),e.jsx(n,{value:a.tagline,onChange:s=>i({...a,tagline:s.target.value})})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Popis"}),e.jsx(p,{value:a.description,onChange:s=>i({...a,description:s.target.value}),rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(r,{children:"Mesačná cena (€)"}),e.jsx(n,{type:"number",value:a.monthly_price,onChange:s=>i({...a,monthly_price:Number(s.target.value)})})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Ročná cena (€)"}),e.jsx(n,{type:"number",value:a.yearly_price??"",onChange:s=>i({...a,yearly_price:s.target.value?Number(s.target.value):null}),placeholder:"Nechať prázdne ak nedostupné"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(r,{children:"Ročne účtované mesiace"}),e.jsx(n,{type:"number",value:a.yearly_months_charged??"",onChange:s=>i({...a,yearly_months_charged:s.target.value?Number(s.target.value):null})})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Limit miest"}),e.jsx(n,{type:"number",value:a.max_slots??"",onChange:s=>i({...a,max_slots:s.target.value?Number(s.target.value):null}),placeholder:"Neobmedzené"})]})]}),e.jsxs("div",{children:[e.jsx(r,{children:"CTA text"}),e.jsx(n,{value:a.cta_text,onChange:s=>i({...a,cta_text:s.target.value})})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Funkcie (jedna na riadok)"}),e.jsx(p,{value:_,onChange:s=>f(s.target.value),rows:6})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(x,{checked:a.is_highlighted,onCheckedChange:s=>i({...a,is_highlighted:s})}),e.jsx(r,{children:"Zvýraznený"})]})}),a.is_highlighted&&e.jsxs("div",{children:[e.jsx(r,{children:"Badge text"}),e.jsx(n,{value:a.highlight_label??"",onChange:s=>i({...a,highlight_label:s.target.value||null})})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsxs("div",{children:[e.jsx(r,{children:"Trial hodiny"}),e.jsx(n,{type:"number",value:a.trial_hours??"",onChange:s=>i({...a,trial_hours:s.target.value?Number(s.target.value):null}),placeholder:"Žiadny trial"})]})}),a.trial_hours&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(r,{children:"Správa po expirácii trial"}),e.jsx(p,{value:a.trial_expiry_message??"",onChange:s=>i({...a,trial_expiry_message:s.target.value||null}),rows:3})]}),e.jsxs("div",{children:[e.jsx(r,{children:"CTA po expirácii"}),e.jsx(n,{value:a.trial_expiry_cta??"",onChange:s=>i({...a,trial_expiry_cta:s.target.value||null})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(v,{variant:"outline",onClick:()=>i(null),children:"Zrušiť"}),e.jsx(v,{onClick:$,disabled:c.isPending,children:c.isPending?"Ukladám...":"Uložiť zmeny"})]})]})]})})]})};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.