1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8267],{8267:function(e,s,t){t.r(s),t.d(s,{default:function(){return G}});var a=t(57437),l=t(94856),i=t(6949),n=t(39124),r=t(75272),d=t(64635),o=t(61212),c=t(11687),m=t(93448),x=t(80633),h=t(35748),u=t(94662),p=t(99559),g=t(80906),j=t(24399);let{useGetAllVotesQuery:N,useGetVoteByIdQuery:v,useCreateVoteMutation:f,useUpdateVoteMutation:b,useDeleteVoteMutation:y,useCheckCastedVoteByUserIdQuery:w}=p.e_.injectEndpoints({endpoints:e=>({getAllVotes:e.query({query:e=>{let{centerId:s,boardId:t,electionId:a,positionId:l,params:i}=e;return{url:"votes/center/".concat(s,"/board/").concat(t,"/election/").concat(a,"/position/").concat(l),params:i}},providesTags:e=>(null==e?void 0:e.content)?[...e.content.map(e=>({type:g.tps,id:e.id})),{type:g.tps,id:"LIST"}]:[{type:g.tps,id:"LIST"}]}),getVoteById:e.query({query:e=>{let{centerId:s,boardId:t,electionId:a,positionId:l,voteId:i}=e;return{url:"votes/center/".concat(s,"/board/").concat(t,"/election/").concat(a,"/position/").concat(l,"/").concat(i)}},providesTags:(e,s,t)=>{let{voteId:a}=t;return[{type:g.tps,id:a}]}}),createVote:e.mutation({query:e=>{let{centerId:s,boardId:t,payload:a,positionId:l,electionId:i}=e;return{url:"votes/center/".concat(s,"/board/").concat(t,"/election/").concat(i,"/position/").concat(l),method:j.WU.POST,body:a}},invalidatesTags:()=>[{type:g.tps,id:"LIST"}]}),updateVote:e.mutation({query:e=>{let{centerId:s,boardId:t,electionId:a,payload:l,positionId:i,voteId:n}=e;return{url:"votes/center/".concat(s,"/board/").concat(t,"/election/").concat(a,"/position/").concat(i,"/").concat(n),method:j.WU.PUT,body:l}},invalidatesTags:(e,s,t)=>{let{voteId:a}=t;return[{type:g.tps,id:a},{type:g.tps,id:"LIST"}]}}),deleteVote:e.mutation({query:e=>{let{centerId:s,boardId:t,electionId:a,positionId:l,voteId:i}=e;return{url:"votes/center/".concat(s,"/board/").concat(t,"/election/").concat(a,"/position/").concat(l,"/").concat(i)}},invalidatesTags:()=>[{type:g.tps,id:"LIST"}]}),checkCastedVoteByUserId:e.query({query:e=>{let{params:s}=e;return{url:"votes/center/{centerId}/board/{boardId}/election/{electionId}/position/{positionId}/check",params:s}}})})});var I=t(29387),S=t(82119),C=t(41671),Z=t(2265),E=t(64692),k=t(8717),L=t(61781),P=t(49175),D=t(23029),V=t(18587),T=t(64045),F=t(78656),Q=t(31047),U=t(91723),B=t(95805),O=e=>{var s;let{onClose:t}=e,{data:i,error:n,isLoading:r,isFetching:d}=(0,I.VS)({centerId:Number(x.Z.getSchoolId()),boardId:Number(x.Z.getBoardId())});return(0,a.jsx)("div",{className:"h-[85vh] overflow-auto p-4",children:r||d?(0,a.jsxs)("div",{className:"flex h-80 w-full items-center justify-center",children:[(0,a.jsx)(P.olI,{className:"animate-spin text-4xl text-gray-500"}),(0,a.jsx)("p",{className:"text-gray-600",children:"Loading Elections..."})]}):n?(0,a.jsx)("div",{className:"flex h-80 w-full items-center justify-center",children:(0,a.jsxs)(l.bZ,{variant:"destructive",children:[(0,a.jsx)(S.Z,{className:"h-4 w-4"}),(0,a.jsx)(l.Cd,{children:"Error"}),(0,a.jsx)(l.X,{children:"Failed to load election data. Please try again later."})]})}):(null==i?void 0:i.content)&&(null==i?void 0:null===(s=i.content)||void 0===s?void 0:s.length)!==0?(0,a.jsx)(D.UQ,{type:"single",collapsible:!0,className:"w-full space-y-6",children:i.content.map(e=>(0,a.jsx)(T.Zb,{children:(0,a.jsxs)(D.Qd,{value:e.id.toString(),children:[(0,a.jsxs)(T.Ol,{className:"pb-4",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,a.jsx)(D.o4,{className:"flex-1 hover:no-underline",children:(0,a.jsx)(T.ll,{className:"text-left",children:e.title})}),(0,a.jsx)(V.C,{variant:e.active?"default":"secondary",className:"flex-shrink-0",children:e.active?"Active":"Inactive"})]}),(0,a.jsx)(T.SZ,{className:"mt-3",children:e.description})]}),(0,a.jsxs)(D.vF,{children:[(0,a.jsxs)(T.aY,{className:"space-y-8",children:[(0,a.jsxs)("div",{className:"grid gap-8 md:grid-cols-2",children:[(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(Q.Z,{className:"h-4 w-4 text-gray-500"}),(0,a.jsx)("h4",{className:"text-sm font-semibold text-gray-900",children:"Nomination Period"})]}),(0,a.jsxs)("div",{className:"space-y-1 pl-6",children:[(0,a.jsxs)("p",{className:"text-sm text-gray-600",children:[(0,a.jsx)("span",{className:"font-medium",children:"From:"})," ",(0,m.p6)(e.nominationStart)]}),(0,a.jsxs)("p",{className:"text-sm text-gray-600",children:[(0,a.jsx)("span",{className:"font-medium",children:"To:"})," ",(0,m.p6)(e.nominationEnd)]})]})]}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(U.Z,{className:"h-4 w-4 text-gray-500"}),(0,a.jsx)("h4",{className:"text-sm font-semibold text-gray-900",children:"Voting Perio
1d"})]}),(0,a.jsxs)("div",{className:"space-y-1 pl-6",children:[(0,a.jsxs)("p",{className:"text-sm text-gray-600",children:[(0,a.jsx)("span",{className:"font-medium",children:"From:"})," ",(0,m.p6)(e.votingStart)]}),(0,a.jsxs)("p",{className:"text-sm text-gray-600",children:[(0,a.jsx)("span",{className:"font-medium",children:"To:"})," ",(0,m.p6)(e.votingEnd)]})]})]})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(B.Z,{className:"h-4 w-4 text-gray-500"}),(0,a.jsx)("h4",{className:"text-sm font-semibold text-gray-900",children:"Available Positions"})]}),e.positionResponseList&&e.positionResponseList.length>0?(0,a.jsx)("div",{className:"pl-6",children:(0,a.jsxs)(F.iA,{children:[(0,a.jsx)(F.xD,{children:(0,a.jsx)(F.SC,{children:(0,a.jsx)(F.ss,{children:"Position Name"})})}),(0,a.jsx)(F.RM,{children:e.positionResponseList.map(e=>(0,a.jsx)(F.SC,{children:(0,a.jsx)(F.pj,{className:"font-medium",children:e.name})},e.id))})]})}):(0,a.jsx)("div",{className:"pl-6",children:(0,a.jsx)("div",{className:"rounded-lg bg-gray-50 p-4 text-center",children:(0,a.jsx)("p",{className:"text-sm italic text-gray-500",children:"No positions available for this election."})})})]})]}),(0,a.jsxs)(T.eW,{className:"flex items-center justify-between text-xs text-gray-500",children:[(0,a.jsxs)("span",{children:["Created: ",(0,m.p6)(e.createdAt)]}),(0,a.jsxs)("span",{children:["Updated: ",(0,m.p6)(e.updatedAt)]})]})]})]})},e.id))}):(0,a.jsxs)("div",{className:"flex h-80 flex-col items-center justify-center p-4",children:[(0,a.jsx)("img",{src:"/noData.jpg",className:"mb-3 h-44 object-contain",alt:"No candidates"}),(0,a.jsx)("p",{className:"text-center text-sm font-medium text-gray-600",children:"No near by elections found"})]})})},A=t(33145),Y=t(92369),q=t(30401),z=t(32489),R=t(35022),_=t(10333),M=e=>{let{candidate:s,onClose:t}=e,[l,{isLoading:i}]=f(),{toast:n}
1=(0,R.pm)(),[r,d]=Z.useState(!1),o=async()=>{d(!0)},c=async()=>{try{let e={candidateId:s.userId,userId:Number(x.Z.getUserId())};await l({centerId:Number(x.Z.getSchoolId()),boardId:Number(x.Z.getBoardId()),electionId:s.electionId,positionId:s.positionId,payload:e}).unwrap(),n({title:"Vote Cast Successfully",description:"Your vote for ".concat(s.fullName," has been recorded."),className:"bg-green-500 text-white"}),d(!1),t()}catch(e){console.error("Error casting vote:",e),n({title:"Failed to Cast Vote",description:"Oops! You've already voted for this position. Only one vote is allowed.",variant:"destructive"})}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"flex min-h-[80vh] items-center justify-center overflow-auto sm:p-4",children:(0,a.jsxs)("div",{className:"mx-auto w-full max-w-3xl",children:[(0,a.jsxs)("div",{className:"overflow-auto rounded-xl border sm:rounded-2xl",children:[(0,a.jsx)("div",{className:"bg-gradient-to-r from-blue-200 to-purple-300 p-4 sm:p-5",children:(0,a.jsxs)("div",{className:"flex flex-col items-center gap-4 sm:gap-5 lg:flex-row",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)("div",{className:"border-3 relative h-20 w-20 overflow-hidden rounded-full border-white shadow-lg sm:h-24 sm:w-24 sm:border-4 md:h-28 md:w-28 lg:h-32 lg:w-32",children:s.imageUrl?(0,a.jsx)(A.default,{src:(0,m.fr)(s.imageUrl),alt:s.fullName,layout:"fill",objectFit:"cover",className:"rounded-full"}):(0,a.jsx)("div",{className:"flex h-full w-full items-center justify-center bg-gradient-to-br from-gray-100 to-gray-200",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("div",{className:"mx-auto mb-1 flex h-8 w-8 items-center justify-center rounded-full bg-gray-300 sm:h-10 sm:w-10 md:h-12 md:w-12",children:(0,a.jsx)(Y.Z,{className:"h-4 w-4 text-gray-500 sm:h-5 sm:w-5 md:h-6 md:w-6"})}),(0,a.jsx)("span",{className:"text-xs text-gray-500",children:"No Image"})]})})})}),(0,a.jsxs)("div",{className:"flex-1 text-center text-white lg:text-left",children:[(0,a.jsx)("h2",{className:"mb-2 text-xl font-bold sm:text-2xl md:mb-3 md:text-3xl",children:s.fullName}),(0,a.jsx)("div",{className:"space-y-2 rounded-lg bg-white/20 p-3 backdrop-blur-sm sm:p-4",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-center sm:gap-3 lg:justify-start",children:[(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2 lg:justify-start",children:[(0,a.jsx)("div",{className:"h-1.5 w-1.5 rounded-full bg-white"}),(0,a.jsxs)("span",{className:"text-sm font-medium sm:text-base",children:["Class: ",s.className]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2 lg:justify-start",children:[(0,a.jsx)("div",{className:"h-1.5 w-1.5 rounded-full bg-white"}),(0,a.jsxs)("span",{className:"text-sm font-medium sm:text-base",children:["Section: ",s.sectionName]})]})]})})]})]})}),(0,a.jsxs)("div",{className:"p-4 sm:p-5 md:p-6",children:[(0,a.jsxs)("div",{className:"mb-4 md:mb-5",children:[(0,a.jsxs)("div",{className:"mb-3 flex items-center gap-2",children:[(0,a.jsx)("div",{className:"h-6 w-1 rounded-full bg-gradient-to-b from-blue-500 to-purple-500"}),(0,a.jsx)("h3",{className:"text-lg font-bold text-gray-800 sm:text-xl md:text-2xl",children:"Candidate Manifesto"})]}),(0,a.jsx)("div",{className:"rounded-lg border border-blue-100 bg-gradient-to-r from-blue-50 to-purple-50 p-4 sm:rounded-xl sm:p-5",children:(0,a.jsx)("p",{className:"whitespace-pre-line text-sm leading-relaxed text-gray-700 sm:text-base",children:s.manifesto||"No manifesto provided by the candidate."})})]}),(0,a.jsxs)("div",{className:"mb-4 grid grid-cols-1 gap-3 sm:grid-cols-3 sm:gap-4 md:mb-5",children:[(0,a.jsxs)("div",{className:"rounded-lg bg-gray-50 p-3 text-center transition-shadow duration-300 hover:shadow-md sm:p-4",children:[(0,a.jsx)("div",{className:"mb-1 text-base font-bold text-blue-600 sm:text-sm",children:s.fullName||"-"}),(0,a.jsx)("div",{className:"text-xs font-medium text-gray-600",children:"Candidate"})]}),(0,a.jsxs)("div",{className:"rounded-lg bg-gray-50 p-3 text-center transition-shadow duration-300 hover:shadow-md sm:p-4",children:[(0,a.jsx)("div",{className:"mb-1 text-base font-bold text-purple-600 sm:text-sm",children:s.electionName||"-"}),(0,a.jsx)("div",{className:"text-xs font-medium text-gray-600",children:"Election"})]}),(0,a.jsxs)("div",{className:"rounded-lg bg-gray-50 p-3 text-center transition-shadow duration-300 hover:shadow-md sm:p-4",children:[(0,a.jsx)("div",{className:"mb-1 text-base font-bold text-green-600 sm:text-sm",children:s.positionName||"-"}),(0,a.jsx)("div",{className:"text-xs font-medium text-gray-600",children:"Position"})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:gap-3",children:[(0,a.jsxs)("button",{onClick:o,disabled:i,className:"group relative flex-1 transform rounded-lg bg-gradient-to-r from-green-500 to-green-600 px-4 py-2 text-xs font-bold text-white shadow-md transition-all duration-300 hover:-translate-y-0.5 hover:from-green-600 hover:to-green-700 hover:shadow-lg disabled:cursor-not-allowed disabled:opacity-70 sm:px-5 sm:text-sm",children:[(0,a.jsxs)("span",{className:"relative z-10 flex items-center justify-center gap-1",children:[i?(0,a.jsx)("span",{className:"animate-spin",children:"â»"}):(0,a.jsx)(q.Z,{className:"h-3 w-3 sm:h-4 sm:w-4"}),i?"Processing...":"Cast Your Vote"]}),(0,a.jsx)("div",{className:"absolute inset-0 rounded-lg bg-gradient-to-r from-green-400 to-green-500 opacity-0 transition-opacity duration-300 group-hover:opacity-100"})]}),(0,a.jsxs)("button",{onClick:t,disabled:i,className:"group relative flex-1 transform rounded-lg bg-gradient-to-r from-red-400 to-red-500 px-4 py-2 text-xs font-bold text-white shadow-md transition-all duration-300 hover:-translate-y-0.5 hover:from-red-500 hover:to-red-600 hover:shadow-lg disabled:opacity-70 sm:px-5 sm:text-sm",children:[(0,a.jsxs)("span",{className:"relative z-10 flex items-center justify-center gap-1",children:[(0,a.jsx)(z.Z,{className:"h-3 w-3 sm:h-4 sm:w-4"}),"Cancel"]}),(0,a.jsx)("div",{className:"absolute inset-0 rounded-lg bg-gradient-to-r from-red-400 to-red-500 opacity-0 transition-opacity duration-300 group-hover:opacity-100"})]})]})]})]}),(0,a.jsx)("div",{className:"mt-4 text-center md:mt-5",children:(0,a.jsx)("p",{className:"text-xs text-gray-500 sm:text-sm",children:"Your vote is confidential and secure"})})]})}),(0,a.jsx)(_.aR,{open:r,onOpenChange:d,children:(0,a.jsxs)(_._T,{className:"max-w-[95vw] rounded-lg sm:max-w-md",children:[(0,a.jsxs)(_.fY,{children:[(0,a.jsx)(_.f$,{className:"text-lg sm:text-xl",children:"Confirm Your Vote"}
1),(0,a.jsxs)(_.yT,{className:"text-sm sm:text-base",children:["You are about to cast your vote for"," ",(0,a.jsx)("span",{className:"font-semibold",children:s.fullName}),". This action cannot be undone. Are you sure this is your final choice?"]})]}),(0,a.jsxs)(_.xo,{className:"mt-4 sm:mt-6",children:[(0,a.jsx)(_.le,{className:"rounded-md bg-gray-100 px-4 py-2 text-gray-800 transition-colors hover:bg-gray-200",children:"Cancel"}),(0,a.jsx)(_.OL,{onClick:c,className:"rounded-md bg-green-600 px-4 py-2 text-white transition-colors hover:bg-green-700",disabled:i,children:i?"Processing...":"Confirm Vote"})]})]})})]})},W=t(65526),X=t(49322),$=e=>{var s,t,l,n;let{onClose:d}=e,{toast:o}=(0,R.pm)(),[c,m]=(0,Z.useState)(""),[p,g]=(0,Z.useState)(""),[j,N]=(0,Z.useState)(""),[v,f]=(0,Z.useState)(0),[b,y]=(0,Z.useState)(!1),[w,S]=(0,Z.useState)(null),[C,E]=(0,Z.useState)(!1),{data:k,isLoading:L,isError:P}=(0,I.VS)({centerId:Number(x.Z.getSchoolId()),boardId:Number(x.Z.getBoardId()),params:{}}),D=e=>{let s=new Date,t=new Date(e.nominationStart),a=new Date(e.nominationEnd);return s>=t&&s<=a};(0,Z.useEffect)(()=>{if(c&&(null==k?void 0:k.content)){let e=k.content.find(e=>e.id.toString()===c);e&&(S(e),E(D(e)))}else S(null),E(!1)},[c,k]);let{data:V,isLoading:T,isError:F}=(0,u.Q)({centerId:Number(x.Z.getSchoolId()),boardId:Number(x.Z.getBoardId()),electionId:Number(c),params:{}},{skip:!c}),[B,{isLoading:O}]=(0,h.xi)();(0,Z.useEffect)(()=>{y(!!c&&!!p&&v>=5&&v<=50&&C)},[c,p,v,C]);let A=async()=>{if(b)try{await B({centerId:Number(x.Z.getSchoolId()),boardId:Number(x.Z.getBoardId()),electionId:Number(c),positionId:Number(p),userId:Number(x.Z.getUserId()),payload:{manifesto:j.trim()}}).unwrap(),o({title:"Nomination submitted successfully!",description:"Your application has been received.",className:"bg-green-500 text-white"}),m(""),g(""),N(""),f(0),d()}catch(e){o({title:"Failed to submit nomination",description:"There was an error submitting your application. Please try again.",variant:"destructive"})}},Y=e=>new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"});return(0,a.jsxs)("div",{className:"container mx-auto max-w-4xl p-4",children:[(0,a.jsxs)("div",{className:"mb-6 grid grid-cols-1 gap-6 md:grid-cols-2",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:"Election"}),(0,a.jsxs)(r.Ph,{onValueChange:m,value:c,children:[(0,a.jsx)(r.i4,{className:"w-full",children:(0,a.jsx)(r.ki,{placeholder:"Select an election"})}),(0,a.jsxs)(r.Bw,{children:[L&&(0,a.jsx)(r.Ql,{disabled:!0,value:"loading",children:"Loading elections..."}),P&&(0,a.jsx)(r.Ql,{disabled:!0,value:"error",children:"Failed to load elections"}),!L&&!P&&(null==k?void 0:null===(s=k.content)||void 0===s?void 0:s.length)===0&&(0,a.jsx)(r.Ql,{disabled:!0,value:"no-data",children:"No elections available"}),null==k?void 0:null===(t=k.content)||void 0===t?void 0:t.map(e=>(0,a.jsx)(r.Ql,{value:e.id.toString(),children:e.title},e.id))]})]})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:"Position"}),(0,a.jsxs)(r.Ph,{onValueChange:g,value:p,disabled:!c||!C,children:[(0,a.jsx)(r.i4,{className:"w-full",children:(0,a.jsx)(r.ki,{placeholder:c?C?"Select a position":"Nomination period closed":"Select an election first"})}),(0,a.jsxs)(r.Bw,{children:[T&&(0,a.jsx)(r.Ql,{disabled:!0,value:"loading",children:"Loading positions..."}),F&&(0,a.jsx)(r.Ql,{disabled:!0,value:"error",children:"Failed to load positions"}),!T&&!F&&(null==V?void 0:null===(l=V.content)||void 0===l?void 0:l.length)===0&&(0,a.jsx)(r.Ql,{disabled:!0,value:"no-data",children:"No positions available for this election"}),null==V?void 0:null===(n=V.content)||void 0===n?void 0:n.map(e=>(0,a.jsx)(r.Ql,{value:e.id.toString(),children:e.name},e.id))]})]})]})]}),w&&(0,a.jsxs)("div",{className:"mb-6 rounded-lg border p-4",children:[(0,a.jsxs)("div",{className:"flex items-start space-x-3",children:[(0,a.jsx)(Q.Z,{className:"mt-1 h-5 w-5 text-blue-500"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("h3",{className:"font-semibold text-gray-800",children:"Nomination Period"}),(0,a.jsxs)("p",{className:"text-sm text-gray-600",children:["Starts: ",Y(w.nominationStart)]}),(0,a.jsxs)("p",{className:"text-sm text-gray-600",children:["Ends: ",Y(w.nominationEnd)]})]})]}),!C&&(0,a.jsxs)("div",{className:"mt-3 flex items-center space-x-2 rounded-md bg-yellow-50 p-3",children:[(0,a.jsx)(X.Z,{className:"h-5 w-5 text-yellow-500"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium text-yellow-800",children:new Date<new Date(w.nominationStart)?"Nomination period has not started yet":"Nomination period has ended"}),(0,a.jsx)("p",{className:"text-xs text-yellow-600",children:"You can only submit nominations during the nomination period."})]})]})]}),C?(0,a.jsxs)("div",{className:"mb-6",children:[(0,a.jsx)("label",{className:"mb-2 block text-sm font-medium text-gray-700",children:"Manifesto (5-50 words)"}),(0,a.jsx)(W.g,{value:j,onChange:e=>{let s=e.target.value;N(s),f((s.trim()?s.trim().split(/\s+/):[]).length)},placeholder:"Explain why you should be nominated (5-50 words)",className:"min-h-[120px]",disabled:!C}),(0,a.jsxs)("div",{className:"mt-1 text-xs ".concat(v>50?"text-red-500":"text-gray-500"),children:["Word count: ",v,"/50"]}),v>50&&(0,a.jsx)("p",{className:"mt-1 text-sm text-red-500",children:"Manifesto must be 50
1words or less"}),v>0&&v<5&&(0,a.jsx)("p",{className:"mt-1 text-sm text-red-500",children:"Manifesto must be at least 5 words"})]}):w?(0,a.jsxs)("div",{className:"mb-6 rounded-lg bg-gray-50 p-4 text-center",children:[(0,a.jsx)(U.Z,{className:"mx-auto h-8 w-8 text-gray-400"}),(0,a.jsx)("p",{className:"mt-2 text-sm text-gray-600",children:new Date<new Date(w.nominationStart)?"Nomination period will open soon. Please check back during the nomination period to submit your application.":"The nomination period for this election has ended. No further nominations can be accepted."})]}):null,(0,a.jsxs)("div",{className:"flex space-x-3",children:[C?(0,a.jsx)(i.z,{onClick:A,disabled:!b||O,className:"bg-[var(--primary-color)] text-white hover:bg-[var(--primary-color)] hover:text-white",children:O?"Submitting...":"Apply for Nomination"}):null,(0,a.jsx)(i.z,{variant:"outline",className:"text-red-500",onClick:d,children:"Cancel"})]})]})},H=t(87899),J=e=>{let{onClose:s}=e,{data:t,isLoading:l,isError:i,error:n}=(0,h.EE)({centerId:Number(x.Z.getSchoolId()),boardId:Number(x.Z.getBoardId()),userId:Number(x.Z.getUserId())}),r=(null==t?void 0:t.content)||[];return(0,a.jsx)("div",{className:"h-[85vh] overflow-auto p-4 sm:p-6 lg:p-4",children:(0,a.jsx)("div",{className:"mx-auto max-w-4xl",children:l?(0,a.jsx)("div",{className:"flex h-full w-full items-center justify-center p-12",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("div",{className:"mx-auto mb-4 h-12 w-12 animate-spin rounded-full border-b-2 border-gray-900"}),(0,a.jsx)("p",{className:"text-lg text-gray-600",children:"Loading your nominations..."})]})}):i?(0,a.jsxs)("div",{className:"flex h-full w-full flex-col items-center justify-center p-12",children:[(0,a.jsx)(H.lEC,{color:"red",size:35}),(0,a.jsx)("h3",{className:"mb-2 font-semibold text-red-500",children:"Error Loading summary of the positions you've applied for."}),(0,a.jsx)("p",{className:"text-sm text-red-500",children:null==n?void 0:n.toString()})]}):0===r.length?(0,a.jsxs)("div",{className:"flex h-full w-full flex-col items-center justify-center p-12",children:[(0,a.jsx)("img",{src:"/noData.jpg",className:"mb-3 h-48"}),(0,a.jsx)("h3",{className:"mb-2 font-semibold text-gray-700",children:"No Nominations Yet"}),(0,a.jsx)("p",{className:"text-gray-600",children:"You haven't made any nominations yet."})]}):(0,a.jsx)("div",{className:"space-y-6",children:r.map(e=>(0,a.jsxs)("div",{className:"overflow-hidden rounded-xl border border-gray-200 bg-gray-50 transition-shadow duration-200 hover:shadow-md",children:[(0,a.jsx)("div",{className:"p-6 pb-4",children:(0,a.jsxs)("div",{className:"flex items-start gap-4",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:e.imageUrl?(0,a.jsx)("img",{src:(0,m.fr)(e.imageUrl),alt:e.fullName,className:"h-16 w-16 rounded-full border-2 border-white object-cover shadow-sm sm:h-20 sm:w-20"}):(0,a.jsx)("div",{className:"flex h-16 w-16 items-center justify-center rounded-full border-2 border-white bg-gray-200 shadow-sm sm:h-20 sm:w-20",children:(0,a.jsx)("span",{className:"text-xs font-medium text-gray-500",children:"No Image"})})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("h3",{className:"truncate text-lg font-semibold text-gray-900",children:e.fullName||"No Name Provided"}),(0,a.jsxs)("p",{className:"mt-1 text-sm text-gray-600",children:[(0,a.jsx)("span",{className:"font-medium",children:"Position:"})," ",e.positionName]}),(0,a.jsxs)("p",{className:"text-sm text-gray-600",children:[(0,a.jsx)("span",{className:"font-medium",children:"Election:"})," ",e.electionName]})]})]})}),(0,a.jsx)("div",{className:"space-y-3 px-6 pb-6",children:(0,a.jsxs)("div",{className:"space-y-2 rounded-lg bg-white p-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("p",{className:"text-sm text-gray-600",children:[(0,a.jsx)("span",{className:"font-medium",children:"Class:"})," ",e.className," - ",e.sectionName]}),(0,a.jsx)("span",{className:"inline-flex rounded-full px-2 py-1 text-xs font-medium ".concat("Approved"===e.status?"bg-green-100 text-green-800":"Pending"===e.status?"bg-yellow-100 text-yellow-800":"Rejected"===e.status?"bg-red-100 text-red-800":"bg-gray-100 text-gray-800"),children:e.status||"Unknown"})]}),(0,a.jsxs)("div",{className:"border-t border-gray-100 pt-2",children:[(0,a.jsx)("p",{className:"mb-2 text-sm text-gray-600",children:(0,a.jsx)("span",{className:"font-medium",children:"Manifesto:"})}),(0,a.jsx)("p",{className:"text-sm leading-relaxed text-gray-800",children:e.manifesto||"No manifesto provided"})]}),(0,a.jsx)("div",{className:"border-t border-gray-100 pt-2",children:(0,a.jsxs)("p",{className:"text-xs text-gray-500",children:[(0,a.jsx)("span",{className:"font-medium",children:"Nominated on:"})," ",new Date(e.createdAt).toLocaleDateString()]})})]})})]},e.id))})})})},K=t(28728),G=e=>{var s,t,p,g,j,v;let{onFlip:f,feature:b,subFeatures:y,hasBack:D}=e,[V,T]=(0,Z.useState)(!1),[F,Q]=(0,Z.useState)(!1),[U,B]=(0,Z.useState)(!1),[A,Y]=(0,Z.useState)(!1),[q,z]=(0,Z.useState)(""),[R,_]=(0,Z.useState)(""),[W,X]=(0,Z.useState)(null),[H,G]=(0,Z.useState)(null),[ee,es]=(0,Z.useState)(!1),{data:et,isLoading:ea,isError:el}=(0,I.VS)({centerId:Number(x.Z.getSchoolId()),boardId:Number(x.Z.getBoardId()),params:{}}),ei=e=>{let s=new Date,t=new Date(e.votingStart),a=new Date(e.votingEnd);return s>=t&&s<=a};(0,Z.useEffect)(()=>
1{if(q&&(null==et?void 0:et.content)){let e=et.content.find(e=>e.id.toString()===q);e&&(G(e),es(ei(e)))}else G(null),es(!1)},[q,et]);let{data:en,isLoading:er,isError:ed}=(0,u.Q)({centerId:Number(x.Z.getSchoolId()),boardId:Number(x.Z.getBoardId()),electionId:Number(q),params:{}},{skip:!q}),{data:eo,isLoading:ec,isFetching:em,isError:ex}=(0,h.Ox)({centerId:Number(x.Z.getSchoolId()),boardId:Number(x.Z.getBoardId()),electionId:Number(q),positionId:Number(R),params:{status:"APPROVED"}},{skip:!q||!R}),{data:eh,isLoading:eu,isError:ep}=w({params:{centerId:Number(x.Z.getSchoolId()),boardId:Number(x.Z.getBoardId()),electionId:Number(q),positionId:Number(R),userId:Number(x.Z.getUserId())}},{skip:!q||!R}),{data:eg,isLoading:ej,isError:eN}=N({centerId:Number(x.Z.getSchoolId()),boardId:Number(x.Z.getBoardId()),electionId:Number(q),positionId:Number(R),params:{userId:Number(x.Z.getUserId())}},{skip:!q||!R}),ev=e=>{X(e),B(!0)},ef=e=>null!=eg&&!!eg.content&&eg.content.some(s=>s.candidateId===e&&s.electionId===Number(q)&&s.positionId===Number(R)),eb=e=>new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"}),ey=()=>{if(!H)return"";let e=new Date,s=new Date(H.votingStart),t=new Date(H.votingEnd);return e<s?"Voting period starts on ".concat(eb(H.votingStart)):e>t?"Voting period ended on ".concat(eb(H.votingEnd)):"Voting period ends on ".concat(eb(H.votingEnd))};return(0,a.jsx)(c.Z,{title:null==b?void 0:b.displayName,tooltipContent:(0,K.O)(b,"Manage houses, council roles, elections and clubs."),icon:(0,a.jsx)(E.A5B,{className:"fill-[#4969F3] text-2xl"}),handleFlip:f,displayFlip:D,managebutton:!0,managebuttoncontent:(0,a.jsxs)(n.h_,{children:[(0,a.jsx)(n.$F,{asChild:!0,children:(0,a.jsx)(i.z,{variant:"ghost",size:"icon",children:(0,a.jsx)(E.Blh,{className:"h-5 w-5"})})}),(0,a.jsxs)(n.AW,{align:"end",children:[(0,a.jsx)(n.Xi,{onClick:()=>T(!0),className:"cursor-pointer",children:"Nominate Yourself"}),(0,a.jsx)(n.Xi,{onClick:()=>Q(!0),className:"cursor-pointer",children:"Nominations"}),(0,a.jsx)(n.Xi,{onClick:()=>Y(!0),className:"cursor-pointer",children:"Elections"})]})]}),children:(0,a.jsxs)("div",{className:"flex h-full w-full flex-col px-5",children:[(0,a.jsxs)("div",{className:"mb-4 grid grid-cols-1 gap-4 md:grid-cols-2",children:[(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:"Election"}),(0,a.jsxs)(r.Ph,{onValueChange:e=>{z(e),_("")},value:q,children:[(0,a.jsx)(r.i4,{className:"w-full",children:(0,a.jsx)(r.ki,{placeholder:"Select an election"})}),(0,a.jsxs)(r.Bw,{children:[ea&&(0,a.jsx)(r.Ql,{disabled:!0,value:"loading",children:"Loading elections..."}),el&&(0,a.jsx)(r.Ql,{disabled:!0,value:"error",children:"Failed to load elections"}),!ea&&!el&&(null==et?void 0:null===(s=et.content)||void 0===s?void 0:s.length)===0&&(0,a.jsx)(r.Ql,{disabled:!0,value:"no-data",children:"No elections available"}),null==et?void 0:null===(t=et.content)||void 0===t?void 0:t.map(e=>(0,a.jsx)(r.Ql,{value:e.id.toString(),children:e.title},e.id))]})]})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:"Position"}),(0,a.jsxs)(r.Ph,{onValueChange:e=>{_(e)},value:R,disabled:!q,children:[(0,a.jsx)(r.i4,{className:"w-full",children:(0,a.jsx)(r.ki,{placeholder:q?"Select a position":"Select an election first"})}),(0,a.jsxs)(r.Bw,{children:[er&&(0,a.jsx)(r.Ql,{disabled:!0,value:"loading",children:"Loading positions..."}),ed&&(0,a.jsx)(r.Ql,{disabled:!0,value:"error",children:"Failed to load positions"}),!er&&!ed&&(null==en?void 0:null===(p=en.content)||void 0===p?void 0:p.length)===0&&(0,a.jsx)(r.Ql,{disabled:!0,value:"no-data",children:"No positions available for this election"}),null==en?void 0:null===(g=en.content)||void 0===g?void 0:g.map(e=>(0,a.jsx)(r.Ql,{value:e.id.toString(),children:e.name},e.id))]})]})]})]}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto",children:q&&R?(0,a.jsxs)(a.Fragment,{children:[(ep||eN)&&(0,a.jsx)("div",{className:"flex h-full items-center justify-center",children:"Error checking vote status."}),em?(0,a.jsxs)("div",{className:"flex h-full flex-col items-center justify-center",children:[(0,a.jsx)(P.olI,{className:"mb-2 animate-spin text-4xl text-gray-500"}),(0,a.jsx)("p",{className:"text-gray-600",children:"Loading Nominated Candidates..."})]}):ex?(0,a.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,a.jsxs)(l.bZ,{variant:"destructive",className:"max-w-md border-none",children:[(0,a.jsx)(S.Z,{className:"h-4 w-4"}),(0,a.jsx)(l.Cd,{children:"Error"}),(0,a.jsx)(l.X,{children:"Failed to load candidates. Please try again later."})]})}):(null==eo?void 0:null===(j=eo.content)||void 0===j?void 0:j.length)===0?(0,a.jsxs)("div",{className:"flex h-full flex-col items-center justify-center p-4",children:[(0,a.jsx)("img",{src:"/noData.jpg",className:"mb-3 h-44 object-contain",alt:"No candidates"}),(0,a.jsx)("p",{className:"text-center text-sm font-medium text-gray-600",children:"No nominated candidates for the selected election and position"})]}):(0,a.jsx)("div",{className:"grid grid-cols-1 gap-3 p-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:null==eo?void 0:null===(v=eo.content)||void 0===v?void 0:v.map(e=>(0,a.jsxs)("div",{className:"flex flex-col rounded-lg border p-3 transition-shadow hover:shadow-md",children:[(0,a.jsxs)("div",{className:"mb-2 flex items-center space-x-3",children:[e.imageUrl?(0,a.jsx)("img",{src:(0,m.fr)(e.imageUrl),alt:e.fullName,className:"h-10 w-10 rounded-full object-cover"}):(0,a.jsx)("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-gray-200",children:(0,a.jsx)("span",{className:"text-xs text-gray-500",children:"Img"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("h3",{className:"truncate text-sm font-medium",children:e.fullName}),(0,a.jsxs)("p",{className:"truncate text-xs text-gray-500",children:[e.className," - ",e.sectionName]})]})]}),e.manifesto&&(0,a.jsx)("p",{className:"mb-2 line-clamp-2 flex-1 text-xs text-gray-600",children:e.manifesto}),ef(e.userId)?(0,a.jsxs)("div",{className:"mt-auto flex items-center justify-center gap-2 rounded bg-green-50 px-3 py-2 text-sm text-green-600",children:[(0,a.jsx)(C.Z,{className:"h-4 w-4"}),(0,a.jsx)("span",{children:"Chosen"})]}):eh?(0,a.jsxs)("div",{className:"mt-auto flex items-center justify-center gap-2 rounded bg-red-50 px-3 py-2 text-sm text-red-600",children:[(0,a.jsx)(L.pyx,{className:"h-4 w-4"}),(0,a.jsx)("span",{children:"Rejected"})]}):(0,a.jsx)(o.pn,{children:(0,a.jsxs)(o.u,{children:[(0,a.jsx)(o.aJ,{asChild:!0,children:(0,a.jsx)("div",{children:(0,a.jsxs)(i.z,{className:"mt-auto flex w-full gap-2 text-blue-500",size:"sm",variant:"outline",onClick:()=>ev(e),disabled:!ee,children:[(0,a.jsx)(k.eZR,{size:25,color:"blue"}),"Cast Vote"]})})}),!ee&&(0,a.jsx)(o._v,{children:(0,a.jsx)("p",{children:ey()})})]})})]},e.id))})]}):(0,a.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,a.jsx)("p",{className:"text-center",children:"Please select an election and position to view candidates and cast your vote."})})}),(0,a.jsx)(d.yo,{open:V,onOpenChange:T,children:(0,a.jsxs)(d.ue,{className:"w-full md:max-w-2xl",children:[(0,a.jsxs)(d.Tu,{children:[(0,a.jsx)(d.bC,{children:"Apply for Nomination"}),(0,a.jsx)(d.Ei,{children:"Fill in the form to submit your nomination request."})]}),(0,a.jsx)($,{onClose:()=>{T(!1)}})]})}),(0,a.jsx)(d.yo,{open:F,onOpenChange:Q,children:(0,a.jsxs)(d.ue,{className:"w-full md:max-w-2xl",children:[(0,a.jsxs)(d.Tu,{children:[(0,a.jsx)(d.bC,{children:"Nomination Overview"}),(0,a.jsx)(d.Ei,{children:"Here's a summary of the positions you've applied for."})]}),(0,a.jsx)(J,{onClose:()=>{Q(!1)}})]})}),(0,a.jsx)(d.yo,{open:U,onOpenChange:B,children:(0,a.jsxs)(d.ue,{className:"w-full md:max-w-2xl",children:[(0,a.jsxs)(d.Tu,{children:[(0,a.jsx)(d.bC,{children:"Cast V
1ote"}),(0,a.jsx)(d.Ei,{children:"One click, one voice. Submit your vote with confidence."})]}),W&&(0,a.jsx)(M,{candidate:W,onClose:()=>{B(!1),X(null)}})]})}),(0,a.jsx)(d.yo,{open:A,onOpenChange:Y,children:(0,a.jsxs)(d.ue,{className:"w-full md:max-w-2xl",children:[(0,a.jsxs)(d.Tu,{children:[(0,a.jsx)(d.bC,{children:"Important Dates"}),(0,a.jsx)(d.Ei,{children:"Key dates and deadlines for the election process."})]}),(0,a.jsx)(O,{onClose:()=>Y(!1)})]})})]})})}}}]);
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.