PageSourceSearch

https://8004.ch/assets/AdminMeineKommission-Cg86KVjX.js

js 8004.ch collected 2026-10-02 20:50:18 UTC 12,663 bytes, 1 lines download raw bytes

1import{r as a,s as m,j as e,g as q}from"./index-DeJ875KO.js";import{u as Z}from"./AdminContext-DezprucX.js";import{B as I}from"./BestaetigungsKnopf-Dz2-jEtu.js";const L=Object.fromEntries(q.filter(i=>i.type==="kommission").map(i=>[i.key,i.label])),T=i=>i?new Date(`${i.slice(0,10)}T12:00:00`).toLocaleDateString("de-CH"):"",O={vorstandssitzung:"Vorstandssitzung",kommission:"Kommissionssitzung",arbeitsgruppe:"Arbeitsgruppe",extern:"Externer Termin"};function R(){const{personId:i,displayName:N}=Z(),[o,h]=a.useState(null),[g,C]=a.useState([]),[p,D]=a.useState([]),[b,E]=a.useState(!1),[f,u]=a.useState(!1),[c,z]=a.useState(null),[k,w]=a.useState([]),[_,v]=a.useState([]),d=a.useCallback(async()=>{if(!i){h([]);return}const n=new Date().toISOString().slice(0,10),[s,l,S,j,$]=await Promise.all([m.from("person_commissions").select("commission_key, role").eq("person_id",i),m.from("board_meeting_attendance").select("id, status, note, board_meetings!inner(id, title, meeting_date, meeting_time, location, status, art)").eq("person_id",i).gte("board_meetings.meeting_date",n).eq("board_meetings.status","geplant"),m.from("pendenzen").select("id, title, description, status, due_on, owner_person_id, owner_name, done_on, done_by_name, commission_key").order("due_on",{ascending:!0,nullsFirst:!1}),m.from("helper_assignments").select("status, helper_shifts!inner(id, title, starts_at, ends_at, helper_events!inner(id, title, starts_on))").eq("person_id",i).eq("status","zugesagt"),m.from("board_meeting_attendance").select("id, token, board_meetings!inner(id, title, status)").eq("person_id",i).eq("board_meetings.status","terminsuche")]);h(s.data??[]),C((l.data??[]).map(t=>({...t.board_meetings,attendance:{id:t.id,status:t.status,note:t.note}})).sort((t,x)=>t.meeting_date.localeCompare(x.meeting_date))),D(S.data??[]),w((j.data??[]).map(t=>({id:t.helper_shifts.id,titel:t.helper_shifts.title,anlass:t.helper_shifts.helper_events.title,datum:t.helper_shifts.helper_events.starts_on,von:t.helper_shifts.starts_at,bis:t.helper_shifts.ends_at})).filter(t=>!t.datum||t.datum>=n).sort((t,x)=>(t.datum??"").localeCompare(x.datum??""))),v(($.data??[]).map(t=>({titel:t.board_meetings.title,token:t.token})))},[i]);a.useEffect(()=>{d()},[d]);const[y,r]=a.useState(null);async function A(n,s){if(!n.attendance)return;u(!0),r(null);const{error:l}=await m.from("board_meeting_attendance").update({status:s,responded_at:new Date().toISOString(),responded_via:"admin"}).eq("id",n.attendance.id);l&&r(`Antwort konnte nicht gespeichert werden: ${l.message}`),u(!1),d()}async function B(n){u(!0),r(null);const{error:s}=await m.from("pendenzen").update({status:"erledigt",done_on:new Date().toISOString().slice(0,10),done_by_name:N||null,updated_at:new Date().toISOString()}).eq("id",n.id);s&&r(`Pendenz konnte nicht erledigt werden: ${s.message}`),u(!1),d()}if(o===null)return e.jsx("p",{className:"text-sm text-zinc-400",children:"Lade…"});if(!i||o.length===0)return e.jsxs("div",{className:"max-w-3xl",children:[e.jsx("h1",{className:"text-xl font-bold text-zinc-900 dark:text-white mb-2",children:"Mein Bereich"}),e.jsx("p",{className:"text-sm text-zinc-500",children:"Dein Konto ist mit keiner Kommission verknüpft. Die Zuteilung pflegt der Vorstand in der Mitgliederverwaltung."})]});const K=new Set(o.filter(n=>n.role==="vorsitz").map(n=>n.commission_key)),M=new Date().toISOString().slice(0,10);return e.jsxs("div",{className:"max-w-4xl",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-zinc-900 dark:text-white",children:"Mein Bereich"}),e.jsx("p",{className:"text-sm text-zinc-500 dark:text-zinc-400 mt-0.5",children:o.map(n=>`${L[n.commission_key]??n.commission_key}${n.role==="vorsitz"?" (Vorsitz)":""}`).join(" · ")})]}),y&&e.jsx("p",{className:"mb-4 text-sm text-red-600",children:y}),_.length>0&&e.jsxs("div",{className:"mb-6 rounded-xl border border-amber-300 dark:border-amber-900 bg-amber-50 dark:bg-amber-950/20 px-4 py-3",children:[e.jsx("p",{className:"text-[12px] font-semibold uppercase tracking-wide text-amber-800 dark:text-amber-300 mb-1",children:"Termin wählen"}),_.map((n,s)=>e.jsxs("p",{className:"text-[13.5px] text-amber-900 dark:text-amber-200",children:[n.titel,n.token&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("a",{href:`/api/vorstand/termin?token=${n.token}`,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 font-medium",children:"jetzt antworten"})]})]},s))]}),e.jsxs("div",{className:"mb-8",children:[e.jsx("h2",{className:"text-sm font-semibold text-zinc-900 dark:text-white mb-2",children:"Kommende Termine"}),g.length===0?e.jsx("p",{className:"text-[13px] text-zinc-400",children:"Keine Einladungen offen. Termine setzt der Vorstand oder der Vorsitz an; du wirst per Mail eingeladen."}):e.jsx("div",{className:"rounded-xl border border-zinc-200 dark:border-zinc-800 divide-y divide-zinc-100 dark:divide-zinc-800 bg-white dark:bg-zinc-900",children:g.map(n=>e.jsxs("div",{className:"px-4 py-3 flex flex-wrap items-center gap-x-3 gap-y-1 text-[13.5px]",children:[e.jsx("span",{className:"tabular-nums text-zinc-500 w-[86px] shrink-0",children:T(n.meeting_date)}),e.jsx("span",{className:"font-medium text-zinc-900 dark:text-zinc-100",children:n.title}),e.jsxs("span",{className:"text-zinc-400 text-[12px]",children:[O[n.art]??n.art,n.meeting_time?` · ${n.meeting_time.slice(0,5)} Uhr`:"",n.location?` · ${n.location}`:""]}),e.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[["zugesagt","abgesagt"].map(s=>{const l=n.attendance?.status===s;return e.jsxs("button",{disabled:f,onClick:()=>A(n,s),title:l?`Du hast ${s==="zugesagt"?"zugesagt":"abgesagt"}. Nochmals klicken ändert nichts.`:`Jetzt ${s==="zugesagt"?"zusagen":"absagen"}`,className:`px-2.5 py-1 rounded-lg text-[12.5px] font-semibold border transition-colors inline-flex items-center gap-1 ${l?s==="zugesagt"?"bg-green-600 border-green-700 text-white":"bg-zinc-700 border-zinc-800 text-white":"border-zinc-300 dark:border-zinc-600 text-zinc-600 dark:text-zinc-300 hover:border-zinc-500"}`,children:[l&&e.jsx("svg",{className:"w-3 h-3 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:3,viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),l?s==="zugesagt"?"Zugesagt":"Abgesagt":s==="zugesagt"?"Zusagen":"Absagen"]},s)}),(!n.attendance||n.attendance.status==="offen")&&e.jsx("span",{className:"text-[12px] text-amber-700 dark:text-amber-400",children:"Antwort offen"})]})]},n.id))})]}),k.length>0&&e.jsxs("div",{className:"mb-8",children:[e.jsx("h2",{className:"text-sm font-semibold text-zinc-900 dark:text-white mb-2",children:"Meine Helfereinsätze"}),e.jsx("div",{className:"flex flex-col gap-1.5",children:k.map(n=>e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2.5 rounded-lg border border-zinc-200 dark:border-zinc-700 px-3 py-2 text-[13.5px]",children:[e.jsx("span",{className:"font-medium text-zinc-900 dark:text-white",children:n.anlass}),e.jsx("span",{className:"text-zinc-600 dark:text-zinc-400",children:n.titel}),e.jsxs("span",{className:"ml-auto tabular-nums text-zinc-500",children:[n.datum?new Date(`${n.datum}T12:00:00`).toLocaleDateString("de-CH"):"ohne Datum",n.von?` · ${new Date(n.von).toLocaleTimeString("de-CH",{hour:"2-digit",minute:"2-digit",timeZone:"Europe/Zurich"})}`:"",n.bis?` bis ${new Date(n.bis).toLocaleTimeString("de-CH",{hour:"2-digit",minute:"2-digit",timeZone:"Europe/Zurich"})}`:""]})]},n.id))})]}),o.map(n=>{const s=n.commission_key,l=p.filter(t=>t.commission_key===s),S=l.filter(t=>t.status==="offen"),j=l.filter(t=>t.status!=="offen"),$=K.has(s);return e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3 mb-2",children:[e.jsxs("h2",{className:"text-sm font-semibold text-zinc-900 dark:text-white",children:["Pendenzen · ",L[s]??s]}),e.jsx("button",{onClick:()=>z({key:s}),className:"text-[12.5px] font-semibold text-red-600 hover:underline",children:"Neue Pendenz"})]}),S.length===0?e.jsx("p",{className:"text-[13px] text-zinc-400",children:"Keine offenen Pendenzen."}):e.jsx("div",{className:"rounded-xl border border-zinc-200 dark:border-zinc-800 divide-y divide-zinc-100 dark:divide-zinc-800 bg-white dark:bg-zinc-900",children:S.map(t=>{const x=t.owner_person_id===i,P=t.due_on&&t.due_on<M;return e.jsxs("div",{className:"px-4 py-2.5 flex flex-wrap items-baseline gap-x-3 gap-y-0.5 text-[13.5px]",children:[e.jsx("span",{className:"font-medium text-zinc-900 dark:text-zinc-100",children:t.title}),t.owner_name&&e.jsx("span",{className:`text-[12px] ${x?"text-red-600 font-semibold":"text-zinc-400"}`,children:x?"du":t.owner_name}),t.due_on&&e.jsxs("span",{className:`text-[12px] tabular-nums ${P?"text-red-600 font-semibold":"text-zinc-400"}`,children:["bis ",T(t.due_on)]}),t.description&&e.jsx("span",{className:"w-full text-[12.5px] text-zinc-500",children:t.description}),(x||$||!t.owner_person_id)&&e.jsx("span",{className:"ml-auto",children:e.jsxs(I,{disabled:f,frage:"Wirklic
1h erledigt?",jaLabel:"Erledigt",onBestaetigt:()=>B(t),className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg border border-zinc-300 dark:border-zinc-600 text-[12px] font-semibold text-zinc-600 dark:text-zinc-300 hover:border-green-500 hover:text-green-700 dark:hover:text-green-400 disabled:opacity-40",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M5 13l4 4L19 7"})}),"Erledigt melden"]})})]},t.id)})}),j.length>0&&e.jsx("button",{onClick:()=>E(t=>!t),className:"mt-1.5 text-[12px] text-zinc-400 hover:text-zinc-600 underline underline-offset-2",children:b?"Erledigte ausblenden":`${j.length} erledigte anzeigen`}),b&&j.map(t=>e.jsxs("p",{className:"mt-1 text-[12.5px] text-zinc-400 line-through",children:[t.title," · ",t.done_by_name??""," ",T(t.done_on)]},t.id))]},s)}),e.jsxs("p",{className:"text-[12px] text-zinc-400",children:["Du siehst hier die Termine, zu denen du eingeladen bist, und die Pendenzen deiner Kommission",o.length>1?"en":"",". Jede Änderung wird protokolliert."]}),c&&e.jsx(F,{kommission:c.key,label:L[c.key]??c.key,personId:i,personName:N,onClose:()=>z(null),onDone:()=>{z(null),d()}})]})}function F({kommission:i,label:N,personId:o,personName:h,onClose:g,onDone:C}){const[p,D]=a.useState(""),[b,E]=a.useState(""),[f,u]=a.useState(""),[c,z]=a.useState(!0),[k,w]=a.useState(!1),[_,v]=a.useState(null),d="w-full rounded-lg border border-zinc-300 dark:border-zinc-600 bg-white dark:bg-zinc-800 px-3 py-1.5 text-sm";async function y(){w(!0),v(null);const{error:r}=await m.from("pendenzen").insert({title:p.trim(),description:b.trim()||null,commission_key:i,status:"offen",due_on:f||null,owner_person_id:c?o:null,owner_name:c?h:null,created_by_name:h||null});if(w(!1),r){v("Konnte nicht speichern.");return}C()}return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",onClick:g,children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl bg-white dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-700 shadow-2xl p-5",onClick:r=>r.stopPropagation(),children:[e.jsx("h3",{className:"text-base font-bold text-zinc-900 dark:text-white mb-0.5",children:"Neue Pendenz"}),e.jsx("p",{className:"text-[13px] text-zinc-500 mb-3",children:N}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("input",{value:p,onChange:r=>D(r.target.value),placeholder:"Was ist zu tun?",className:d,autoFocus:!0}),e.jsx("textarea",{value:b,onChange:r=>E(r.target.value),rows:2,placeholder:"Details (optional)",className:`${d} resize-none`}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("label",{className:"text-[13px] text-zinc-500",children:["Frist",e.jsx("input",{type:"date",value:f,onChange:r=>u(r.target.value),className:`${d} mt-1`})]}),e.jsxs("label",{className:"flex items-center gap-2 text-[13px] text-zinc-700 dark:text-zinc-300 mt-5",children:[e.jsx("input",{type:"checkbox",checked:c,onChange:r=>z(r.target.checked)})," mir zuweisen"]})]}),_&&e.jsx("p",{className:"text-sm text-red-600",children:_})]}),e.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[e.jsx("button",{disabled:k||p.trim().length<3,onClick:y,className:"px-4 py-2 rounded-lg bg-red-600 text-white text-sm font-semibold hover:bg-red-700 disabled:opacity-50",children:"Erfassen"}),e.jsx("button",{disabled:k,onClick:g,className:"ml-auto px-3 py-2 text-sm text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-200",children:"Abbrechen"})]})]})})}export{R as AdminMeineKommission};

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.