PageSourceSearch

https://app.ateliereonline.ro/assets/Oferte-B5iGEa5d.js

js ateliereonline.ro collected 2026-10-02 15:59:30 UTC 6,608 bytes, 1 lines download raw bytes

1import{u as j,j as e}from"./vendor-data-BnAsYEPc.js";import{S as O}from"./Seo-DMj-8jJG.js";import{u as P,q as E,f as x,B as u,P as y,be as S,b9 as A,H as _,c as V,aE as k,r as I}from"./index-288RRn8G.js";import{C as z,a as L}from"./card-1z68Zaok.js";import{e as $,r as B}from"./vendor-react-BNJcskRT.js";import{G as C}from"./gift-CmEKMf25.js";import{C as F}from"./copy-CU1In3zH.js";import{E as M}from"./external-link-fPkwHpuB.js";import{f as R}from"./vendor-date-BFEA4iDb.js";import"./vendor-ui-vXhwLHr8.js";const Y=()=>{const{user:s,isAuthenticated:r}=P(),{usedCodes:p}=E(),i=$(),o=new Date().toISOString(),n=t=>(t??[]).filter(a=>!p.has(String(a.code??"").trim().toUpperCase())),{data:h,isLoading:l}=j({queryKey:["public-vouchers"],queryFn:async()=>{const{data:t,error:a}=await x.from("user_discounts").select("*").is("parent_contact_id",null).eq("is_active",!0).or(`starts_at.is.null,starts_at.lte.${o}`).or(`ends_at.is.null,ends_at.gte.${o}`).order("created_at",{ascending:!1});if(a)throw a;return t??[]}}),{data:c,isLoading:f}=j({queryKey:["personal-vouchers",s==null?void 0:s.id],queryFn:async()=>{var v;if(!(s!=null&&s.email))return[];const{data:t}=await x.from("parent_contacts").select("id").ilike("email",s.email).limit(1),a=(v=t==null?void 0:t[0])==null?void 0:v.id;if(!a)return[];const{data:m,error:w}=await x.from("user_discounts").select("*").eq("parent_contact_id",a).eq("is_active",!0).order("created_at",{ascending:!1});if(w)throw w;return m??[]},enabled:r}),g=n(h),b=n(c),d=[...g,...b].flatMap(t=>t.applies_to_workshops??[]).filter(Boolean),{data:N}=j({queryKey:["voucher-workshop-names",d.join(",")],queryFn:async()=>{if(d.length===0)return{};const{data:t}=await x.from("workshops_catalog").select("id, workshop_name").in("id",d),a={};return(t??[]).forEach(m=>{a[m.id]=m.workshop_name}),a},enabled:d.length>0});return e.jsxs("div",{className:"min-h-dvh bg-background pb-32",children:[e.jsx(O,{title:"Oferte și vouchere active — AteliereOnline",description:"Coduri de reducere, vouchere și promoții curente pentru atelierele online AteliereOnline.",ogType:"website"}),e.jsx("div",{className:"bg-gradient-to-br from-amber-500/20 via-orange-500/15 to-yellow-500/10 pt-8 pb-10 px-5",children:e.jsx("div",{className:"container mx-auto max-w-4xl",children:e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-amber-500/20 flex items-center justify-center",children:e.jsx(C,{className:"w-6 h-6 text-amber-600 dark:text-amber-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-extrabold text-foreground",children:"Oferte & Reduceri"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Coduri de reducere active pentru atelierele noastre"})]}),!r&&e.jsx(u,{size:"sm",onClick:()=>i("/profile"),className:"shrink-0 rounded-full font-bold",children:"Intră în cont"})]})})}),e.jsxs("div",{className:"container mx-auto max-w-4xl px-5 -mt-4",children:[l?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 mt-6",children:[1,2].map(t=>e.jsx(y,{className:"h-48 rounded-2xl"},t))}):g.length>0?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 mt-6",children:g.map(t=>e.jsx(q,{voucher:t,workshopNames:N??{}},t.id))}):e.jsxs("div",{className:"text-center py-16",children:[e.jsx(C,{className:"w-12 h-12 text-muted-foreground/30 mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-bold text-foreground mb-2",children:"Nicio ofertă publică activă"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Revino mai târziu pentru oferte noi!"})]}),e.jsx("div",{className:"mt-10",children:r?e.jsxs(e.Fragment,{children:[e.jsxs("h2",{className:"text-lg font-bold text-foreground mb-4 flex items-center gap-2",children:[e.jsx(S,{className:"w-5 h-5 text-primary"}),"Ofertele tale personale"]}),f?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:e.jsx(y,{className:"h-48 rounded-2xl"})}):b.length>0?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:b.map(t=>e.jsx(q,{voucher:t,workshopNames:N??{},isPersonal:!0},t.id))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Nu ai vouchere personale active momentan."})]}):e.jsx(z,{className:"border-primary/20 bg-primary/5",children:e.jsxs(L,{className:"p-5 flex items-center gap-4",children:[e.jsx(A,{className:"w-8 h-8 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-semibold text-foreground text-sm",children:"Loghează-te pentru a vedea ofertele tale personale"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Poți avea vouchere dedicate contului tău."})]}),e.jsx(u,{size:"sm",onClick:()=>i("/onboarding"),children:"Loghează-te"})]})})})]})]})},q=({voucher:s,workshopNames:r,isPersonal:p})=>{const[i,o]=B.useState(!1),n=async()=>{try{await navigator.clipboard.writeText(s.code),o(!0),k.success("Cod copiat!"),setTimeout(()=>
1o(!1),2e3)}catch{k.error("Nu am putut copia codul")}},h=s.discount_type==="percent"?`${s.discount_value}% reducere`:`${s.discount_value} RON reducere`,l=s.applies_to_workshops??[],c=l.length>0?l.map(f=>r[f]||"Atelier").join(", "):s.applies_to_workshop||null;return e.jsx(z,{className:"overflow-hidden border-border/60 hover:shadow-md transition-shadow",children:e.jsxs(L,{className:"p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(_,{className:"bg-amber-500/15 text-amber-700 dark:text-amber-300 border-amber-500/30 text-sm font-bold",children:h}),p&&e.jsx(_,{variant:"secondary",className:"text-xs",children:"Personal"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 bg-muted/60 rounded-lg px-3 py-2 font-mono font-bold text-foreground text-sm tracking-wider text-center border border-dashed border-border",children:s.code}),e.jsx(u,{variant:"outline",size:"icon",className:"shrink-0",onClick:n,children:i?e.jsx(V,{className:"w-4 h-4 text-green-500"}):e.jsx(F,{className:"w-4 h-4"})})]}),s.description&&e.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e.jsx("p",{className:"text-xs text-muted-foreground",children:c?`Aplicabil: ${c}`:"Valabil la toate atelierele"}),s.ends_at&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Expiră: ",R(new Date(s.ends_at),"d MMM yyyy",{locale:I})]}),s.cta_url&&e.jsxs(u,{variant:"outline",size:"sm",className:"w-full mt-2",onClick:()=>window.open(s.cta_url,"_blank"),children:[e.jsx(M,{className:"w-3.5 h-3.5 mr-1.5"}),"Vezi detalii"]})]})})};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.