1import{a as n,j as e}from"./query-Cv7TMIMb.js";import{s as y,G as _,J as k,K as w,C,T as x,a3 as i}from"./index-CPlqvBbY.js";import{c as b}from"./react-vendor-CuxgGW6S.js";import{J as v,by as u,aG as B,u as E,bb as H,bx as h}from"./ui-vendor-seEETszD.js";import{e as m}from"./dates-BF29MinS.js";import"./pdf-Bj1Od7c8.js";import"./three-DyNlscO1.js";import"./charts-BRijplOf.js";import"./supabase-CUQpzalg.js";const z=()=>{var o;const{code:l}=b(),[r,a]=n.useState("loading"),[s,f]=n.useState(null),[p,c]=n.useState("");n.useEffect(()=>{l&&j(l)},[l]);const j=async g=>{try{const{data:N,error:d}=await y.rpc("self_check_in",{p_check_in_code:g});if(d)throw d;const t=N;if(!t)throw new Error("empty");if(t.starts_at&&f({starts_at:t.starts_at,ends_at:t.ends_at,courts:{name:t.court_name||""},guest_name:t.by_staff&&t.guest_name||null}),t.ok&&t.already){a("already");return}if(t.ok){a("success");return}switch(t.reason){case"not_authenticated":a("error"),c("Bitte melde dich mit deinem Boomo-Konto an, um einzuchecken.");return;case"too_early":a("error"),c("Check-in ist erst 2 Stunden vor Beginn möglich.");return;case"expired":a("expired");return;case"not_confirmed":a("error"),c("Buchung ist nicht bestätigt.");return;default:a("error"),c("Buchung nicht gefunden.");return}}catch{a("error"),c("Ein Fehler ist aufgetreten.")}};return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsxs(_,{className:"w-full max-w-md",children:[e.jsx(k,{className:"text-center",children:e.jsx(w,{children:"Check-in"})}),e.jsxs(C,{className:"text-center space-y-4",children:[r==="loading"&&e.jsxs("div",{className:"py-8",children:[e.jsx(v,{className:"h-12 w-12 animate-spin text-primary mx-auto"}),e.jsx("p",{className:"mt-4 text-muted-foreground",children:"Wird verarbeitet..."})]}),r==="success"&&e.jsxs("div",{className:"py-8",children:[e.jsx(u,{className:"h-16 w-16 text-primary mx-auto"}),e.jsx("p",{className:"mt-4 text-xl font-semibold",children:"Erfolgreich eingecheckt!"}),s&&e.jsxs("div",{className:"mt-4 space-y-2 text-sm text-muted-foreground",children:[s.guest_name&&e.jsxs("p",{className:"text-base font-semibold text-foreground",children:["Gast: ",s.guest_name]}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(B,{className:"h-4 w-4"}),(o=s.courts)==null?void 0:o.name]}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(E,{className:"h-4 w-4"}),m(new Date(s.starts_at),"dd.MM.yyyy",{locale:i})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(H,{className:"h-4 w-4"}),m(new Date(s.starts_at),"HH:mm",{locale:i})," â ",m(new Date(s.ends_at),"HH:mm",{locale:i})]})]})]}),r==="already"&&e.jsxs("div",{className:"py-8",children:[e.jsx(u,{className:"h-16 w-16 text-accent mx-auto"}),e.jsx("p",{className:"mt-4 text-xl font-semibold",children:"Bereits eingecheckt"}),(s==null?void 0:s.checked_in_at)&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["Check-in um ",m(new Date(s.checked_in_at),"HH:mm",{locale:i})," Uhr"]})]}),r==="expired"&&e.jsxs("div",{className:"py-8",children:[e.jsx(h,{className:"h-16 w-16 text-muted-foreground mx-auto"}),e.jsx("p",{className:"mt-4 text-xl font-semibold",children:e.jsx(x,{children:"Buchung abgelaufen"})}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:e.jsx(x,{children:"Der Check-in-Zeitraum ist vorbei."})})]}),r==="error"&&e.jsxs("div",{className:"py-8",children:[e.jsx(h,{className:"h-16 w-16 text-destructive mx-auto"}),e.jsx("p",{className:"mt-4 text-xl font-semibold",children:"Check-in fehlgeschlagen"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:p})]})]})]})})};export{z 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.