PageSourceSearch

https://fiftyoneai.com/js/PetitionDashboardPage.tsx-BJsBm62J.js

js fiftyoneai.com collected 2026-10-10 02:44:32 UTC 6,898 bytes, 2 lines download raw bytes

1import{j as e,k as z,aB as P,L as E,aa as D,ag as M,r as R,s as B}from"./chunk-CgdxW11o.js";import{H as $}from"./chunk-BdcivWQc.js";import{h as U,u as q,r,L as F}from"./chunk-Dmsukp28.js";import{M as O}from"./chunk-DyXhz7ao.js";import{E as A}from"./chunk-Dzmjx3hO.js";import{b as H,s as c,B as l}from"../assets/index-BrW_aWiG.js";import{B as I}from"./chunk-B-7ucqzN.js";import{g as T}from"./chunk-mNUKl6UC.js";import"./chunk-BqJbJ7gK.js";import"./chunk-CJ7iKqZf.js";import"./chunk-0KF9c2-o.js";import"./chunk-WEDgC6ok.js";import"./chunk-C6RZjUsZ.js";function ie(){const{id:n}=U(),d=q(),{toast:i}=H(),[t,m]=r.useState(null),[o,j]=r.useState([]),[g,b]=r.useState(0),[v,N]=r.useState(!0);r.useEffect(()=>{n&&(async()=>{const{data:s,error:u}=await c.from("petitions").select("*").eq("id",n).maybeSingle();if(u||!s){i({title:"Not found",variant:"destructive"}),d("/tools/mobilize");return}m(s);const{data:x}=await c.from("petition_signatures").select("id, full_name, email, zip, comment, confirmed_at, created_at").eq("petition_id",n).order("created_at",{ascending:!1}).limit(500);j(x||[]),b(await T(n)),N(!1)})()},[n,d,i]);const h=r.useMemo(()=>t?`${window.location.origin}/p/${t.slug}`:"",[t]),w=t?Math.min(100,Math.round(g/Math.max(1,t.goal_count)*100)):0,k=()=>{const s=["Name","Email","ZIP","Comment","Confirmed","Signed at"],u=o.map(a=>[a.full_name,a.email,a.zip??"",a.comment??"",a.confirmed_at?"yes":"no",a.created_at]),x=[s,...u].map(a=>a.map(_=>`"${String(_).replace(/"/g,'""')}"`).join(",")).join(`
2`),L=new Blob([x],{type:"text/csv"}),f=URL.createObjectURL(L),p=document.createElement("a");p.href=f,p.download=`${t?.slug||"petition"}-signatures.csv`,p.click(),URL.revokeObjectURL(f)},S=async()=>{if(!t||!confirm("Close this petition? Signatures will stop being accepted."))return;const{error:s}=await c.from("petitions").update({status:"closed",closed_at:new Date().toISOString()}).eq("id",t.id);if(s){i({title:s.message,variant:"destructive"});return}m({...t,status:"closed"}),i({title:"Petition closed"})},y=async()=>{if(!t)return;const{error:s}=await c.from("petitions").update({status:"active",closed_at:null}).eq("id",t.id);if(s){i({title:s.message,variant:"destructive"});return}m({...t,status:"active"}),i({title:"Petition reopened"})},C=()=>{navigator.clipboard.writeText(h),i({title:"Link copied"})};return v||!t?e.jsx("div",{className:"min-h-screen flex items-center justify-center text-sm text-muted-foreground",children:"Loading…"}):e.jsxs(e.Fragment,{children:[e.jsx($,{children:e.jsxs("title",{children:[t.title," — Mobilize"]})}),e.jsx(O,{}),e.jsxs("main",{className:"min-h-screen bg-background text-foreground",children:[e.jsx("div",{className:"pt-24 px-6",children:e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsxs(F,{to:"/tools/mobilize",className:"inline-flex items-center gap-1.5 text-xs uppercase tracking-[0.2em] text-muted-foreground hover:text-foreground transition-colors mb-8",children:[e.jsx(z,{className:"w-3.5 h-3.5"}),"All petitions"]}),e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 mb-8",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(I,{variant:t.status==="active"?"default":"outline",className:"mb-2 capitalize",children:t.status}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold tracking-tight",children:t.title}),t.target&&e.jsxs("p",{className:"text-muted-foreground mt-1",children:["to ",t.target]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(l,{variant:"outline",size:"sm",onClick:()=>d(`/tools/mobilize/${t.id}/edit`),children:[e.jsx(P,{className:"w-3.5 h-3.5 mr-2"}),"Edit"]}),t.status==="active"?e.jsxs(l,{variant:"outline",size:"sm",onClick:S,children:[e.jsx(E,{className:"w-3.5 h-3.5 mr-2"}),"Close"]}):t.status==="closed"?e.jsx(l,{variant:"outline",size:"sm",onClick:y,children:"Reopen"}):null]})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-4 mb-8",children:[e.jsxs("div",{className:"border border-border/40 rounded-sm p-6",children:[e.jsx("p",{className:"text-xs uppercase tracking-[0.2em] text-muted-foreground mb-2",children:"Signatures"}),e.jsx("p",{className:"text-3xl font-bold",children:g.toLocaleStr
2ing()}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["of ",t.goal_count.toLocaleString()," goal"]}),e.jsx("div",{className:"mt-3 h-1 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${w}%`}})})]}),e.jsxs("div",{className:"border border-border/40 rounded-sm p-6",children:[e.jsx("p",{className:"text-xs uppercase tracking-[0.2em] text-muted-foreground mb-2",children:"Public link"}),t.status==="active"?e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:h,target:"_blank",rel:"noreferrer",className:"text-sm font-medium text-primary hover:underline break-all inline-flex items-center gap-1",children:["/p/",t.slug," ",e.jsx(D,{className:"w-3 h-3"})]}),e.jsx("div",{className:"flex gap-2 mt-3",children:e.jsxs(l,{size:"sm",variant:"outline",onClick:C,children:[e.jsx(M,{className:"w-3.5 h-3.5 mr-2"}),"Copy"]})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Publish to get a public link."})]}),e.jsxs("div",{className:"border border-border/40 rounded-sm p-6",children:[e.jsx("p",{className:"text-xs uppercase tracking-[0.2em] text-muted-foreground mb-2",children:"Export"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"Download all signatures as CSV."}),e.jsxs(l,{size:"sm",variant:"outline",onClick:k,disabled:!o.length,children:[e.jsx(R,{className:"w-3.5 h-3.5 mr-2"}),"Download CSV"]})]})]}),e.jsxs("div",{className:"border border-border/40 rounded-sm",children:[e.jsxs("div",{className:"p-4 border-b border-border/40 flex items-center justify-between",children:[e.jsx("h2",{className:"font-semibold",children:"Recent signatures"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[o.length," shown"]})]}),o.length===0?e.jsx("p",{className:"p-8 text-sm text-muted-foreground text-center",children:"No signatures yet. Share your petition link to get started."}):e.jsx("div",{className:"divide-y divide-border/40",children:o.map(s=>e.jsxs("div",{className:"p-4 grid grid-cols-12 gap-3 text-sm items-start",children:[e.jsxs("div",{className:"col-span-3 font-medium truncate flex items-center gap-1.5",children:[s.confirmed_at&&e.jsx(B,{className:"w-3.5 h-3.5 text-primary shrink-0"}),s.full_name]}),e.jsx("div",{className:"col-span-3 text-muted-foreground truncate",children:s.email}),e.jsx("div",{className:"col-span-1 text-muted-foreground",children:s.zip||"—"}),e.jsx("div",{className:"col-span-3 text-muted-foreground line-clamp-2",children:s.comment||"—"}),e.jsx("div",{className:"col-span-2 text-xs text-muted-foreground text-right",children:new Date(s.created_at).toLocaleDateString()})]},s.id))})]})]})}),e.jsx("div",{className:"h-24"})]}),e.jsx(A,{})]})}export{ie 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.