PageSourceSearch

https://indiancaucus.org/_next/static/chunks/pages/dashboard/polls-27d0f1f6ffe4b4fe.js

js indiancaucus.org collected 2026-10-02 01:11:01 UTC 17,362 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7431],{27110:(e,t,r)=>{"use strict";function n(e){if(!e)return null;let t=String(e).match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/);if(!t){let t=new Date(e);return isNaN(t)?null:t.toISOString()}let[,r,n,i,s,o]=t.map(Number),a=Date.UTC(r,n-1,i,s,o),l=function(e,t){let r=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(e).reduce((e,t)=>(e[t.type]=t.value,e),{});return Date.UTC(+r.year,r.month-1,+r.day,+r.hour,+r.minute,+r.second)-e.getTime()}(new Date(a),"America/New_York");return new Date(a-l).toISOString()}function i(){let e=new Intl.DateTimeFormat("en-CA",{timeZone:"America/New_York",hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).formatToParts(new Date).reduce((e,t)=>(e[t.type]=t.value,e),{});return`${e.year}-${e.month}-${e.day}T${e.hour}:${e.minute}`}function s(e){if(!e)return"";let t=e instanceof Date?e:new Date(e);if(isNaN(t))return"";let r=new Intl.DateTimeFormat("en-CA",{timeZone:"America/New_York",hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).formatToParts(t).reduce((e,t)=>(e[t.type]=t.value,e),{});return`${r.year}-${r.month}-${r.day}T${r.hour}:${r.minute}`}function o(e,t={month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}){if(!e)return"";let r=e instanceof Date?e:new Date(e);return isNaN(r)?"":r.toLocaleString("en-US",{...t,timeZone:"America/New_York"})+" ET"}function a(e,t={month:"short",day:"numeric",year:"numeric"}){if(!e)return"";let r=e instanceof Date?e:new Date(e);return isNaN(r)?"":r.toLocaleDateString("en-US",{...t,timeZone:"America/New_York"})}function l(e){let t=String(e||"").match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/);if(!t)return"";let[,r,n,i,s,o]=t.map(Number);return new Date(r,n-1,i,s,o).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})+" ET"}r.d(t,{$e:()=>n,S4:()=>i,b3:()=>o,lQ:()=>a,sX:()=>l,y4:()=>s})},35650:(e,t,r)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/dashboard/polls",function(){return r(62525)}])},62525:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>d});var n=r(37876),i=r(14232),s=r(90030),o=r(27110),a=r(77073);let l={question:"",kind:"single",options:["",""],closesAt:""};function d(){let[e,t]=(0,i.useState)(null),[r,d]=(0,i.useState)(""),[u,c]=(0,i.useState)(l),[h,m]=(0,i.useState)(!1),[p,f]=(0,i.useState)(""),x="border border-gray-200 dark:border-white/10 rounded-xl px-3 py-2.5 text-sm w-full dark:text-white dark:placeholder-white/30";function g(){(0,a.B)("/api/admin/polls",e=>t(e.polls||[])).catch(()=>{})}async function y(){let e=u.options.map(e=>e.trim()).filter(Boolean);if(!u.question.trim()||e.length<2)return void f("A question and at least two options are required");m(!0),f("");try{let t=await fetch("/api/admin/polls",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({question:u.question,kind:u.kind,options:e,closesAt:u.closesAt||null})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||"Could not save")}c(l),g()}catch(e){f(e.message)}finally{m(!1)}}async function v(e){let t="open"===e.status?"closed":"open";await fetch("/api/admin/polls",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id,status:t})}),g()}async function _(e){confirm("Delete this poll and all its votes?")&&(await fetch("/api/admin/polls",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e})}),g())}return(0,i.useEffect)(()=>{g()},[]),(0,n.jsx)(s.Ay,{title:"Polls & surveys",children:(0,n.jsxs)("div",{className:"max-w-6xl grid lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)] gap-6 items-start",children:[(0,n.jsxs)("div",{className:"bg-white dark:bg-white/4 roun
1ded-2xl border border-gray-100 dark:border-white/10 shadow-xs p-5",children:[(0,n.jsx)("p",{className:"font-bold text-gray-900 dark:text-white text-sm mb-1",children:"Create a poll"}),(0,n.jsx)("p",{className:"text-gray-400 dark:text-white/40 text-xs mb-3",children:"Members vote in the app under Polls. Results update here as votes come in."}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("textarea",{className:x,rows:2,placeholder:"Question",value:u.question,onChange:e=>c({...u,question:e.target.value}),maxLength:1e3}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)("button",{onClick:()=>c({...u,kind:"single"}),className:`flex-1 text-sm font-bold rounded-xl px-3 py-2 border ${"single"===u.kind?"border-[#F26644] bg-gray-50 dark:bg-white/6 text-gray-900 dark:text-white":"border-gray-200 dark:border-white/10 text-gray-500 dark:text-white/60"}`,children:"Single choice"}),(0,n.jsx)("button",{onClick:()=>c({...u,kind:"multi"}),className:`flex-1 text-sm font-bold rounded-xl px-3 py-2 border ${"multi"===u.kind?"border-[#F26644] bg-gray-50 dark:bg-white/6 text-gray-900 dark:text-white":"border-gray-200 dark:border-white/10 text-gray-500 dark:text-white/60"}`,children:"Multiple choice"})]}),u.options.map((e,t)=>(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("input",{className:x,placeholder:`Option ${t+1}`,value:e,onChange:e=>{var r;return r=e.target.value,void c(e=>({...e,options:e.options.map((e,n)=>n===t?r:e)}))},maxLength:300}),u.options.length>2&&(0,n.jsx)("button",{onClick:()=>{c(e=>e.options.length<=2?e:{...e,options:e.options.filter((e,r)=>r!==t)})},className:"text-gray-300 dark:text-white/40 hover:text-red-500 text-sm font-bold shrink-0 px-1",children:"Remove"})]},t)),u.options.length<30&&(0,n.jsx)("button",{onClick:function(){c(e=>e.options.length>=30?e:{...e,options:[...e.options,""]})},className:"text-[#F26644] text-sm font-bold self-start",children:"+ Add option"}),(0,n.jsxs)("label",{className:"text-xs text-gray-500 dark:text-white/60 flex flex-col gap-1",children:["Close date (optional) ",(0,n.jsx)("span",{className:"text-gray-400 dark:text-white/40",children:"\xb7 Eastern (ET)"}),(0,n.jsx)("input",{type:"datetime-local",className:x,min:(0,o.S4)(),value:u.closesAt,onChange:e=>c({...u,closesAt:e.target.value})})]})]}),p&&(0,n.jsx)("p",{className:"text-red-600 text-xs mt-2",children:p}),(0,n.jsx)("button",{onClick:y,disabled:h,className:"mt-3 bg-[#0F2044] text-white text-sm font-bold rounded-xl px-5 py-2.5 disabled:opacity-50",children:h?"Saving…":"Create poll"})]}),(0,n.jsxs)("div",{className:"space-y-2",children:[e?.length>0&&(0,n.jsxs)("div",{className:"flex-1 min-w-0 relative",children:[(0,n.jsxs)("svg",{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-gray-400 dark:text-white/40",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),(0,n.jsx)("input",{type:"text",placeholder:"Search polls…",value:r,onChange:e=>d(e.target.value),className:"w-full bg-white dark:bg-white/4 border border-gray-200 dark:border-white/10 rounded-xl pl-9 pr-4 py-2.5 text-sm focus:outline-hidden focus:ring-2 focus:ring-[#F26644]/20 focus:border-[#F26644] transition-all shadow-xs dark:text-white dark:placeholder-white/30"})]}),null===e?(0,n.jsx)("div",{className:"space-y-2",children:[0,1,2].map(e=>(0,n.jsx)("div",{className:"h-28 rounded-2xl bg-gray-50 dark:bg-white/6 animate-pulse"},e))}):0===e.length?(0,n.jsx)("p",{className:"text-gray-400 dark:text-white/40 text-sm",children:"No polls yet."}):e.filter(e=>`${e.question||""} ${(e.options||[]).map(e=>e.label).join(" ")} ${e.created_by||""}`.toLowerCase().includes(r.trim().toLowerCase())).map(e=>{let t;return(0,n.jsxs)("div",{className:"bg-white dark:bg-white/4 roun
1ded-2xl border border-gray-100 dark:border-white/10 shadow-xs p-4",children:[(0,n.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,n.jsx)("p",{className:"font-bold text-gray-900 dark:text-white",children:e.question}),(0,n.jsx)("span",{className:`shrink-0 text-[10px] font-bold uppercase tracking-wide rounded-full px-2 py-0.5 ${"open"===e.status?"text-[#2e9664] bg-green-50":"text-gray-400 bg-gray-100"}`,children:e.status})]}),(0,n.jsx)("div",{className:"mt-3 space-y-2",children:e.options.map(t=>{let r=e.totalVotes>0?Math.round(t.votes/e.totalVotes*100):0;return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center justify-between text-sm mb-1",children:[(0,n.jsx)("span",{className:"text-gray-600 dark:text-white/60",children:t.label}),(0,n.jsxs)("span",{className:"text-gray-400 dark:text-white/40 text-xs",children:[r,"% \xb7 ",t.votes]})]}),(0,n.jsx)("div",{className:"h-2.5 rounded-full bg-gray-100 dark:bg-white/6 overflow-hidden",children:(0,n.jsx)("div",{className:"h-full rounded-full bg-[#0F2044]",
1style:{width:`${r}%`}})})]},t.id)})}),(0,n.jsx)("p",{className:"text-gray-400 dark:text-white/40 text-xs mt-2",children:[`${e.totalVoters} voter${1===e.totalVoters?"":"s"}`,"multi"===e.kind?"multi":"single",e.closes_at?`closes ${(t=e.closes_at)?new Date(t).toLocaleString("en-US",{timeZone:"America/New_York",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):""}`:null,e.created_by].filter(Boolean).join(" \xb7 ")}),(0,n.jsxs)("div",{className:"flex items-center gap-3 mt-2.5",children:[(0,n.jsx)("button",{onClick:()=>v(e),className:"text-[#F26644] text-xs font-bold",children:"open"===e.status?"Close":"Reopen"}),(0,n.jsx)("button",{onClick:()=>_(e.id),className:"text-gray-400 dark:text-white/40 hover:text-red-500 text-xs font-bold",children:"Delete"})]})]},e.id)})]})]})})}},72552:()=>{},72784:(e,t,r)=>{"use strict";var n=r(65364);r(72552);var i=r(14232),s=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(i),o=void 0!==n&&n.env&&!0,a=function(e){return"[object String]"===Object.prototype.toString.call(e)},l=function(){function e(e){var t=void 0===e?{}:e,r=t.name,n=void 0===r?"stylesheet":r,i=t.optimizeForSpeed,s=void 0===i?o:i;d(a(n),"`name` must be a string"),this._name=n,this._deletedRulePlaceholder="#"+n+"-deleted-rule____{}",d("boolean"==typeof s,"`optimizeForSpeed` must be a boolean"),this._optimizeForSpeed=s,this._serverSheet=void 0,this._tags=[],this._injected=!1,this._rulesCount=0;var l=document.querySelector('meta[property="csp-nonce"]');this._nonce=l?l.getAttribute("content"):null}var t,r=e.prototype;return r.setOptimizeForSpeed=function(e){d("boolean"==typeof e,"`setOptimizeForSpeed` accepts a boolean"),d(0===this._rulesCount,"optimizeForSpeed cannot be when rules have already been inserted"),this.flush(),this._optimizeForSpeed=e,this.inject()},r.isOptimizeForSpeed=function(){return this._optimizeForSpeed},r.inject=function(){var e=this;if(d(!this._injected,"sheet already injected"),this._injected=!0,this._optimizeForSpeed){this._tags[0]=this.makeStyleTag(this._name),this._optimizeForSpeed="insertRule"in this.getSheet(),this._optimizeForSpeed||(o||console.warn("StyleSheet: optimizeForSpeed mode not supported falling back to standard mode."),this.flush(),this._injected=!0);return}this._serverSheet={cssRules:[],insertRule:function(t,r){return"number"==typeof r?e._serverSheet.cssRules[r]={cssText:t}:e._serverSheet.cssRules.push({cssText:t}),r},deleteRule:function(t){e._serverSheet.cssRules[t]=null}}},r.getSheetForTag=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]},r.getSheet=function(){return this.getSheetForTag(this._tags[this._tags.length-1])},r.insertRule=function(e,t){if(d(a(e),"`insertRule` accepts only strings"),this._optimizeForSpeed){var r=this.getSheet();"number"!=typeof t&&(t=r.cssRules.length);try{r.insertRule(e,t)}catch(t){return o||console.warn("StyleSheet: illegal rule: \n\n"+e+"\n\nSee https://stackoverflow.com/q/20007992 for more info"),-1}}else{var n=this._tags[t];this._tags.push(this.makeStyleTag(this._name,e,n))}return this._rulesCount++},r.replaceRule=function(e,t){if(this._optimizeForSpeed){var r=this.getSheet();if(t.trim()||(t=this._deletedRulePlaceholder),!r.cssRules[e])return e;r.deleteRule(e);try{r.insertRule(t,e)}catch(n){o||console.warn("StyleSheet: illegal rule: \n\n"+t+"\n\nSee https://stackoverflow.com/q/20007992 for more info"),r.insertRule(this._deletedRulePlaceholder,e)}}else{var n=this._tags[e];d(n,"old rule at index `"+e+"` not found"),n.textContent=t}return e},r.deleteRule=function(e){if(this._optimizeForSpeed)this.replaceRule(e,"");else{var t=this._tags[e];d(t,"rule at index `"+e+"` not found"),t.parentNode.removeChild(t),this._tags[e]=null}},r.flush=function(){this._injected=!1,this._rulesCount=0,this._tags.forEac
1h(function(e){return e&&e.parentNode.removeChild(e)}),this._tags=[]},r.cssRules=function(){var e=this;return this._tags.reduce(function(t,r){return r?t=t.concat(Array.prototype.map.call(e.getSheetForTag(r).cssRules,function(t){return t.cssText===e._deletedRulePlaceholder?null:t})):t.push(null),t},[])},r.makeStyleTag=function(e,t,r){t&&d(a(t),"makeStyleTag accepts only strings as second parameter");var n=document.createElement("style");this._nonce&&n.setAttribute("nonce",this._nonce),n.type="text/css",n.setAttribute("data-"+e,""),t&&n.appendChild(document.createTextNode(t));var i=document.head||document.getElementsByTagName("head")[0];return r?i.insertBefore(n,r):i.appendChild(n),n},t=[{key:"length",get:function(){return this._rulesCount}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),e}();function d(e,t){if(!e)throw Error("StyleSheet: "+t+".")}var u=function(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return t>>>0},c={};function h(e,t){if(!t)return"jsx-"+e;var r=String(t),n=e+r;return c[n]||(c[n]="jsx-"+u(e+"-"+r)),c[n]}function m(e,t){var r=e+t;return c[r]||(c[r]=t.replace(/__jsx-style-dynamic-selector/g,e)),c[r]}var p=function(){function e(e){var t=void 0===e?{}:e,r=t.styleSheet,n=void 0===r?null:r,i=t.optimizeForSpeed,s=void 0!==i&&i;this._sheet=n||new l({name:"styled-jsx",optimizeForSpeed:s}),this._sheet.inject(),n&&"boolean"==typeof s&&(this._sheet.setOptimizeForSpeed(s),this._optimizeForSpeed=this._sheet.isOptimizeForSpeed()),this._fromServer=void 0,this._indices={},this._instancesCounts={}}var t=e.prototype;return t.add=function(e){var t=this;void 0===this._optimizeForSpeed&&(this._optimizeForSpeed=Array.isArray(e.children),this._sheet.setOptimizeForSpeed(this._optimizeForSpeed),this._optimizeForSpeed=this._sheet.isOptimizeForSpeed()),this._fromServer||(this._fromServer=this.selectFromServer(),this._instancesCounts=Object.keys(this._fromServer).reduce(function(e,t){return e[t]=0,e},{}));var r=this.getIdAndRules(e),n=r.styleId,i=r.rules;if(n in this._instancesCounts){this._instancesCounts[n]+=1;return}var s=i.map(function(e){return t._sheet.insertRule(e)}).filter(function(e){return -1!==e});this._indices[n]=s,this._instancesCounts[n]=1},t.remove=function(e){var t=this,r=this.getIdAndRules(e).styleId;if(function(e,t){if(!e)throw Error("StyleSheetRegistry: "+t+".")}(r in this._instancesCounts,"styleId: `"+r+"` not found"),this._instancesCounts[r]-=1,this._instancesCounts[r]<1){var n=this._fromServer&&this._fromServer[r];n?(n.parentNode.removeChild(n),delete this._fromServer[r]):(this._indices[r].forEach(function(e){return t._sheet.deleteRule(e)}),delete this._indices[r]),delete this._instancesCounts[r]}},t.update=function(e,t){this.add(t),this.remove(e)},t.flush=function(){this._sheet.flush(),this._sheet.inject(),this._fromServer=void 0,this._indices={},this._instancesCounts={}},t.cssRules=function(){var e=this,t=this._fromServer?Object.keys(this._fromServer).map(function(t){return[t,e._fromServer[t]]}):[],r=this._sheet.cssRules();return t.concat(Object.keys(this._indices).map(function(t){return[t,e._indices[t].map(function(e){return r[e].cssText}).join(e._optimizeForSpeed?"":"\n")]}).filter(function(e){return!!e[1]}))},t.styles=function(e){var t,r;return t=this.cssRules(),void 0===(r=e)&&(r={}),t.map(function(e){var t=e[0],n=e[1];return s.default.createElement("style",{id:"__"+t,key:"__"+t,nonce:r.nonce?r.nonce:void 0,dangerouslySetInnerHTML:{__html:n}})})},t.getIdAndRules=function(e){var t=e.children,r=e.dynamic,n=e.id;if(r){var i=h(n,r);return{styleId:i,rules:Array.isArray(t)?t.map(function(e){return m(i,e)}):[m(i,t)]}}return{styleId:h(n),rules:Array.isArray(t)?t:[t]}},t.selectFromServer=function(){return Array.prototype.slice.call(document.querySelectorAll('[id^="__jsx-"]')).reduce(function(e,t){return e[t.id.slice(2)]=t,e},{})},e}(),f=i.createContext(null);f.displayName="StyleSheetContext";var x=s.default.useInsertionEffect||s.default.useLayoutEffect,g=new p;function y(e){var t=g||i.useContext(f);return t&&x(function(){return t.add(e),function(){t.remove(e)}},[e.id,String(e.dynamic)]),null}y.dynamic=function(e){return e.map(function(e){return h(e[0],e[1])}).join(" ")},t.style=y},75961:(e,t,r)=>{"use strict";e.exports=r(72784).style},77073:(e,t,r)=>{"use strict";r.d(t,{B:()=>i});var n=r(79004);function i(e,t,{key:r=e}={}){if(r){let e=(0,n.tv)(`json:${r}`);if(void 0!==e)try{t(e)}catch{}}return fetch(e).then(e=>e.json()).then(e=>(r&&(0,n.lx)(`json:${r}`,e),t(e)))}}},e=>{e.O(0,[8230,8766,5466,30,636,6593,8792],()=>e(e.s=35650)),_N_E=e.O()}]);

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.