1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9367],{69367:(e,l,i)=>{i.r(l),i.d(l,{VolunteerDetail:()=>w,default:()=>$});var s=i(95155),t=i(12115),a=i(82222),r=i(41841),n=i(73139),o=i(94992),d=i(57128),c=i(54138),u=i(86478),x=i(4479),p=i(65851),g=i(49173),f=i(3206),b=i(94784),h=i(1571),m=i(37586),y=i(91057),j=i(85626),S=i(18031),v=i(82034),M=i(6438);let w=({id:e,config:l})=>{let i=M.MB.colors,w=(0,a.useRouter)(),$=t.useContext(v.A),A=(0,j.jE)(),[D,B]=t.useState(null),[k,C]=t.useState(null),[z,R]=t.useState(null),H=!!($?.person?.id||m.gA.currentUserChurch?.person?.id),W=l?.church?.id,{data:I,isLoading:F}=(0,S.I)({queryKey:["volunteer-detail",W,e,H],queryFn:async()=>{let l=await m.tH.getAnonymous("/plans/public/signup/"+W,"DoingApi"),i=Array.isArray(l)?l.find(l=>l?.plan?.id===e):null;if(!i)return{plan:null,positions:[],times:[],myAssignments:[]};let s=[];if(H)try{let e=await m.tH.get("/assignments/my","DoingApi"),l=(i.positions||[]).map(e=>e.id).filter(Boolean);Array.isArray(e)&&(s=e.filter(e=>l.includes(e.positionId)))}catch{s=[]}return{plan:i.plan,positions:i.positions||[],times:i.times||[],myAssignments:s}},enabled:!!W&&!!e}),U=I?.plan??null,_=I?.positions??[],N=I?.times??[],P=I?.myAssignments??[],T=!F&&void 0!==I&&!U,E=()=>A.invalidateQueries({queryKey:["volunteer-detail",W,e,H]}),q=t.useMemo(()=>{if(!U?.signupDeadlineHours||!U?.serviceDate)return!1;let e=new Date(U.serviceDate);return e.setHours(e.getHours()-(U.signupDeadlineHours||0)),new Date>e},[U]),L=async e=>{if(e.id&&H){C(e.id),B(null);try{await m.tH.post("/assignments/signup",{positionId:e.id},"DoingApi"),B({type:"success",text:y.h.label("mobile.details.signedUpSuccess")}),await E()}catch(i){let e=(i?.message||i?.toString()||"").toLowerCase(),l=y.h.label("mobile.details.signupFailed");e.includes("full")?l=y.h.label("mobile.details.positionFull"):e.includes("deadline")?l=y.h.label("mobile.details.deadlinePassed"):e.includes("already")&&(l=y.h.label("mobile.details.alreadySignedUp")),B({type:"error",text:l})}finally{C(null)}}},V=async()=>{if(R(null),z?.id){C(z.id),B(null);try{await m.tH.delete(`/assignments/signup/${z.id}`,"DoingApi"),B({type:"success",text:y.h.label("mobile.details.signupRemoved")}),await E()}catch(e){B({type:"error",text:(e?.message||e?.toString()||"").toLowerCase().includes("deadline")?y.h.label("mobile.details.deadlineHasPassed"):y.h.label("mobile.details.couldNotRemoveSignup")})}finally{C(null)}}},K=t.useMemo(()=>{let e={};return _.forEach(l=>{let i=l.categoryName||y.h.label("mobile.details.general");e[i]||(e[i]=[]),e[i].push(l)}),e},[_]),O=U?.serviceDate?m.rV.prettyDate(m.rV.toDate(U.serviceDate)):"",Q=N.length>0?N.map(e=>e.displayName||"").filter(Boolean).join(", "):"",G=(e,l,t)=>{let a={warning:{bg:"rgba(254,170,36,0.15)",fg:i.warning},info:{bg:"rgba(86,139,218,0.15)",fg:i.primary},success:{bg:"rgba(112,220,135,0.2)",fg:i.success},error:{bg:"rgba(176,18,12,0.15)",fg:i.error}}[e];return(0,s.jsxs)(r.default,{sx:{display:"flex",alignItems:"center",gap:1,bgcolor:a.bg,color:a.fg,borderRadius:`${M.MB.radius.md}px`,p:`${M.MB.spacing.sm}px`},children:[(0,s.jsx)(o.default,{sx:{color:a.fg},children:t}),(0,s.jsx)(n.default,{sx:{fontSize:14,color:a.fg,flex:1},children:l})]})},J=e=>{let l,t=e.count||0,a=e.filledCount||0,o=Math.max(0,t-a),c=t>0?Math.min(100,a/t*100):0,u=0===o&&t>0,x=(l=e.id)?P.find(e=>e.positionId===l):void 0,p=k===e.id||!!x?.id&&k===x.id;return(0,s.jsxs)(r.default,{sx:{bgcolor:i.surface,borderRadius:`${M.MB.radius.lg}px`,p:`${M.MB.spacing.md}px`,border:x?`1px solid ${i.success}`:`1px solid ${i.border}`},children:[(0,s.jsxs)(r.default,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:1},children:[(0,s.jsxs)(r.default,{sx:{flex:1,minWidth:0},children:[(0,s.jsxs)(r.default,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:[(0,s.jsx)(n.default,{sx:{fontSize:16,fontWeight:600,color:i.text},children:e.name}),x&&(0,s.jsx)(r.default,{sx:{px:1,py:"2px",borderRadius:"999px",bgcolor:"rgba(112,220,135,0.2)",color:i.success,fontSize:10.5,fontWeight:700},children:y.h.label("mobile.details.signedUp")})]}),e.description&&(0,s.jsx)(n.default,{sx:{fontSize:13,color:i.textMuted,mt:"4px"},children:e.description})]}),x?(0,s.jsx)(d.default,{variant:"outlined",size:"small",disabled:q||p,onClick:()=>{x.id&&R(x)},sx:{color:i.error,borderColor:i.error,textTransform:"none",fontWeight:600,borderRadius:`${M.MB.radius.md}px`,flexShrink:0},children:p?y.h.label("mobile.details.removing"):y.h.label("mobile.details.remove")}):(0,s.jsx)(d.default,{variant:"contained",size:"small",disabled:u||q||!H||p,onClick:()=>L(e),sx:{bgcolor:i.primary,color:i.onPrimary,textTransform:"none",fontWeight:600,borderRadius:`${M.MB.radius.md}px`,flexShrink:0,"&:hover":{bgcolor:i.primary},"&.Mui-disabled":{bgcolor:i.disabled,color:"#FFF"}},children:p?y.h.label("mobile.details.signingUp"):u?y.h.label("mobile.details.full"):y.h.label("mobile.details.signUp")})]}),(0,s.jsxs)(r.default,{sx:{mt:1.5},children:[(0,s.jsx)(r.default,{sx:{height:6,borderRadius:3,bgcolor:i.border,overflow:"hidden"},children:(0,s.jsx)(r.default,{sx:{height:"100%",width:`${c}%`,bgcolor:u?i.error:i.primary,transition:"width 300ms ease"}})}),(0,s.jsx)(n.default,{sx:{fontSize:12,color:i.textMuted,mt:"4px"},children:o>0?y.h.label("mobile.details.slotsRemaining").replace("{}",String(o)).replace("{}",String(t)):y.h.label("mobile.details.allSlotsFilled").replace("{}",String(t))})]})]},e.id)};return(0,s.jsxs)(r.default,{sx:{p:`${M.MB.spacing.md}px`,bgcolor:i.background,minHeight:"100%"},children:[(0,s.jsx)(r.default,{sx:{display:"flex",alignItems:"center",mb:`${M.MB.spacing.sm}px`},children:(0,s.jsx)(u.default,{"aria-label":y.h.label("mobile.components.back"),onClick:()=>w.back(),sx:{color:i.text},size:"small",children:(0,s.jsx)(h.A,{})})}),F&&(0,s.jsx)(r.default,{sx:{display:"flex",flexDirection:"column",gap:`${M.MB.spacing.sm}px`},children:[0,1,2].map(e=>(0,s.jsxs)(r.default,{sx:{bgcolor:i.surface,border:`1px solid ${i.border}`,borderRadius:`${M.MB.radius.lg}px`,p:`${M.MB.spacing.md}px`},children:[(0,s.jsx)(c.A,{variant:"text",width:"60%",height:20}),(0,s.jsx)(c.A,{variant:"text",width:"40%",height:14}),(0,s.jsx)(c.A,{variant:"rounded",height:32,sx:{mt:1.5}})]},`sk-${e}`))}),!F&&T&&(0,s.jsxs)(r.default,{sx:{bgcolor:i.surface,border:`1px solid ${i.border}`,borderRadius:`${M.MB.radius.xl}px`,p:`${M.MB.spacing.lg}px`,textAlign:"center"},children:[(0,s.jsx)(o.default,{sx:{fontSize:48,color:i.textSecondary},children:"event_busy"}),(0,s.jsx)(n.default,{sx:{fontSize:16,fontWeight:600,color:i.text,mt:1},children:y.h.label("mobile.details.planNotFound")})]}),!F&&!T&&U&&(0,s.jsxs)(r.default,{sx:{display:"flex",flexDirection:"column",gap:`${M.MB.spacing.md}px`},children:[(0,s.jsxs)(r.default,{children:[(0,s.jsx)(n.default,{sx:{fontSize:24,fontWeight:700,color:i.text,mb:"4px"},children:U?.name}),(0,s.jsxs)(n.default,{sx:{fontSize:15,color:i.textMuted,mb:U?.notes?"8px":0},children:[O,Q&&` \xb7 ${Q}`]}),U?.notes&&(0,s.jsx)(n.default,{sx:{fontSize:14,color:i.textMuted,whiteSpace:"pre-wrap"},children:U.notes})]}),q&&G("warning",y.h.label("mobile.details.signupDeadlinePassed"),"schedule"),!H&&G("info",y.h.label("mobile.details.signInToSignUp"),"info"),D&&G(D.type,D.text,"success"===D.type?"check_circle":"error"),Object.entries(K).map(([e,l])=>(0,s.jsxs)(r.default,{children:[(0,s.jsx)(n.default,{sx:{fontSize:18,fontWeight:700,color:i.text,mb:1},children:e}),(0,s.jsx)(r.default,{sx:{display:"flex",flexDirection:"column",gap:`${M.MB.spacing.sm}px`},children:l.map(J)})]},e)),0===_.length&&(0,s.jsx)(n.default,{sx:{textAlign:"center",color:i.textMuted,py:3},children:y.h.label("mobile.details.noPositionsAvailable")})]}),(0,s.jsxs)(x.default,{open:!!z,onClose:()=>R(null),"aria-labelledby":"remove-signup-title",children:[(0,s.jsx)(p.default,{id:"remove-signup-title",children:y.h.label("mobile.details.removeSignup")}),(0,s.jsx)(g.default,{children:(0,s.jsx)(f.A,{children:y.h.label("mobile.details.confirmRemoveSignup")})}),(0,s.jsxs)(b.default,{children:[(0,s.jsx)(d.default,{onClick:()=>R(null),sx:{color:i.textMuted,textTransform:"none"},children:y.h.label("mobile.details.cancel")}),(0,s.jsx)(d.default,{onClick:V,sx:{color:i.error,textTransform:"none",fontWeight:600},children:y.h.label("mobile.details.remove")})]})]})]})},$=w}}]);
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.