1import{r as h,j as e,L as C}from"./react-vendor-D9qNvWQG.js";import{x as D,k as A,a4 as _,B as u,cc as E,cd as N,ce as m,cD as k,n as F,a5 as M,a6 as S,ai as K,G as q,aM as B,b_ as L,b$ as O,c0 as y,c1 as r,c2 as H,c3 as t,f as Q,au as P,K as R,M as U,N as z,O as $,P as G,Q as I,X as V,R as W,s as x,y as c,bj as X,ax as Z}from"./index-BXvgJPFT.js";import{P as J}from"./PageHeader-BuAS4uuG.js";import{bg as Y,A as ee,aB as se,E as ae}from"./ui-vendor-PCW79cM9.js";import"./supabase-vendor-HycfBNB9.js";function ce(){const[i,v]=h.useState("all"),[p,d]=h.useState(!1),[j,g]=h.useState(null),l=D(),{data:o,isLoading:T}=A({queryKey:["membership-applications"],queryFn:async()=>{const{data:s,error:n}=await x.from("membership_applications").select("id, child_first_name, child_last_name, child_birth_year, parent_first_name, parent_last_name, parent_email, parent_phone, status, created_at, responded_at, consent_accepted_at").order("created_at",{ascending:!1});if(n)throw n;return s}}),b=_({mutationFn:async s=>{const{error:n}=await x.functions.invoke("membership-application-send",{body:{applicationId:s}});if(n)throw n},onSuccess:()=>{l.invalidateQueries({queryKey:["membership-applications"]}),l.invalidateQueries({queryKey:["membership-applications-count"]}),c.success("Unterlagen erfolgreich versendet")},onError:s=>{console.error("Error sending documents:",s),c.error(X(s,"Fehler beim Versenden der Unterlagen"))}}),f=_({mutationFn:async s=>{const{error:n}=await x.from("membership_applications").delete().eq("id",s);if(n)throw n},onSuccess:()=>{l.invalidateQueries({queryKey:["membership-applications"]}),l.invalidateQueries({queryKey:["membership-applications-count"]}),c.success("Anfrage gelöscht"),d(!1),g(null)},onError:s=>{console.error("Error deleting application:",s),c.error("Fehler beim Löschen")}}),a=o==null?void 0:o.filter(s=>i==="all"?!0:s.status===i),w=s=>{g(s),d(!0)};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(J,{icon:Y,title:"FuÃballkindergarten",subtitle:"Mitgliedsanfragen verwalten",actionSlot:e.jsx(u,{asChild:!0,variant:"outline",children:e.jsxs(C,{to:"/attendance-overview",children:[e.jsx(ee,{className:"h-4 w-4"}),"Zurück zur Ãbersicht"]})})}),e.jsxs(E,{value:i,onValueChange:s=>v(s),children:[e.jsxs(N,{children:[e.jsx(m,{value:"all",children:"Alle"}),e.jsx(m,{value:"OFFEN",children:"Offen"}),e.jsx(m,{value:"BEANTWORTET",children:"Beantwortet"})]}),e.jsx(k,{value:i,className:"mt-6",children:e.jsxs(F,{children:[e.jsxs(M,{children:[e.jsxs(S,{children:["Anfragen (",(a==null?void 0:a.length)||0,")"]}),e.jsx(K,{children:"Ãbersicht aller Mitgliedschaftsanfragen"})]}),e.jsx(q,{children:T?e.jsx("div",{className:"text-center py-8",children:"Lädt..."}):(a==null?void 0:a.length)===0?e.jsx(B,{title:"Keine Anfragen vorhanden"}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(L,{children:[e.jsx(O,{children:e.jsxs(y,{children:[e.jsx(r,{children:"Kind"}),e.jsx(r,{children:"Geburtsjahr"}),e.jsx(r,{children:"Elternteil"}),e.jsx(r,{children:"E-Mail"}),e.jsx(r,{children:"Telefon"}),e.jsx(r,{children:"Status"}),e.jsx(r,{children:"Eingegangen"}),e.jsx(r,{children:"Aktionen"})]})}),e.jsx(H,{children:a==null?void 0:a.map(s=>e.jsxs(y,{children:[e.jsxs(t,{className:"font-medium",children:[s.child_first_name," ",s.child_last_name]}),e.jsx(t,{children:s.child_birth_year}),e.jsxs(t,{children:[s.parent_first_name," ",s.parent_last_name]}),e.jsx(t,{children:e.jsx("a",{href:`mailto:${s.parent_email}`,className:"text-primary hover:underline",children:s.parent_email})}),e.jsx(t,{children:e.jsx("a",{href:`tel:${s.parent_phone}`,className:"text-primary hover:underline",children:s.parent_phone})}),e.jsx(t,{children:e.jsx(Q,{variant:s.status==="OFFEN"?"default":"secondary",children:s.status})}),e.jsx(t,{children:P(new Date(s.created_at),"dd.MM.yyyy HH:mm",{locale:Z})}),e.jsx(t,{children:e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(u,{size:"sm",variant:"outline",onClick:()=>b.mutate(s.id),disabled:b.isPending,children:[e.jsx(se,{className:"h-4 w-4 mr-2"}),"Unterlagen senden"]}),e.jsx(u,{size:"sm",variant:"outline",onClick:()=>w(s.id),disabled:f.isPending,children:e.jsx(ae,{className:"h-4 w-4"})})]})})]},s.id))})]})})})]})})]}),e.jsx(R,{open:p,onOpenChange:d,children:e.jsxs(U,{children:[e.jsxs(z,{children:[e.jsx($,{children:"Anfrage löschen?"}),e.jsx(G,{children:"Möchten Sie diese Anfrage wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden."})]}),e.jsxs(I,{children:[e.jsx(V,{children:"Abbrechen"}),e.jsx(W,{onClick:()=>j&&f.mutate(j),children:"Löschen"})]})]})})]})}export{ce 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.