PageSourceSearch

https://johannapardo.de/assets/admin.shows-mcd08_Kb.js

js johannapardo.de collected 2026-10-07 03:21:33 UTC 6,418 bytes, 1 lines download raw bytes

1import{u as y,o as k,g as d,p as S,I as C,J as D,K as L,r as m,j as e,a as A,t as u}from"./index-CHfAEzh6.js";import{u as f}from"./useQuery-BNbnznBU.js";import{L as j}from"./log-out-BGR8mbb7.js";import{P as _}from"./plus-Cc8jWbOu.js";import{P as q}from"./pen-line-uUXbqSEW.js";import{T as F}from"./trash-2-Ch328BbP.js";import"./useBaseQuery-Bttx1P4P.js";function G(){const r=y(),n=k(),l=d(S),t=d(C),i=d(D),s=d(L),p=f({queryKey:["isAdmin"],queryFn:()=>l()}),h=f({queryKey:["shows","admin"],queryFn:()=>t(),enabled:!!p.data?.isAdmin}),[g,o]=m.useState(null);async function b(){await n.cancelQueries(),n.clear(),await A.auth.signOut(),r({to:"/auth",replace:!0})}if(p.isLoading)return e.jsx(v,{children:"Lade…"});if(!p.data?.isAdmin)return e.jsx(v,{children:e.jsxs("div",{className:"text-center max-w-md",children:[e.jsx("p",{className:"font-display text-3xl font-extrabold uppercase",children:"Kein Admin-Zugriff"}),e.jsxs("p",{className:"mt-4 text-sm text-muted-foreground",children:["Dein Konto hat keine Admin-Rolle. Lege sie in der Lovable-Cloud-Datenbank in der Tabelle ",e.jsx("code",{className:"bg-acid/30 px-1",children:"user_roles"})," für deine User-ID an (role = ",e.jsx("code",{className:"bg-acid/30 px-1",children:"admin"}),")."]}),e.jsxs("button",{onClick:b,className:"mt-8 inline-flex items-center gap-2 border-2 border-ink px-5 py-2 text-xs uppercase tracking-widest",children:[e.jsx(j,{className:"h-3 w-3"})," Ausloggen"]})]})});async function w(a){try{await i({data:{id:a.id,show_date:a.show_date,city:a.city,venue:a.venue,program:a.program||null,ticket_url:a.ticket_url||null,status:a.status||"planned"}}),u.success("Gespeichert."),o(null),n.invalidateQueries({queryKey:["shows"]})}catch(x){u.error(x.message??"Fehler")}}async function N(a){if(confirm("Diesen Termin wirklich löschen?"))try{await s({data:{id:a}}),u.success("Gelöscht."),n.invalidateQueries({queryKey:["shows"]})}catch(x){u.error(x.message??"Fehler")}}return e.jsxs("section",{className:"mx-auto max-w-7xl px-6 py-16 lg:px-10",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-4 mb-12",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.3em] text-olive",children:"Admin"}),e.jsxs("h1",{className:"mt-2 font-display text-5xl font-extrabold uppercase leading-none tracking-tight",children:["Shows",e.jsx("span",{className:"text-acid",children:"."})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:()=>o({status:"planned",show_date:new Date().toISOString().slice(0,16)}),className:"inline-flex items-center gap-2 bg-ink px-5 py-3 text-xs font-bold uppercase tracking-widest text-cream hover:bg-olive",children:[e.jsx(_,{className:"h-4 w-4"})," Neuer Termin"]}),e.jsxs("button",{onClick:b,className:"inline-flex items-center gap-2 border-2 border-ink px-5 py-3 text-xs font-bold uppercase tracking-widest hover:bg-acid",children:[e.jsx(j,{className:"h-4 w-4"})," Logout"]})]})]}),g&&e.jsx(T,{initial:g,onCancel:()=>o(null),onSave:w}),e.jsxs("div",{className:"mt-8 border-y-2 border-ink",children:[h.data?.shows.length===0&&e.jsx("p",{className:"py-12 text-center text-sm text-muted-foreground",children:"Noch keine Termine."}),h.data?.shows.map(a=>e.jsxs("div",{className:"grid grid-cols-12 gap-4 items-center border-b border-ink/10 py-4",children:[e.jsx("div",{className:"col-span-3 font-mono text-xs",children:new Date(a.show_date).toLocaleString("de-DE")}),e.jsx("div",{className:"col-span-3 font-display font-bold uppercase",children:a.city}),e.jsx("div",{className:"col-span-3 text-sm text-muted-foreground",children:a.venue}),e.jsx("div",{className:"col-span-1 text-[10px] uppercase tracking-widest",children:a.status}),e.jsxs("div",{className:"col-span-2 flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>o(a),className:"p-2 hover:bg-acid",children:e.jsx(q,{className:"h-4 w-4"})}),e.jsx("button",{onClick:()=>N(a.id),className:"p-2 hover:bg-destructive hover:text-cream",children:e.jsx(F,{className:"h-4 w-4"})})]})]},a.id))]})]})}function T({initial:r,onSave:n,onCancel:l}){const[t,i]=m.useState(r);return m.useEffect(()=>i(r),[r]),e.jsxs("form",{onSubmit:s=>{s.preventDefault(),n(t)},className:"grid gap-4 border-2 border-ink p-6 lg:grid-cols-2",children:[e.jsx(c,{label:"Datum & Uhrzeit",type:"datetime-local",value:I(t.show_date),onChange:s=>i({...t,show_date:new Date(s).toISOString()}),required:!0}),e.jsx(c,{label:"Stadt",value:t.city??"",onChange:s=>i({...t,city:s}),required:!0}),e.jsx(c,{label:"Veranstaltungsort",value:t.venue??"",onChange:s=>i({...t,venue:s}),required:!0}),e.jsx(c,{label:"Programm (optional)",value:t.program??"",onChange:s=>i({...t,program:s})}),e.jsx(c,{label:"Ticket-Link (optional)",value:t.ticket_url??"",onChange:s=>i({...t,ticket_url:s})}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-widest text-muted-foreground",children:"Status"}),e.jsxs("select",{value:t.status??"planned",onChange:s=>i({...t,status:s.target.value}),className:"mt-1 w-full border-b-2 border-ink bg-transparent py-2 outline-none",children:[e.jsx("option",{value:"planned",children:"geplant"}),e.jsx("option",{value:"soldout",children:"ausverkauft"}),e.jsx("option",{value:"cancelled",children:"abgesagt"})]})]}),e.jsxs("div",{className:"lg:col-span-2 flex gap-2 mt-2",children:[e.jsx("button",{type:"submit",className:"bg-ink px-6 py-3 text-xs font-bold uppercase tracking-widest text-cream hover:bg-olive",children:"Speichern"}),e.jsx("button",{type:"button",onClick:l,className:"border-2 border-ink px-6 py-3 text-xs font-bold uppercase tracking-widest hover:bg-acid",children:"Abbrechen"})]})]})}function c({label:r,value:n,onChange:l,type:t="text",required:i}){return e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-widest text-muted-foreground",children:r}),e.jsx("input",{type:t,required:i,value:n,onChange:s=>l(s.target.value),className:"mt-1 w-full border-b-2 border-ink bg-transparent py-2 outline-none focus:border-acid"})]})}function I(r){if(!r)return"";const n=new Date(r),l=t=>String(t).padStart(2,"0");return`${n.getFullYear()}-${l(n.getMonth()+1)}-${l(n.getDate())}T${l(n.getHours())}:${l(n.getMinutes())}`}function v({children:r}){return e.jsx("div",{className:"flex min-h-[60vh] items-center justify-center px-6",children:r})}export{G 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.