PageSourceSearch

https://www.ozmen-yaylak.com/assets/AdminGoodies-odgvBAho.js

js ozmen-yaylak.com collected 2026-10-07 05:25:25 UTC 7,644 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FileUploadWidget-OPvqR83W.js","assets/index-BBwi5kqS.js","assets/index-D5Sr9NVf.css","assets/copy-BoThfsVL.js","assets/download-BYcO72kY.js","assets/upload-C75QbzjY.js"])))=>i.map(i=>d[i]);
2import{w as O,d as R,r as n,p as Q,x as y,j as e,aj as q,B as h,P as M,e as G,O as F,T as V,H as J,I as U,J as W,K as Z,a9 as X,ak as Y,s as l}from"./index-BBwi5kqS.js";import{I as $}from"./input-JLfvfLkB.js";import{L as c}from"./label-YaqFE0Nc.js";import{T as ee}from"./textarea-9_xSeRB0.js";import{S as b}from"./switch-BqgZugcn.js";import{A as se,b as ie,c as te,d as re,e as ae,f as ne,g as oe,h as le}from"./alert-dialog-Dc8nynUP.js";import{A as ce,a as de}from"./AdminPage-D_7uJR4j.js";import{A as me}from"./AdminListRow-CV97lqjQ.js";import{A as ue}from"./AdminRowActions-Ckr28VRC.js";import{C as he}from"./circle-alert-B8QTiSEd.js";import{L as P}from"./loader-circle-DmhKP_P8.js";import{G as xe}from"./grip-vertical-B8GLCcaf.js";import{P as pe}from"./pencil-DThdb1_D.js";import"./square-CxzJ1rrm.js";import"./dropdown-menu-DkI2NnXX.js";import"./index-Gb2yqO_J.js";import"./ellipsis-vertical-BudpJkcj.js";const fe=n.lazy(()=>Y(()=>import("./FileUploadWidget-OPvqR83W.js"),__vite__mapDeps([0,1,2,3,4,5]))),T={title:"",description:"",file_url:"",is_active:!0,requires_email_confirmation:!0};function Te(){var D;const x=O(),{toast:p}=R(),[k,f]=n.useState(null),[d,j]=n.useState(!1),[i,o]=n.useState(T),[E,C]=n.useState(!1),[m,g]=n.useState(null),{data:r,isLoading:v,isError:I,error:_,refetch:A,isFetching:S}=Q({queryKey:["admin-goodies"],queryFn:async()=>{const{data:s,error:t}=await l.from("goodies").select("*").order("sort_order",{ascending:!0});if(t)throw t;return s},staleTime:3e4,gcTime:5*6e4,retry:1});n.useEffect(()=>{if(!v){C(!1);return}const s=setTimeout(()=>C(!0),8e3);return()=>clearTimeout(s)},[v]);const w=y({mutationFn:async()=>{const s={title:i.title.trim(),description:i.description.trim()||null,file_url:i.file_url.trim()||null,is_active:i.is_active,requires_email_confirmation:i.requires_email_confirmation};if(d){const t=(r==null?void 0:r.reduce((u,H)=>Math.max(u,H.sort_order),-1))??-1,{error:a}=await l.from("goodies").insert({...s,sort_order:t+1});if(a)throw a}else{const{error:t}=await l.from("goodies").update(s).eq("id",k.id);if(t)throw t}},onSuccess:()=>{x.invalidateQueries({queryKey:["admin-goodies"]}),p({title:d?"Goodie erstellt":"Goodie aktualisiert"}),N()},onError:s=>{p({title:"Fehler",description:s.message,variant:"destructive"})}}),L=y({mutationFn:async s=>{const{error:t}=await l.from("goodies").delete().eq("id",s);if(t)throw t},onSuccess:()=>{x.invalidateQueries({queryKey:["admin-goodies"]}),p({title:"Goodie gelöscht"})}}),z=y({mutationFn:async({id:s,is_active:t})=>{const{error:a}=await l.from("goodies").update({is_active:t}).eq("id",s);if(a)throw a},onSuccess:()=>{x.invalidateQueries({queryKey:["admin-goodies"]})}}),K=()=>{j(!0),o(T),f({})},B=s=>{j(!1),o({title:s.title,description:s.description||"",file_url:s.file_url||"",is_active:s.is_active,requires_email_confirmation:s.requires_email_confirmation}),f(s)},N=()=>{f(null),j(!1)};return e.jsxs(ce,{children:[e.jsx(de,{title:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-6 w-6 text-primary"}),"Goodies"]}),description:"Kostenlose Downloads & Ressourcen verwalten",actions:e.jsxs(h,{variant:"admin-primary",size:"admin-sm",onClick:K,className:"gap-2",children:[e.jsx(M,{className:"h-4 w-4"})," Neues Goodie"]})}),I?e.jsxs(G,{className:"p-6 flex flex-col items-center gap-3 text-center",children:[e.jsx(he,{className:"h-8 w-8 text-destructive"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-foreground",children:"Goodies konnten nicht geladen werden"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:_==null?void 0:_.message})]}),e.jsxs(h,{variant:"admin-secondary",size:"admin-sm",onClick:()=>A(),disabled:S,children:[S&&e.jsx(P,{className:"h-4 w-4 animate-spin mr-1.5"}),"Erneut versuchen"]})]}):v?e.jsxs("div",{className:"grid gap-3",children:[[0,1,2].map(s=>e.jsx(F,{className:"h-[88px] w-full rounded-lg"},s)),E&&e.jsxs("p",{className:"text-xs text-muted-foreground text-center",children:["Verbindung dauert ungewöhnlich lange …"," ",e.jsx("button",{onClick:()=>A(),className:"underline",children:"erneut versuchen"})]})]}):e.jsxs("div",{className:"grid gap-2",children:[r==null?void 0:r.map(s=>{const t=[s.is_active?"Aktiv":"Inaktiv",s.requires_email_confirmation?"Double-Opt-In":null,s.file_url||null].filter(
2Boolean);return e.jsx(G,{className:"admin-drag-item",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx(xe,{className:"h-4 w-4 text-muted-foreground shrink-0 hidden md:block mt-4 ml-3 cursor-grab"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(me,{icon:q,muted:!s.is_active,title:s.title,meta:t.map((a,u)=>e.jsxs("span",{className:"truncate max-w-[20ch]",children:[a,u<t.length-1?" ·":""]},u)),preview:s.description||void 0,actions:e.jsx(ue,{leading:e.jsx(b,{checked:s.is_active,onCheckedChange:a=>z.mutate({id:s.id,is_active:a})}),actions:[{label:"Bearbeiten",icon:pe,onClick:()=>B(s)},{label:"Löschen",icon:V,onClick:()=>g(s.id),destructive:!0,separatorAbove:!0}]})})})]})},s.id)}),(r==null?void 0:r.length)===0&&e.jsx("p",{className:"text-center text-muted-foreground py-12",children:"Noch keine Goodies vorhanden"})]}),e.jsx(se,{open:!!m,onOpenChange:s=>!s&&g(null),children:e.jsxs(ie,{className:"skeuo-scope",children:[e.jsxs(te,{children:[e.jsx(re,{children:"Goodie löschen?"}),e.jsxs(ae,{children:["„",(D=r==null?void 0:r.find(s=>s.id===m))==null?void 0:D.title,'" wird unwiderruflich gelöscht.']})]}),e.jsxs(ne,{children:[e.jsx(oe,{children:"Abbrechen"}),e.jsx(le,{onClick:()=>{m&&(L.mutate(m),g(null))},children:"Löschen"})]})]})}),e.jsx(J,{open:!!k,onOpenChange:s=>!s&&N(),children:e.jsxs(U,{side:"right",className:"skeuo-scope sm:max-w-md overflow-y-auto",children:[e.jsx(W,{children:e.jsx(Z,{children:d?"Neues Goodie":"Goodie bearbeiten"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(c,{children:"Titel *"}),e.jsx($,{value:i.title,onChange:s=>o({...i,title:s.target.value}),placeholder:"z. B. Ratgeber Kennenlernphase"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(c,{children:"Beschreibung"}),e.jsx(ee,{value:i.description,onChange:s=>o({...i,description:s.target.value}),placeholder:"Kurze Beschreibung des Downloads",rows:3})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(c,{children:"Datei"}),e.jsx(n.Suspense,{fallback:e.jsx(F,{className:"h-24 w-full rounded-md"}),children:e.jsx(fe,{value:i.file_url,onChange:s=>o({...i,file_url:s}),bucket:"goodies",label:"Datei hierher ziehen",acceptLabel:"PDF, ZIP, etc.",compact:!0})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{htmlFor:"goodie-active",children:"Aktiv"}),e.jsx(b,{id:"goodie-active",checked:i.is_active,onCheckedChange:s=>o({...i,is_active:s})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{htmlFor:"goodie-doi",children:"Double-Opt-In erforderlich"}),e.jsx(b,{id:"goodie-doi",checked:i.requires_email_confirmation,onCheckedChange:s=>o({...i,requires_email_confirmation:s})})]})]}),e.jsxs(X,{children:[e.jsx(h,{variant:"admin-ghost",size:"admin-sm",onClick:N,children:"Abbrechen"}),e.jsxs(h,{variant:"admin-primary",size:"admin-sm",onClick:()=>w.mutate(),disabled:!i.title.trim()||w.isPending,children:[w.isPending&&e.jsx(P,{className:"h-4 w-4 animate-spin mr-1.5"}),d?"Erstellen":"Speichern"]})]})]})})]})}export{Te 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.