PageSourceSearch

https://tsofit.org.il/assets/KibbutzSiteObserverVotes-D3Rv7g_Z.js

js tsofit.org.il collected 2026-09-25 02:13:27 UTC 15,944 bytes, 1 lines download raw bytes

1import{aa as Z,cU as I,r as n,d as y,z as u,j as e,b as S,w as ee,L as se,aU as X,bE as te,x as q,a7 as J,aF as ae,C as P,aK as le,aG as ie}from"./index-BuF13C9R.js";import{S as ne}from"./SitePageShell-D3rwKhmW.js";import{S as re}from"./SignaturePad-XCCnnVBI.js";import{R as ce}from"./ResidentLoginRedirect-C4cTFDh_.js";import{P as R}from"./pen-line-CuBxLD5W.js";import{C as K}from"./clipboard-check-CMT0h_dd.js";import{M as B}from"./message-square-plus-sO0cIKtO.js";import"./usePaymentPlacements-CX0SzjnY.js";import"./user-cog-BrPu6RcS.js";import"./bell-ring-DHDlhRvf.js";import"./life-buoy-DD0yJ6o8.js";import"./log-in-8daxVYSJ.js";import"./kibbutzSiteUtils-DG6eIbUJ.js";import"./info-BIFqAg3-.js";import"./folder-open-BSPTKQzn.js";import"./graduation-cap-D9zn9IjR.js";import"./file-check-D2O-2b5u.js";import"./instagram-rO3n40RO.js";import"./sliders-horizontal-D0cjPgOh.js";import"./youtube-D4vYeyfI.js";import"./leaf-BxZ8PRn4.js";import"./paymentCatalogs-CvImawYM.js";import"./chevron-left-D2IUBEPa.js";import"./siren-DuSchdHr.js";import"./personalHeading-D8itHFYD.js";import"./ContentPageHero-BxCWcB43.js";import"./eraser-HIMwNg90.js";const b="#0d9488",C="#c026d3",oe=a=>{if(!a)return"";const l=String(a).slice(0,10).split("-");return`${l[2]}/${l[1]}/${l[0]}`},v=a=>{if(!a)return"";const l=String(a).slice(11,16);return`${oe(a)}${l?" "+l:""}`};function de(a,l){var o;const[c,m]=a.split(","),r=((o=/:(.*?);/.exec(c))==null?void 0:o[1])||"image/png",t=atob(m),p=new Uint8Array(t.length);for(let d=0;d<t.length;d++)p[d]=t.charCodeAt(d);return new File([p],l,{type:r})}function Ae(){const{kibbutzId:a}=Z(),l=I(a),c=l==null?void 0:l.phone,[m,r]=n.useState(!0),[t,p]=n.useState([]),[o,d]=n.useState(null),f=n.useCallback(async()=>{var i;if(!c){r(!1);return}r(!0);try{const x=await y.functions.invoke("residentVoteObserver",{community_id:a,action:"list"});p(((i=x==null?void 0:x.data)==null?void 0:i.votes)||[])}catch{u.error("שגיאה בטעינת ההצבעות")}r(!1)},[a,c]);return n.useEffect(()=>{f()},[f]),e.jsx(ne,{kibbutzId:a,moduleKey:"resident_registration",showHero:!1,hidePageTitleHeader:!0,hideFooter:!0,pageTitle:"ניהול הצבעות | משקיף",mainClassName:"flex-1 w-full pt-24 md:pt-28 pb-12",children:()=>l?m?e.jsx("div",{className:"flex justify-center py-24",children:e.jsx(S,{className:"w-8 h-8 animate-spin text-slate-400"})}):t.length?o?e.jsx(xe,{kibbutzId:a,vote:o,onBack:()=>{d(null),f()}}):e.jsx("div",{className:"max-w-5xl mx-auto w-full px-4",dir:"rtl",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:t.map(i=>{const x=i.eligible?Math.round(i.voted/i.eligible*100):0;return e.jsxs("button",{onClick:()=>d(i),className:"card-float p-4 text-right hover:shadow-md transition-all",children:[e.jsxs("div",{className:"flex items-start gap-2 mb-1.5",children:[e.jsx("h3",{className:"text-sm font-bold text-slate-900 flex-1 min-w-0",children:i.title||"הצבעה"}),i.closed?e.jsx("span",{className:"text-[11px] font-medium px-2 py-0.5 rounded-full bg-slate-100 text-slate-600 flex-shrink-0",children:"נסגרה"}):e.jsx("span",{className:"text-[11px] font-medium px-2 py-0.5 rounded-full bg-emerald-50 text-emerald-700 flex-shrink-0",children:"פעילה"})]}),i.category&&e.jsx("p",{className:"text-[11px] text-teal-600 font-medium mb-1",children:i.category}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-slate-500 mb-2",children:[e.jsx(q,{className:"w-3.5 h-3.5"})," ",i.voted,"/",i.eligible," הצביעו (",x,"%)"]}),e.jsx("div",{className:"h-1.5 rounded-full bg-slate-100 overflow-hidden mb-2",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${x}%`,backgroundColor:b}})}),i.signed?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-medium text-emerald-700",children:[e.jsx(J,{className:"w-3.5 h-3.5"})," נחתם — הצג פרוטוקול"]}):i.closed?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-medium text-fuchsia-700",children:[e.jsx(R,{className:"w-3.5 h-3.5"})," ממתין לחתימת משקיף"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-slate-400",children:[e.jsx(ae,{className:"w-3.5 h-3.5"})," חתימה תתאפשר בסגירה"]})]},i.id)})})}):e.jsxs("div",{className:"max-w-md mx-auto px-4 py-20 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-slate-100 flex items-center justify-center mx-auto mb-4",children:e.jsx(ee,{className:"w-8 h-8 text-slate-400"})}),e.jsx("p",{className:"text-slate-600 font-semibold mb-1",children:"לא הוגדרת כמשקיף על הצבעות"}),e.jsx("p",{className:"text-sm text-slate-400",children:"כאשר מנהל הקהילה יגדיר אותך כמשקיף על הצבעה, היא תופיע כאן."}),e.jsxs(se,{to:te(`/kibbutz-site/${a}/personal`),className:"inline-flex items-center gap-1 mt-6 text-sm font-medium",style:{color:b},children:[e.jsx(X,{className:"w-4 h-4"})," חזרה לאזור האישי"]})]}):e.jsx(ce,{kibbutzId:a})})}
1const w=({icon:a,title:l,extra:c,children:m,tone:r=b})=>e.jsxs("section",{className:"card-float p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4 pb-2.5 border-b border-slate-100",children:[e.jsx("span",{className:"w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0",style:{backgroundColor:`${r}14`,color:r},children:e.jsx(a,{className:"w-4 h-4"})}),e.jsx("h2",{className:"text-sm font-bold text-slate-800",children:l}),c&&e.jsx("span",{className:"text-xs text-slate-400 mr-auto",children:c})]}),m]});function xe({kibbutzId:a,vote:l,onBack:c}){var H,M;const[m,r]=n.useState(!0),[t,p]=n.useState(null),[o,d]=n.useState(""),[f,i]=n.useState(!1),[x,$]=n.useState(!1),[U,Q]=n.useState(""),[L,V]=n.useState(""),[D,E]=n.useState(!1),_=n.useCallback(async()=>{r(!0);try{const s=await y.functions.invoke("residentVoteObserver",{community_id:a,action:"detail",vote_id:l.id});p((s==null?void 0:s.data)||null)}catch{u.error("שגיאה בטעינת הפרטים")}r(!1)},[a,l.id]);n.useEffect(()=>{_()},[_]);const W=async()=>{if(o.trim()){i(!0);try{await y.functions.invoke("residentVoteObserver",{community_id:a,action:"add_note",vote_id:l.id,content:o.trim()}),d(""),u.success("ההערה נוספה"),await _()}catch{u.error("שגיאה בהוספת ההערה")}i(!1)}},Y=async()=>{if(!L){u.error("יש לחתום באזור החתימה");return}E(!0);try{const{file_url:s}=await y.integrations.Core.UploadFile({file:de(L,`observer-signature-${l.id}.png`)});await y.functions.invoke("residentVoteObserver",{community_id:a,action:"sign",vote_id:l.id,signature_url:s,assessment:U.trim()}),u.success("החתימה נשמרה"),$(!1),await _()}catch(s){u.error((s==null?void 0:s.message)||"שגיאה בשמירת החתימה")}E(!1)};if(m||!t)return e.jsxs("div",{className:"max-w-6xl mx-auto w-full px-4",dir:"rtl",children:[e.jsx(G,{onBack:c}),e.jsx("div",{className:"flex justify-center py-20",children:e.jsx(S,{className:"w-8 h-8 animate-spin text-slate-400"})})]});const N=t.vote.closed,T=!!((H=t.my_observer)!=null&&H.signed_at),j=N&&T,A=((M=t.participation)==null?void 0:M.voters)||[],F=A.filter(s=>s.has_voted),O=A.filter(s=>!s.has_voted),z=(t.observers||[]).filter(s=>s.signed_at&&s.signature_url);return e.jsxs("div",{className:"max-w-6xl mx-auto w-full px-4",dir:"rtl",children:[e.jsx(G,{onBack:c}),e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsx("span",{className:"w-11 h-11 rounded-2xl flex items-center justify-center text-white flex-shrink-0",style:{backgroundColor:j?C:b},children:j?e.jsx(J,{className:"w-6 h-6"}):e.jsx(K,{className:"w-6 h-6"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h1",{className:"text-2xl font-extrabold text-slate-900 truncate",children:t.vote.title||"הצבעה"}),e.jsx("span",{className:`text-[11px] font-medium px-2 py-0.5 rounded-full ${N?"bg-slate-100 text-slate-600":"bg-emerald-50 text-emerald-700"}`,children:N?"נסגרה":"פעילה"})]}),e.jsx("p",{className:"text-sm text-slate-500",children:j?"פרוטוקול ההצבעה — נחתם על ידך, לצפייה בלבד":"ניהול משקיף — השתתפות, הערות וחתימה"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4 items-start",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs(w,{icon:K,title:"פרטי ההצבעה",children:[e.jsxs("dl",{className:"space-y-2 text-sm",children:[t.vote.category&&e.jsx(k,{label:"קטגוריה",value:t.vote.category}),e.jsx(k,{label:"סוג",value:t.vote.voting_type==="public"?"גלויה":"חשאית"}),e.jsx(k,{label:"פתיחה",value:v(t.vote.start_at)||"—"}),e.jsx(k,{label:"סגירה",value:v(t.vote.end_at)||"—"})]}),t.vote.description&&e.jsx("p",{className:"text-sm text-slate-500 mt-3 pt-3 border-t border-slate-100",children:t.vote.description})]}),e.jsx(w,{icon:q,title:"השתתפות",extra:`${t.participation.voted}/${t.participation.eligible}`,children:e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs font-semibold text-emerald-700 mb-1.5 flex items-center gap-1",children:[e.jsx(P,{className:"w-3.5 h-3.5"})," הצביעו (",F.length,")"]}),e.jsxs("div",{className:"max-h-52 overflow-y-auto space-y-1",children:[F.map((s,h)=>e.jsx("div",{className:"text-xs text-slate-600 truncate",children:s.full_name},h)),F.length===0&&e.jsx("p",{className:"text-xs text-slate-300",children:"—"})]})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs font-semibold text-slate-500 mb-1.5 flex items-center gap-1",children:[e.jsx(le,{className:"w-3.5 h-3.5"})," טרם הצביעו (",O.length,")"]}),e.jsxs("div",{className:"max-h-52 overflow-y-auto space-y-1",children:[O.map((s,h)=>e.jsx("div",{className:"text-xs text-slate-600 truncate",children:s.full_name},h)),O.length===0&&e.jsx("p",{className:"text-xs text-slate-300",children:"—"})]})]})]})})]}),e.jsx("div",{className:"space-y-4",children:e.jsx(w,{icon:ie,title:"תוצאות",extra:t.results?`${t.results.total_ballots} פתקים`:void 0,children:t.results?e.jsx("div",{className:"space-y-4",children:t.results.questions.map(s=>{const h=Math.max(1,...s.options.map(g=>g.count));return e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-slate-800 mb-1.5",children:s.title}),e.jsx("div",{className:"space-y-1.5",children:s.options.map(g=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-slate-600 w-24 truncate flex-shrink-0",children:g.title}),e.jsx("div",{className:"flex-1 h-4 rounded bg-slate-100 overflow-hidden",children:e.jsx("div",{className:"h-full rounded",style:{width:`${g.count/h*100}%`,backgroundColor:b}})}),e.jsx("span",{className:"text-xs font-bold text-slate-700 w-7 text-left flex-shrink-0",children:g.count})]},g.option_id))})]},s.question_id)})}):e.jsx("p",{className:"text-sm text-slate-400",children:N?"התוצאות אינן מוצגות עבור הצבעה זו.":"התוצאות יוצגו לאחר סגירת ההצבעה."})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(w,{icon:B,title:"הערות משקיפים",children:[t.notes.length>0?e.jsx("div",{className:"space-y-2.5 mb-3",children:t.notes.map(s=>e.jsxs("div",{className:"rounded-xl bg-slate-50 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-slate-400 mb-0.5",children:[e.jsx("span",{className:"font-semibold text-slate-600",children:s.author_name}),e.jsxs("span",{children:["· ",v(s.created_date)]})]}),e.jsx("p",{className:"text-sm text-slate-700 whitespace-pre-wrap",children:s.content})]},s.id))}):e.jsx("p",{className:"text-xs text-slate-400 mb-3",children:"אין הערות עדיין."}),!j&&e.jsxs(e.Fragment,{children:[e.jsx("textarea",{value:o,onChange:s=>d(s.target.value),rows:2,placeholder:"הוספת הערת משקיף (תירשם בפרוטוקול)…",className:"w-full rounded-xl border border-slate-200 p-2.5 text-sm resize-none focus:outline-none focus:ring-2 focus:ring-teal-100 focus:border-teal-300"}),e.jsx("div",{className:"flex justify-end mt-2",children:e.jsxs("button",{onClick:W,disabled:!o.trim()||f,className:"inline-flex items-center gap-1.5 h-9 px-4 roun
1ded-full text-white text-xs font-semibold disabled:opacity-50",style:{backgroundColor:b},children:[f?e.jsx(S,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(B,{className:"w-3.5 h-3.5"})," הוסף הערה"]})})]})]}),e.jsx(w,{icon:R,title:j?"חתימות משקיפים":"חתימת משקיף",tone:C,children:j?z.length>0?e.jsx("div",{className:"space-y-4",children:z.map((s,h)=>e.jsxs("div",{className:"text-center",children:[e.jsx("img",{src:s.signature_url,alt:"חתימה",className:"h-16 mx-auto object-contain"}),e.jsxs("p",{className:"text-sm font-semibold text-slate-700 border-t border-slate-200 pt-1.5 mt-1",children:[s.signed_name||s.full_name," · חתימת משקיף"]}),s.signature_assessment&&e.jsx("p",{className:"text-xs text-slate-500 mt-1 whitespace-pre-wrap",children:s.signature_assessment}),e.jsx("p",{className:"text-[10px] text-slate-400 mt-0.5",children:v(s.signed_at)})]},h))}):e.jsx("p",{className:"text-sm text-slate-400",children:"אין חתימות."}):T?e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm text-emerald-700 font-medium mb-2 flex items-center gap-1.5",children:[e.jsx(P,{className:"w-4 h-4"})," חתמת ב־",v(t.my_observer.signed_at)]}),t.my_observer.signature_assessment&&e.jsxs("p",{className:"text-sm text-slate-600 mb-2",children:["הערכה: ",t.my_observer.signature_assessment]}),t.my_observer.signature_url&&e.jsx("img",{src:t.my_observer.signature_url,alt:"חתימה",className:"h-20 border border-slate-200 rounded-lg bg-white"})]}):N?x?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-500 mb-1",children:"הערכה (רשות)"}),e.jsx("textarea",{value:U,onChange:s=>Q(s.target.value),rows:2,placeholder:"הערכת המשקיף לגבי תקינות ההצבעה…",className:"w-full rounded-xl border border-slate-200 p-2.5 text-sm resize-none focus:outline-none focus:ring-2 focus:ring-fuchsia-100 focus:border-fuchsia-300"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-500 mb-1",children:"חתימה דיגיטלית"}),e.jsx(re,{onChange:V})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>{$(!1),V("")},className:"h-11 px-5 rounded-xl border border-slate-200 text-sm font-semibold text-slate-600 hover:bg-slate-100",children:"ביטול"}),e.jsxs("button",{onClick:Y,disabled:D||!L,className:"inline-flex items-center gap-2 h-11 px-6 rounded-xl text-white font-semibold disabled:opacity-60",style:{backgroundColor:C},children:[D?e.jsx(S,{className:"w-4 h-4 animate-spin"}):e.jsx(P,{className:"w-4 h-4"})," אישור חתימה"]})]})]}):e.jsxs("button",{onClick:()=>$(!0),className:"inline-flex items-center gap-2 h-11 px-5 rounded-xl text-white font-semibold",style:{backgroundColor:C},children:[e.jsx(R,{className:"w-4 h-4"})," חתום כמשקיף"]}):e.jsx("p",{className:"text-sm text-slate-400",children:"חתימת המשקיף תתאפשר לאחר סגירת ההצבעה."})})]})]})]})}const G=({onBack:a})=>e.jsxs("button",{onClick:a,className:"inline-flex items-center gap-1.5 h-9 px-3 mb-4 rounded-full border border-slate-200 bg-white text-sm font-medium text-slate-600 hover:bg-slate-50",children:[e.jsx(X,{className:"w-4 h-4"})," חזרה לרשימת ההצבעות"]}),k=({label:a,value:l})=>e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("dt",{className:"text-xs text-slate-400 flex-shrink-0",children:a}),e.jsx("dd",{className:"text-sm font-medium text-slate-800 text-left truncate",children:l})]});export{Ae 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.