PageSourceSearch

https://dualsub.dev/assets/dashboard.subscription-DsDtuJO9.js

js dualsub.dev collected 2026-10-02 01:52:52 UTC 6,727 bytes, 1 lines download raw bytes

1import{f as g,h as j,a as f,r as m,j as e,I as N,B as d,c as y,t as k,a2 as v,a3 as C,a4 as w,a5 as P,a6 as D,a7 as S,S as T,C as L}from"./index-CXTEvjyM.js";import{u as E}from"./useQuery-D7M1-MBn.js";import{u as F}from"./useServerFn-AkxNlAKH.js";import{a as M}from"./profile-5Zk4wbQf.js";import{r as _}from"./admin.functions-KG3SGBom.js";import{T as $}from"./ticket-DlEKk51z.js";const I=[["path",{d:"M5.8 11.3 2 22l10.7-3.79",key:"gwxi1d"}],["path",{d:"M4 3h.01",key:"1vcuye"}],["path",{d:"M22 8h.01",key:"1mrtc2"}],["path",{d:"M15 2h.01",key:"1cjtqr"}],["path",{d:"M22 20h.01",key:"1mrys2"}],["path",{d:"m22 2-2.24.75a2.9 2.9 0 0 0-1.96 3.12c.1.86-.57 1.63-1.45 1.63h-.38c-.86 0-1.6.6-1.76 1.44L14 10",key:"hbicv8"}],["path",{d:"m22 13-.82-.33c-.86-.34-1.82.2-1.98 1.11c-.11.7-.72 1.22-1.43 1.22H17",key:"1i94pl"}],["path",{d:"m11 2 .33.82c.34.86-.2 1.82-1.11 1.98C9.52 4.9 9 5.52 9 6.23V7",key:"1cofks"}],["path",{d:"M11 13c1.93 1.93 2.83 4.17 2 5-.83.83-3.07-.07-5-2-1.93-1.93-2.83-4.17-2-5 .83-.83 3.07.07 5 2Z",key:"4kbmks"}]],B=g("party-popper",I);function R(){const a=j(),c=f(),{data:t,refetch:s}=E({queryKey:["sub"],queryFn:M}),l=F(_),[r,n]=m.useState(""),[o,p]=m.useState(!1),[x,u]=m.useState(null);m.useEffect(()=>{if(typeof window>"u")return;const i=new URLSearchParams(window.location.search).get("coupon");i&&n(i.toUpperCase())},[]);async function b(){if(!(!r.trim()||o)){p(!0);try{const i=await l({data:{code:r.trim()}});u({code:i.coupon.code,benefit:i.benefit}),await s(),setTimeout(()=>{s()},800),n("")}catch(i){k.error(i.message)}finally{p(!1)}}}return e.jsxs("div",{className:"space-y-6 max-w-3xl",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:a.dashboard.subscription.title}),e.jsxs("section",{className:"rounded-2xl glass-card p-6",children:[e.jsx("div",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:a.dashboard.subscription.currentPlan}),e.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl font-semibold capitalize",children:t?.plan??"free"}),e.jsx("span",{className:"rounded-full bg-emerald-400/15 px-2 py-0.5 text-xs text-emerald-300",children:t?.status??a.dashboard.subscription.active})]})]}),e.jsxs("section",{className:"rounded-2xl glass-card p-6 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[e.jsx($,{className:"h-4 w-4"})," ¿Tienes un cupón?"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(N,{value:r,onChange:i=>n(i.target.value.toUpperCase()),placeholder:"CÓDIGO",onKeyDown:i=>{i.key==="Enter"&&b()}}),e.jsx(d,{onClick:b,disabled:o||!r.trim(),children:o?e.jsx(y,{className:"h-4 w-4 animate-spin"}):"Aplicar"})]}),t?.coupon_code&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Cupón activo: ",e.jsx("span",{className:"font-mono",children:t.coupon_code})]})]}),e.jsx(q,{data:x,onClose:()=>u(null)}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[e.jsx(h,{name:a.dashboard.subscription.freeName,price:a.dashboard.subscription.freePrice,features:a.dashboard.subscription.freeFeatures,current:t?.plan==="free"||!t?.plan,currentLabel:a.dashboard.subscription.current}),e.jsx(h,{name:a.dashboard.subscription.proName,price:a.dashboard.subscription.proPrice,highlight:!0,features:a.dashboard.subscription.proFeatures,cta:a.dashboard.subscription.upgrade,currentLabel:a.dashboard.subscription.current,current:t?.plan==="pro",onCta:()=>c({to:"/pricing"})}),e.jsx(h,{name:a.dashboard.subscription.annualName,price:a.dashboard.subscription.annualPrice,subPrice:a.dashboard.subscription.annualSubPrice,badge:a.dashboard.subscription.annualBadge,features:a.dashboard.subscription.annualFeatures,cta:a.dashboard.subscription.upgrade,currentLabel:a.dashboard.subscription.current,current:t?.plan==="annual",onCta:()=>c({to:"/pricing"})})]})]})}function h({name:a,price:c,subPrice:t,badge:s,features:l,highlight:r,current:n,cta:o,onCta:p,currentLabel:x}){return e.jsxs("div",{className:`relative rounded-2xl p-6 ${r?"bg-gradient-brand text-primary-foreground":"glass-card"}`,children:[s&&e.jsx("span",{className:"absolute -top-3 left-1/2 -translate-x-1/2 roun
1ded-full bg-white px-3 py-1 text-xs font-semibold text-black",children:s}),e.jsxs("div",{className:"flex items-center gap-2",children:[r&&e.jsx(T,{className:"h-4 w-4"}),e.jsx("h3",{className:"font-semibold",children:a})]}),e.jsx("div",{className:"mt-2 text-3xl font-semibold",children:c}),t&&e.jsx("p",{className:"mt-1 text-xs opacity-80",children:t}),e.jsx("ul",{className:"mt-4 space-y-2 text-sm",children:l.map(u=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(L,{className:"mt-0.5 h-4 w-4 shrink-0"})," ",e.jsx("span",{children:u})]},u))}),e.jsx("div",{className:"mt-6",children:n?e.jsx(d,{variant:"outline",disabled:!0,className:"w-full",children:x}):e.jsx(d,{onClick:p,variant:r?"secondary":"default",className:"w-full",children:o})})]})}function q({data:a,onClose:c}){const t=f();if(!a)return null;const{benefit:s,code:l}=a;let r="¡Cupón aplicado!",n="Tu beneficio ya está activo.";return s.kind==="lifetime"?(r="🎉 ¡Pro de por vida activado!",n="Acceso ilimitado a todas las funciones Pro, sin fecha de expiración."):s.kind==="free_months"?(r=`🎉 ¡${s.months} ${s.months===1?"mes":"meses"} de Pro gratis!`,n=s.until?`Tu plan Pro está activo hasta el ${new Date(s.until).toLocaleDateString()}.`:"Tu plan Pro está activo."):s.kind==="trial_days"?(r=`+${s.days} días de prueba`,n="Sumamos días extra a tu periodo de prueba. Disfruta sin compromiso."):s.kind==="percent"&&(r=`${s.percent}% de descuento listo`,n="El descuento se aplicará automáticamente cuando finalices tu compra en el checkout."),e.jsx(v,{open:!!a,onOpenChange:o=>{o||c()},children:e.jsxs(C,{className:"sm:max-w-md",children:[e.jsxs(w,{children:[e.jsx("div",{className:"mx-auto mb-2 flex h-14 w-14 items-center justify-center rounded-full bg-gradient-brand text-primary-foreground",children:e.jsx(B,{className:"h-7 w-7"})}),e.jsx(P,{className:"text-center text-xl",children:r}),e.jsxs(D,{className:"text-center",children:["Código aplicado: ",e.jsx("span",{className:"font-mono font-semibold",children:l})]})]}),e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:n}),e.jsxs(S,{className:"sm:justify-center gap-2",children:[s.kind==="percent"?e.jsx(d,{onClick:()=>{c(),t({to:"/pricing"})},className:"bg-gradient-brand text-primary-foreground",children:"Ir al checkout"}):e.jsx(d,{onClick:()=>{c(),t({to:"/dashboard"})},className:"bg-gradient-brand text-primary-foreground",children:"Empezar a usar Pro"}),e.jsx(d,{variant:"outline",onClick:c,children:"Cerrar"})]})]})})}export{R as component};

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.