1import{o as w,S as o,c as E,t as j,b as A,v,j as e,U as g,w as N,x as _,f as b,y as I,M as f,z as D,A as L}from"./vendor-DO1ZebLX.js";import{H as M}from"./Helmet-BpjCTf24.js";import{u as z,A as U,B as C,S as p}from"./index-CWaALn1m.js";import{T as $,a as V,b as y,c as P}from"./Tabs-AdVvoRZ6.js";import{u as k,F as S,a as d,b as m,c as u,I as h,d as x}from"./Input-Mb1PvF__.js";import"./index-BbP3371Q.js";import"./index-x8CNYFH0.js";w({});const R=async a=>{const s=await fetch("/_api/feedback/list",{method:"GET",...a,headers:{"Content-Type":"application/json"}});if(!s.ok)try{const n=o.parse(await s.text());throw new Error(n.error)}catch{throw new Error(`Request failed with status ${s.status}`)}return o.parse(await s.text())},q=["feedback","list"],H=()=>{const{authState:a}=z(),s=a.type==="authenticated"&&a.user.role==="admin";return E({queryKey:q,queryFn:async()=>{const n=await R();if("error"in n)throw new Error(n.error);return n.feedbacks},enabled:s})},F=w({email:j().email("Invalid email address"),displayName:j().min(1,"Name is required")}),B=async(a,s)=>{const n=F.parse(a),l=await fetch("/_api/auth/update-profile",{method:"POST",body:o.stringify(n),...s,headers:{"Content-Type":"application/json",...s?.headers??{}},credentials:"include"});if(!l.ok){const t=o.parse(await l.text());throw new Error(t.error||"Profile update failed")}return o.parse(await l.text())},T=w({currentPassword:j().min(1,"Current password is required"),newPassword:j().min(8,"New password must be at least 8 characters")}),G=async(a,s)=>{const n=T.parse(a),l=await fetch("/_api/auth/update-password",{method:"POST",body:o.stringify(n),...s,headers:{"Content-Type":"application/json",...s?.headers??{}},credentials:"include"});if(!l.ok){const t=o.parse(await l.text());throw new Error(t.error||"Password update failed")}return o.parse(await l.text())},K=()=>{const a=A();return v({mutationFn:B,onSuccess:s=>{a.setQueryData(U,s.user)}})},Q=()=>v({mutationFn:G}),O="_container_jzlma_1",W="_header_jzlma_9",Y="_avatar_jzlma_17",J="_title_jzlma_28",X="_subtitle_jzlma_36",Z="_cardsGrid_jzlma_42",ee="_card_jzlma_42",se="_cardTitle_jzlma_62",ae="_form_jzlma_70",te="_cardFooter_jzlma_75",i={container:O,header:W,avatar:Y,title:J,subtitle:X,cardsGrid:Z,card:ee,cardTitle:se,form:ae,cardFooter:te},re=T.extend({confirmPassword:j()}).refine(a=>a.newPassword===a.confirmPassword,{message:"Die Passwörter stimmen nicht überein",path:["confirmPassword"]});function ne(){const{authState:a}=z(),s=K(),n=Q();if(a.type!=="authenticated")return null;const l=a.user;return e.jsxs("div",{className:i.container,children:[e.jsxs("div",{className:i.header,children:[e.jsx("div",{className:i.avatar,children:e.jsx(g,{size:32})}),e.jsxs("div",{children:[e.jsx("h2",{className:i.title,children:l.displayName}),e.jsx("p",{className:i.subtitle,children:l.role==="admin"?"Administrator":"Benutzer"})]})]}),e.jsxs("div",{className:i.cardsGrid,children:[e.jsx(le,{user:l,updateMutation:s}),e.jsx(ie,{updateMutation:n})]})]})}function le({user:a,updateMutation:s}){const n=k({schema:F,defaultValues:{email:a.email,displayName:a.displayName}}),l=t=>{s.mutate(t,{onSuccess:()=>{_.success("Profil erfolgreich aktualisiert")},onError:c=>{_.error(`Fehler beim Aktualisieren: ${c.message}`)}})};return e.jsxs("div",{className:i.card,children:[e.jsx("h3",{className:i.cardTitle,children:"Profildaten ändern"}),e.jsx(S,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(l),className:i.form,children:[e.jsxs(d,{name:"displayName",children:[e.jsx(m,{children:"Anzeigename"}),e.jsx(u,{children:e.jsx(h,{value:n.values.displayName,onChange:t=>n.setValues(c=>({...c,displayName:t.target.value})),placeholder:"Anzeigename eingeben"})}),e.jsx(x,{})]}),e.jsxs(d,{name:"email",children:[e.jsx(m,{children:"E-Mail"}),e.jsx(u,{children:e.jsx(h,{type:"email",value:n.values.email,onChange:t=>n.setValues(c=>({...c,email:t.target.value})),placeholder:"E-Mail eingeben"})}),e.jsx(x,{})]}),e.jsx("div",{className:i.cardFooter,children:e.jsxs(C,{type:"submit",disabled:s.isPending,children:[e.jsx(N,{size:16})," Profil aktualisieren"]})})]})})]})}function ie({updateMutation:a}){const s=k({schema:re,defaultValues:{currentPassword:"",newPassword:"",confirmPassword:""}}),n=l=>{a.mutate({currentPassword:l.currentPassword,newPassword:l.newPassword},{onSuccess:()=>{_.success("Passwort erfolgreich geändert"),s.setValues({currentPassword:"",newPassword:"",confirmPassword:""})},onError:t=>{_.error(`Fehler beim Ãndern des Passworts: ${t.message}`)}})};return e.jsxs("div",{className:i.card,children:[e.jsx("h3",{className:i.cardTitle,children:"Passwort ändern"}),e.jsx(S,{...s,children:e.jsxs("form",{onSubmit:s.handleSubmit(n),className:i.form,children:[e.jsxs(d,{name:"currentPassword",children:[e.jsx(m,{children:"Aktuelles Passwort"}),e.jsx(u,{children:e.jsx(h,{type:"password",value:s.values.currentPassword,onChange:l=>s.setValues(t=>({...t,currentPassword:l.target.value})),placeholder:"Aktuelles Passwort eingeben"})}),e.jsx(x,{})]}),e.jsxs(d,{name:"newPassword",children:[e.jsx(m,{children:"Neues Passwort"}),e.jsx(u,{children:e.jsx(h,{type:"password",value:s.values.newPassword,onChange:l=>s.setValues(t=>({...t,newPassword:l.target.value})),placeholder:"Neues Passwort eingeben"})}),e.jsx(x,{})]}),e.jsxs(d,{name:"confirmPassword",children:[e.jsx(m,{children:"Neues Passwort bestätigen"}),e.jsx(u,{children:e.jsx(h,{type:"password",value:s.values.confirmPassword,onChange:l=>s.setValues(t=>({...t,confirmPassword:l.target.value})),placeholder:"Neues Passwort bestätigen"})}),e.jsx(x,{})]}),e.jsx("div",{className:i.cardFooter,children:e.jsxs(C,{type:"submit",disabled:a.isPending,children:[e.jsx(N,{size:16})," Passwort ändern"]})})]})})]})}const oe="_container_7u41z_1",ce="_header_7u41z_8",de="_headerIcon_7u41z_15",me="_title_7u41z_26",ue="_subtitle_7u41z_34",he="_contentWrapper_7u41z_40",xe="_c
1ontent_7u41z_40",je="_tableContainer_7u41z_50",_e="_tableHeader_7u41z_54",pe="_table_7u41z_50",we="_thContent_7u41z_78",be="_dateCell_7u41z_100",fe="_textCell_7u41z_107",ye="_emailCell_7u41z_112",Pe="_emailLink_7u41z_116",ve="_anonymous_7u41z_125",ge="_loadingState_7u41z_130",Ne="_skeletonRow_7u41z_137",ze="_skeletonCell_7u41z_144",Ce="_errorState_7u41z_148",ke="_errorIcon_7u41z_157",Se="_emptyState_7u41z_161",Fe="_emptyIcon_7u41z_171",r={container:oe,header:ce,headerIcon:de,title:me,subtitle:ue,contentWrapper:he,content:xe,tableContainer:je,tableHeader:_e,table:pe,thContent:we,dateCell:be,textCell:fe,emailCell:ye,emailLink:Pe,anonymous:ve,loadingState:ge,skeletonRow:Ne,skeletonCell:ze,errorState:Ce,errorIcon:ke,emptyState:Se,emptyIcon:Fe};function Ue(){const{data:a,isLoading:s,error:n}=H(),l=t=>new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(t));return e.jsxs("div",{className:r.container,children:[e.jsx(M,{children:e.jsx("title",{children:"Admin Dashboard | SiBU-Liste 2.0"})}),e.jsxs("div",{className:r.header,children:[e.jsx("div",{className:r.headerIcon,children:e.jsx(b,{size:28})}),e.jsxs("div",{children:[e.jsx("h1",{className:r.title,children:"Admin Dashboard"}),e.jsx("p",{className:r.subtitle,children:"Systemverwaltung und Profil"})]})]}),e.jsxs($,{defaultValue:"feedbacks",children:[e.jsxs(V,{children:[e.jsxs(y,{value:"feedbacks",style:{gap:"var(--spacing-2)"},children:[e.jsx(b,{size:16})," Feedbacks"]}),e.jsxs(y,{value:"profile",style:{gap:"var(--spacing-2)"},children:[e.jsx(g,{size:16})," Mein Profil"]})]}),e.jsx(P,{value:"feedbacks",children:e.jsx("div",{className:r.contentWrapper,children:e.jsxs("div",{className:r.content,children:[s&&e.jsx("div",{className:r.loadingState,children:[...Array(5)].map((t,c)=>e.jsxs("div",{className:r.skeletonRow,children:[e.jsx(p,{className:r.skeletonCell,style:{width:"15%"}}),e.jsx(p,{className:r.skeletonCell,style:{width:"60%"}}),e.jsx(p,{className:r.skeletonCell,style:{width:"20%"}})]},c))}),n&&e.jsxs("div",{className:r.errorState,children:[e.jsx(I,{size:24,className:r.errorIcon}),e.jsxs("p",{children:["Fehler beim Laden der Feedbacks: ",n.message]})]}),!s&&!n&&a&&e.jsxs("div",{className:r.tableContainer,children:[e.jsx("div",{className:r.tableHeader,children:e.jsxs("span",{children:[a.length," Feedback-Einträge insgesamt"]})}),a.length===0?e.jsxs("div",{className:r.emptyState,children:[e.jsx(f,{size:48,className:r.emptyIcon}),e.jsx("h3",{children:"Keine Feedbacks vorhanden"}),e.jsx("p",{children:"Bisher wurden noch keine Feedbacks über das System eingereicht."})]}):e.jsxs("table",{className:r.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:e.jsxs("div",{className:r.thContent,children:[e.jsx(D,{size:14})," Datum"]})}),e.jsx("th",{children:e.jsxs("div",{className:r.thContent,children:[e.jsx(f,{size:14})," Feedback-Text"]})}),e.jsx("th",{children:e.jsxs("div",{className:r.thContent,children:[e.jsx(L,{size:14})," E-Mail"]})})]})}),e.jsx("tbody",{children:a.map(t=>e.jsxs("tr",{children:[e.jsx("td",{className:r.dateCell,children:l(t.createdAt)}),e.jsx("td",{className:r.textCell,children:t.feedbackText}),e.jsx("td",{className:r.emailCell,children:t.email?e.jsx("a",{href:`mailto:${t.email}`,className:r.emailLink,children:t.email}):e.jsx("span",{className:r.anonymous,children:"Anonym"})})]},t.id))})]})]})]})})}),e.jsx(P,{value:"profile",children:e.jsx(ne,{})})]})]})}export{Ue 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.