PageSourceSearch

https://dramaverket.se/assets/Shows-DJAOe8Gi.js

js dramaverket.se collected 2026-10-02 20:46:37 UTC 15,459 bytes, 9 lines download raw bytes

1import{j as e}from"./ui-D9vYnNRd.js";import{L as Y}from"./Layout-BLNt5gIm.js";import{r as c}from"./vendor-o8UMtg5z.js";import{B as C}from"./badge-Dd2cdvt0.js";import{B as w}from"./button-Q__49QH4.js";import{I as b,L as M,f as Z}from"./label-DfuX_cIP.js";import{s as $,J as f}from"./index-DKQKWcqd.js";import{C as W,a as q}from"./chevron-up-Cqcxvlij.js";import{I as ee}from"./ImageLoader-BQLuY4Da.js";import{u as te}from"./query-CK-6UiBM.js";import{S as se}from"./StayUpdatedSection-y1koD_iO.js";import{u as ae}from"./useRealtimeTable-DEOqQIWD.js";import{s as re}from"./sv-Mt01WpoR.js";import"./router-BDCNlvNV.js";import"./supabase-CFT6Uc19.js";import"./NewsletterModal-DrGA3dSS.js";import"./dialog-BRlT6ZD5.js";import"./circle-check-DR46CD8B.js";import"./mail-BFiy2o5G.js";import"./clock-CfX5Yb5A.js";import"./instagram-DfJbCfiP.js";const ne=({show:s,isCompact:v=!1})=>{const[d,r]=c.useState(1),[n,g]=c.useState(0),[l,P]=c.useState(0),[j,K]=c.useState(""),[i,x]=c.useState(null),[S,p]=c.useState(""),[N,U]=c.useState(""),[k,z]=c.useState(""),[y,O]=c.useState(""),[E,I]=c.useState(!1),[B,A]=c.useState(!1),_=v&&!B,o=s.available_tickets,m=n+l,L=n*s.price+l*(s.discounted_price??s.price),G=()=>{if(!i||m===0)return{discountAmount:0,ticketsWithDiscount:0};const t=i.maxTicketsPerPurchase?Math.min(m,i.maxTicketsPerPurchase):m,a=L/m;return i.type==="percentage"&&i.percentage?{discountAmount:Math.round(a*t*(i.percentage/100)),ticketsWithDiscount:t}:i.type==="fixed"&&i.amount?{discountAmount:i.amount*t,ticketsWithDiscount:t}:{discountAmount:0,ticketsWithDiscount:0}},{discountAmount:T,ticketsWithDiscount:F}=G(),h=L-T,J=async t=>{if(!t.trim()){x(null),p("");return}try{const{data:a,error:u}=await $.from("discount_codes").select("*").eq("code",t.toUpperCase()).eq("is_active",!0).single();if(u||!a){p("Ogiltig rabattkod"),x(null);return}const D=new Date;if(a.valid_until&&new Date(a.valid_until)<D){p("Rabattkoden har gått ut"),x(null);return}if(a.max_uses&&a.current_uses>=a.max_uses){p("Rabattkoden har använts upp"),x(null);return}x({code:a.code,type:a.discount_type||"percentage",percentage:a.discount_percentage,amount:a.discount_amount,maxTicketsPerPurchase:a.max_tickets_per_purchase}),p("");const H=a.discount_type==="fixed"?`${a.discount_amount} kr`:`${a.discount_percentage}%`,X=a.max_tickets_per_purchase?` (max ${a.max_tickets_per_purchase} biljett${a.max_tickets_per_purchase>1?"er":""})`:"";f.success(`Rabatt på ${H}${X} tillämpad!`)}catch{p("Fel vid validering av rabattkod"),x(null)}},R=async()=>{if(h>0&&h<50){f.error("Betalningar under 50 kr kan inte genomföras. Kontakta oss för hjälp.");return}I(!0);try{const{data:t,error:a}=await $.functions.invoke("create-ticket-checkout",{body:{showId:s.id,quantity:m,regularTickets:n,discountedTickets:l,buyerName:N,buyerEmail:k,buyerPhone:y,discountCode:j||null,finalPrice:h}});if(a)throw a;if(t?.ticketSaleId)window.location.href=`/ticket-success?ticket_id=${t.ticketSaleId}`;else if(t?.url)window.location.href=t.url;else throw console.error("No valid redirect received from checkout:",t),new Error("Inget giltigt svar från betalningssystemet")}catch(t){console.error("Payment error:",t),f.error("Ett fel uppstod vid betalningen")}finally{I(!1)}},V=()=>{if(d===1){if(m===0){f.error("Välj minst en biljett");return}if(m>o){f.error(`Endast ${o} biljetter tillgängliga`);return}r(2)}else if(d===2){if(!N||!k||!y){f.error("Alla fält måste fyllas i");return}R()}},Q=()=>{d>1&&r(d-1)};return e.jsxs("div",{className:"bg-gray-100 border-0",children:[s.image_url&&e.jsx("img",{src:s.image_url,alt:s.title,className:_?"w-full aspect-[3/2] object-cover":"w-full aspect-video object-cover",loading:"lazy",decoding:"async"}),e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4 gap-2",children:[e.jsx("h3",{className:"text-xl leading-tight",children:s.title}),(()=>{if(s.external_ticket_url)return null;const t=s.available_tickets,a=s.available_tickets+s.sold_tickets,u=Math.ceil(a*.1),D=Math.ceil(a*.2);return t<=0?e.jsx(C,{variant:"destructive",className:"bg-red-600 hover:bg-red-700 flex-shrink-0 mt-1",children:"Fullsatt!"}):t<=15?e.jsxs(C,{variant:"destructive",className:"bg-red-600 hover:bg-red-700 text-center whitespace-nowrap flex-shrink-0 mt-1",children:[t," ",t===1?"plats":"platser"," kvar!"]}):t<=u?e.jsx(C,{variant:"destructive",className:"bg-red-600 hover:bg-red-700 text-center whitespace-nowrap flex-shrink-0 mt-1",children:"Fåtal kvar"}):t<=D?e.jsx(C,{variant:"destructive",className:"bg-red-600 hover:bg-red-700 text-center whitespace-nowrap flex-shrink-0 mt-1",children:"Snart slutsåld"}):null})()]}),e.jsx("div",{className:"text-sm text-stone-700 dark:text-stone-200 mb-4 -mt-2",children:s.date}),!s.external_ticket_url&&o>0&&e.jsxs("div",{className:"mb-6 space-y-3",children:[e.jsx("h4",{className:"text-lg font-normal",children:"Köp biljetter"}),d===1&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"font-medium text-sm",children:s.price===0?"Gratis":`Pris ${s.price}kr`}),e.jsxs("div",{className:"relative w-32",children:[e.jsx(b,{type:"number",min:"0",max:o-l,value:n,onChange:t=>g(Math.max(0,Math.min(o-l,parseInt(t.target.value)||0))),className:"border-blue-500 rounded-none w-full pr-8 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"}),e.jsxs("div",{className:"absolute right-0 top-0 h-full w-8 flex flex-col border-l border-blue-500",children:[e.jsx("button",{type:"button",onClick:()=>
1g(Math.min(o-l,n+1)),className:"flex-1 flex items-center justify-center transition-colors duration-300 active:transition-none active:bg-blue-600 active:text-white",children:e.jsx(W,{className:"h-4 w-4 text-blue-500"})}),e.jsx("button",{type:"button",onClick:()=>g(Math.max(0,n-1)),className:"flex-1 flex items-center justify-center transition-colors duration-300 active:transition-none active:bg-blue-600 active:text-white",children:e.jsx(q,{className:"h-4 w-4 text-blue-500"})})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"font-normal text-sm",children:"Ev. rabattkod"}),e.jsx(b,{id:"discountCode",placeholder:"",value:j,onChange:t=>K(t.target.value.toUpperCase()),onBlur:()=>j&&J(j),className:"border-blue-500 rounded-none w-24"}),S&&e.jsx("div",{className:"text-xs text-destructive",children:S}),i&&!S&&e.jsxs("div",{className:"text-xs text-green-600",children:["Rabatt pÃ¥ ",i.type==="fixed"?`${i.amount} kr`:`${i.percentage}%`,i.maxTicketsPerPurchase&&` (max ${i.maxTicketsPerPurchase} biljett${i.maxTicketsPerPurchase>1?"er":""})`]})]})]}),s.discounted_price&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"font-medium text-sm",children:["Student/pensionär ",s.discounted_price,"kr"]}),e.jsxs("div",{className:"relative w-32",children:[e.jsx(b,{type:"number",min:"0",max:o-n,value:l,onChange:t=>P(Math.max(0,Math.min(o-n,parseInt(t.target.value)||0))),className:"border-blue-500 rounded-none w-full pr-8 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"}),e.jsxs("div",{className:"absolute right-0 top-0 h-full w-8 flex flex-col border-l border-blue-500",children:[e.jsx("button",{type:"button",onClick:()=>P(Math.min(o-n,l+1)),className:"flex-1 flex items-center justify-center transition-colors duration-300 active:transition-none active:bg-blue-600 active:text-white",children:e.jsx(W,{className:"h-4 w-4 text-blue-500"})}),e.jsx("button",{type:"button",onClick:()=>P(Math.max(0,l-1)),className:"flex-1 flex items-center justify-center transition-colors duration-300 active:transition-none active:bg-blue-600 active:text-white",children:e.jsx(q,{className:"h-4 w-4 text-blue-500"})})]})]})]}),e.jsx(w,{onClick:V,className:"bg-blue-500 hover:bg-blue-600 text-white px-8 py-2",disabled:m===0,children:"Fortsätt →"})]}),d===2&&e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"-mt-0.5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{htmlFor:"buyerName",className:"font-medium text-sm",children:"Namn"}),e.jsx(b,{id:"buyerName",placeholder:"Ange ditt namn",value:N,onChange:t=>U(t.target.value),className:"rounded-none border-blue-500 h-10"})]}),e.jsxs("div",{className:"space-y-2 pt-4",children:[e.jsx(M,{htmlFor:"buyerEmail",className:"font-medium text-sm",children:"E-post"}),e.jsx(b,{id:"buyerEmail",type:"email",placeholder:"[email protected]",value:k,onChange:t=>z(t.target.value),className:"rounded-none border-blue-500 h-10"})]}),e.jsxs("div",{className:"space-y-2 pt-4",children:[e.jsx(M,{htmlFor:"buyerPhone",className:"font-medium text-sm",children:"Telefonnummer"}),e.jsx(b,{id:"buyerPhone",type:"tel",placeholder:"070-123 45 67",value:y,onChange:t=>O(t.target.value),className:"rounded-none border-blue-500 h-10"})]}),e.jsx("div",{className:"pt-4",children:e.jsxs("div",{className:"space-y-2",children:[n>0&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("span",{children:["Ordinarie (",n,"st)"]}),e.jsxs("span",{children:[n*s.price,"kr"]})]}),l>0&&s.discounted_price&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("span",{children:["Student/pensionär (",l,"st)"]}),e.jsxs("span",{children:[l*s.discounted_price,"kr"]})]}),i&&T>0&&e.jsxs("div",{className:"flex justify-between text-sm text-green-600",children:[e.jsxs("span",{children:["Rabatt pÃ¥ ",F," biljett",F>1?"er":"",i.type==="fixed"?` (${i.amount} kr/st)`:` (${i.percentage}%)`]}),e.jsxs("span",{children:["-",T,"kr"]})]}),e.jsxs("div",{className:"flex justify-between items-center font-semibold pt-2 pb-4 border-t",children:[e.jsx("span",{children:"Totalt"}),e.jsx("span",{children:h===0?"Gratis":`${h}kr`})]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(w,{onClick:Q,variant:"outline",className:"flex-1",children:"Tillbaka"}),e.jsx(w,{onClick:R,disabled:E||!N||!k||!y,className:"flex-1 bg-blue-500 hover:bg-blue-600 text-white",children:E?"Bearbetar...":h===0?"Boka gratis":"Betala"})]})]})})]}),s.external_ticket_url&&e.jsxs("div",{onClick:()=>window.open(s.external_ticket_url,"_blank"),className:"mb-6 text-blue-500 text-xl cursor-pointer inline-block",children:[e.jsx("span",{className:"underline",children:"Köp biljetter"}),e.jsx("span",{className:"ml-2",children:"→"})]}),!s.external_ticket_url&&o===0&&e.jsx("div",{className:"mb-6 text-red-600 text-xl font-medium",children:"SlutsÃ¥lt"}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-lg mb-3 font-normal",children:"Praktisk information"}),e.jsxs("div",{className:"space-y-1 text-sm",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-blue-500",children:"–"}),e.jsxs("span",{className:"text-foreground",children:["Tid: ",s.time," ",s.doors_time&&`(Dörrar: ${s.doors_time.slice(0,5)})`]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-blue-500",children:"–"}),s.venue_google_maps_url?e.jsxs("a",{href:s.venue_google_maps_url,target:"_blank",rel:"noopener noreferrer",className:"text-foreground hover:underline cursor-pointer",children:["Plats: ",s.venue]}):e.jsxs("span",{className:"text-foreground",children:["Plats: ",s.venue]})]}),s.duration&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-blue-500",children:"–"}),e.jsxs("span",{className:"text-foreground",children:["Längd: ",s.duration]})]}),s.description&&s.description.split(`
2`).map((t,a)=>t.trim().startsWith("- ")?e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-blue-500",children:"–"}),e.jsx("span",{className:"text-foreground",children:t.trim().substring(2)})]},`bullet-${a}`):null)]})]}),_&&e.jsx("button",{onClick:()=>A(!0),className:"mb-6 text-blue-500 hover:text-blue-600 transition-colors text-sm font-medium",children:"Läs mer om föreställningen →"}),v&&B&&e.jsx("button",{onClick:()=>A(!1),className:"mb-6 text-blue-500 hover:text-blue-600 transition-colors text-sm font-medium",children:"Visa mindre ↑"}),!_&&s.description&&(()=>{const t=s.description.split(`
3`).filter(a=>!a.trim().startsWith("- ")&&a.trim()!=="");return t.length===0?null:e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-lg mb-3 font-normal",children:"Om föreställningen"}),e.jsx("div",{className:"text-foreground text-sm leading-relaxed",children:t.map((a,u)=>e.jsx("div",{className:"my-2",children:a},u))})]})})(),!_&&s.performers&&s.performers.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-lg mb-4 font-normal",children:"Medverkande"}),e.jsx("div",{className:"border-2 border-blue-500 p-4 space-y-4",children:[...s.performers].sort((t,a)=>t.name.localeCompare(a.name,"sv")).map(t=>e.jsxs("div",{className:"flex flex-col md:flex-row md:items-start gap-4",children:[t.image_url&&e.jsx("img",{src:t.image_url,alt:t.name,className:"w-32 h-32 md:w-40 md:h-40 object-cover flex-shrink-0",loading:"lazy",decoding:"async"}),e.jsxs("div",{className:"min-w-0 text-left",children:[e.jsx("h5",{className:"font-medium text-base mb-1",children:t.name}),t.bio&&e.jsx("p",{className:"text-sm text-foreground",children:t.bio})]})]},t.id))})]})]})]})},Se=()=>{const{data:s,isLoading:v}=te({queryKey:["shows"],queryFn:async()=>{const{data:r,error:n}=await $.from("shows").select(`
4          *,
5          venue:venues(name, google_maps_url),
6          show_performers(
7            performer:performers(id, name, bio, image_url)
8          )
9        `).eq("status","active").order("date",{ascending:!0}).order("time",{ascending:!0});if(n)throw console.error("Error fetching shows:",n),n;return console.log("Fetched shows:",r),r}}),d=s&&s.length!==1;return ae({table:"shows",events:["UPDATE"],invalidateKeys:[{queryKey:["shows"]}],channelId:"shows-page"}),e.jsxs(Y,{noPadding:!0,children:[!v&&(!s||s.length===0)&&e.jsx("div",{className:"pt-20 bg-[#2a2a2a]",children:e.jsx(ee,{src:"/lovable-uploads/c3362243-b346-4847-a552-bb55724abf8c.png",alt:"Dramaverket föreställning",className:"w-full aspect-[16/9] md:aspect-[24/9] object-cover",priority:!0,sizes:"100vw"})}),e.jsx("div",{className:"container mx-auto px-3 md:px-6 py-12 pt-24",children:e.jsxs("section",{className:"mb-4",children:[e.jsx("h2",{className:"text-2xl mb-8 text-center",children:"Kommande föreställningar"}),v?e.jsx("div",{className:"text-center text-muted-foreground",children:"Laddar föreställningar..."}):s&&s.length>0?e.jsx("div",{className:"grid gap-6 lg:grid-cols-2 max-w-6xl mx-auto",children:s.map(r=>e.jsx(ne,{isCompact:d,show:{id:r.id,title:r.title,date:Z(new Date(r.date),"d MMMM yyyy",{locale:re}
9),time:r.time?.slice(0,5)||"",venue:r.venue?.name||"Plats ej angiven",venue_google_maps_url:r.venue?.google_maps_url||void 0,price:r.price??200,discounted_price:r.discounted_price??void 0,external_ticket_url:r.external_ticket_url||void 0,description:r.description||"",status:r.status||"active",image_url:r.image_url||void 0,available_tickets:r.available_tickets??165,sold_tickets:r.sold_tickets??0,duration:r.duration||void 0,doors_time:r.doors_time||void 0,performers:(r.show_performers?.map(n=>n.performer)||[]).sort((n,g)=>n.name.localeCompare(g.name,"sv"))}},r.id))}):e.jsx("div",{className:"text-center text-muted-foreground",children:"Inga kommande föreställningar för tillfället."})]})}),e.jsx(se,{showIcons:!0})]})};export{Se 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.