PageSourceSearch

https://app.backstagebaton.com/app/assets/GroupsPage-CFyukUyq.js

js backstagebaton.com collected 2026-10-07 08:50:31 UTC 12,647 bytes, 1 lines download raw bytes

1import{r as n,c as P,a as z,j as e,B as S,t as R,T as _,E as B}from"./index-_aijvlUq.js";import{g as C}from"./groups-DEn_1gGo.js";import{m as q}from"./members-I3UAoZ9P.js";import{P as U}from"./PageHeader-DCofr6qo.js";import{I as F}from"./Input-ysTyZFq5.js";import{B as I}from"./Badge-DJIi163x.js";import{E as V}from"./EmptyState-CPGKooqj.js";import{M as W}from"./MemberMultiPicker-DdjcDFao.js";import{C as X}from"./ConfirmDialog-CODvETNM.js";import"./downscaleImage-qyGK-a3D.js";function oe(){const[r,E]=n.useState(null),[j,l]=n.useState("list"),[x,m]=n.useState(null);P(s=>s.showSuccess);const A=P(s=>s.showError),{canFully:N}=z(),h=N("groups:manage"),p=()=>{C.list().then(s=>E(Array.isArray(s)?s:[])).catch(()=>A(R("email lists")))};n.useEffect(p,[]);const b=[{key:"leadership",title:"Leadership",defaultOpen:!0},{key:"ensembles",title:"Ensembles",defaultOpen:!0},{key:"performances",title:"Performances",defaultOpen:!0},{key:"sections",title:"Sections",defaultOpen:!1},{key:"instruments",title:"Instruments",defaultOpen:!1},{key:"custom",title:"Your Lists",defaultOpen:!0}],[v,D]=n.useState(()=>new Set(b.filter(s=>s.defaultOpen).map(s=>s.key))),M=s=>D(o=>{const t=new Set(o);return t.has(s)?t.delete(s):t.add(s),t}),k=s=>{if(s.kind==="custom")return"custom";const o=s.category||(s.audience==="members"?"ensembles":"leadership");return o==="members"?"ensembles":o},[w,y]=n.useState({}),T=s=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 flex-wrap",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-800",children:s.name}),e.jsx(I,{color:s.kind==="system"?"teal":"purple",children:s.kind==="system"?"Auto-updated":"Custom"}),s.isTeam&&e.jsx(I,{color:"blue",children:s.isPaid?"Paid team":"Team"})]}),e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:[s.memberCount," member",s.memberCount===1?"":"s",s.description?` · ${s.description}`:""]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[h&&s.kind==="custom"&&e.jsx(S,{variant:"ghost",size:"sm",onClick:()=>{m(s),l("edit")},children:"Edit"}),e.jsx(S,{variant:"primary",size:"sm",disabled:s.memberCount===0,title:s.memberCount===0?"No members in this list yet":void 0,onClick:()=>{m(s),l("compose")},children:"Message"})]})]},s.id),d=()=>{l("list"),m(null),p()};return e.jsxs("div",{className:"px-4 md:px-0",children:[e.jsx(U,{title:"Email Lists",subtitle:"Pick a list to email — replies come straight back to you",actions:j==="list"&&h?e.jsx(S,{variant:"primary",size:"md",onClick:()=>{m(null),l("edit")},children:"New list"}):null}),j==="compose"&&x&&e.jsx(J,{group:x,onDone:d,onCancel:d}),j==="edit"&&e.jsx(K,{group:x,onDone:d,onCancel:d}),j==="list"&&(r===null?e.jsx("p",{className:"text-sm text-gray-400 py-4",children:"Loading email lists..."}):r.length===0?e.jsx(V,{title:"No email lists yet."}):e.jsx("div",{className:"space-y-3",children:b.concat([...new Set(r.map(k))].filter(s=>!b.some(o=>o.key===s)).map(s=>({key:s,title:s.charAt(0).toUpperCase()+s.slice(1),defaultOpen:!0}))).map(s=>{const o=r.filter(i=>k(i)===s.key);if(o.length===0)return null;const t=v.has(s.key);return e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200",children:[e.jsxs("button",{type:"button",onClick:()=>M(s.key),"aria-expanded":t,className:"w-full flex items-center justify-between px-4 py-3 text-left",children:[e.jsxs("span",{className:"text-sm font-semibold text-gray-700",children:[s.title,e.jsxs("span",{className:"ml-2 text-xs font-normal text-gray-400",children:[o.length," list",o.length===1?"":"s"]})]}),e.jsx("svg",{className:`h-4 w-4 text-gray-400 transition-transform ${t?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),t&&e.jsxs("div",{className:"divide-y divide-gray-100 border-t border-gray-100",children:[o.length>8&&e.jsx("div",{className:"px-4 py-2",children:e.jsx(F,{placeholder:`Filter ${s.title.toLowerCase()}...`,value:w[s.key]||"",onChange:i=>y(c=>({...c,[s.key]:i.target.value}))})}),(()=>{const i=o.filter(a=>!w[s.key]||a.name.toLowerCase().includes(w[s.key].toLowerCase())),c=[...new Set(i.map(a=>
1a.ensembleName).filter(Boolean))],f=[];let g=null;for(const a of i)c.length>1&&a.ensembleName&&a.ensembleName!==g&&(g=a.ensembleName,f.push(e.jsx("div",{className:"px-4 py-1.5 bg-gray-50 text-xs font-semibold text-gray-500 uppercase tracking-wide",children:a.ensembleName},`hdr-${a.ensembleName}`))),f.push(T(a));return f})()]})]},s.key)})}))]})}const $=5,O=10,Y=".pdf,.doc,.docx,.png,.jpg,.jpeg";function J({group:r,onDone:E,onCancel:j}){const[l,x]=n.useState(""),[m,A]=n.useState(""),[N,h]=n.useState([]),[p,b]=n.useState(null),[v,D]=n.useState(()=>new Set),[M,k]=n.useState(!1),w=P(t=>t.showSuccess),y=P(t=>t.showError);function T(t){const i=[...t];h(c=>{const f=[...c];for(const g of i){if(f.length>=$){y(`Up to ${$} attachments per message.`);break}if(g.size>O*1024*1024){y(`${g.name} is over ${O} MB.`);continue}f.some(a=>a.name===g.name&&a.size===g.size)||f.push(g)}return f})}n.useEffect(()=>{C.getMembers(r.id).then(t=>b(Array.isArray(t)?t:[])).catch(()=>b([]))},[r.id]);const d=(p||[]).filter(t=>!v.has(t.id)).length;function s(t){D(i=>{const c=new Set(i);return c.has(t)?c.delete(t):c.add(t),c})}async function o(t){if(t.preventDefault(),!(!l.trim()||!m.trim()||d===0)){k(!0);try{const i=await C.send(r.id,{subject:l.trim(),message:m.trim(),files:N,excludeMemberIds:[...v]});w(`Sent to ${i.reachable??i.sent} ${(i.reachable??i.sent)===1?"person":"people"} in ${r.name}.`),E()}catch(i){y(i.message||B)}finally{k(!1)}}}return e.jsxs("form",{onSubmit:o,className:"bg-white rounded-xl border border-gray-200 p-6 mb-4",children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-500 uppercase tracking-wide mb-4",children:["Message ",r.name]}),p!==null&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("p",{className:"text-xs text-gray-500 mb-1.5",children:["Going to ",e.jsxs("span",{className:"font-semibold text-gray-700",children:[d," of ",p.length]})," member",p.length===1?"":"s"," — untick anyone to leave them off this message (the list itself is unchanged)."]}),e.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1 max-h-36 overflow-y-auto border border-gray-200 rounded-lg p-2.5",children:p.map(t=>e.jsxs("label",{className:"inline-flex items-center gap-1.5 text-sm text-gray-700 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:!v.has(t.id),onChange:()=>s(t.id),className:"rounded border-gray-300 text-band-600 focus:ring-band-500"}),e.jsxs("span",{className:v.has(t.id)?"line-through text-gray-400":"",children:[t.firstName," ",t.lastName,!t.hasEmail&&e.jsx("span",{className:"text-amber-600 text-xs",children:" (no email)"})]})]},t.id))}),d===0&&e.jsx("p",{className:"text-xs text-red-600 mt-1",children:"Everyone is unticked — select at least one recipient."}),r.audience==="members"&&e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg text-sm text-red-700 p-3 mt-2",children:[e.jsx("span",{className:"font-semibold",children:"Privacy:"})," each member receives their own individually-addressed copy — email addresses are ",e.jsx("span",{className:"font-semibold",children:"never visible to other recipients"}),"."]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(F,{label:"Subject",value:l,onChange:t=>x(t.target.value),required:!0,maxLength:200}),e.jsx(_,{label:"Message",hint:"Sent from your name — replies come straight back to your email",value:m,onChange:t=>A(t.target.value),rows:8,required:!0,maxLength:1e4}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium text-gray-700 mb-1",children:["Attachments ",e.jsxs("span",{className:"text-xs font-normal text-gray-400",children:["optional — up to ",$," files, ",O," MB each (PDF, Word, images)"]})]}),N.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:N.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-gray-100 text-gray-700 text-xs rounded-full pl-3 pr-1.5 py-1",children:[t.name," ",e.jsxs("span",{className:"text-gray-400",children:["(",(t.size/1024/1024).toFixed(1)," MB)"]}),e.jsx("button",{type:"button","aria-label":`Remove ${t.name}`,onClick:()=>h(i=>i.filter(c=>
1c!==t)),className:"h-4 w-4 rounded-full hover:bg-gray-300 text-gray-500 leading-none",children:"×"})]},`${t.name}-${t.size}`))}),N.length<$&&e.jsxs("label",{className:"block max-w-full",children:[e.jsx("span",{className:"sr-only",children:"Add attachment"}),e.jsx("input",{type:"file",multiple:!0,accept:Y,onChange:t=>{T(t.target.files),t.target.value=""},className:"block w-full text-sm text-gray-500 file:mr-3 file:rounded-lg file:border file:border-gray-300 file:bg-white file:px-3 file:py-1.5 file:text-sm file:font-medium file:text-gray-700 hover:file:bg-gray-50 file:cursor-pointer"})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2 mt-4",children:[e.jsx(S,{type:"submit",variant:"primary",isLoading:M,disabled:!l.trim()||!m.trim()||d===0,children:"Send"}),e.jsx(S,{type:"button",variant:"ghost",onClick:j,disabled:M,children:"Cancel"})]})]})}function K({group:r,onDone:E,onCancel:j}){const l=!r,[x,m]=n.useState(r?.name||""),[A,N]=n.useState(r?.description||""),[h,p]=n.useState(!!r?.isTeam),[b,v]=n.useState(!!r?.isPaid),[D,M]=n.useState(null),[k,w]=n.useState(()=>new Set),[y,T]=n.useState(!1),[d,s]=n.useState(!1),o=P(a=>a.showSuccess),t=P(a=>a.showError),{canFully:i}=z();n.useEffect(()=>{let a=!1;return Promise.all([q.list({status:"active",limit:500}),l?Promise.resolve([]):C.getMembers(r.id)]).then(([u,L])=>{if(a)return;const G=Array.isArray(u)?u:u?.members||u?.data||[];M(G),w(new Set((L||[]).map(H=>H.id)))}).catch(()=>{a||t(R("members"))}),()=>{a=!0}},[]);function c(a){w(u=>{const L=new Set(u);return L.has(a)?L.delete(a):L.add(a),L})}async function f(a){if(a.preventDefault(),!!x.trim()){T(!0);try{const u={name:x.trim(),description:A.trim()||null,memberIds:[...k],isTeam:h,isPaid:h&&b};l?await C.create(u):await C.update(r.id,u),o(l?"List created.":"List updated."),E()}catch(u){t(u.message||B)}finally{T(!1)}}}async function g(){try{await C.remove(r.id),o("List deleted."),E()}catch(a){t(a.message||B)}finally{s(!1)}}return e.jsxs("form",{onSubmit:f,className:"bg-white rounded-xl border border-gray-200 p-6 mb-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-500 uppercase tracking-wide mb-4",children:l?"New List":"Edit List"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(F,{label:"Name",value:x,onChange:a=>m(a.target.value),required:!0,maxLength:80,placeholder:l?"e.g. Voting Board":void 0}),e.jsx(F,{label:"Description",hint:"optional",value:A,onChange:a=>N(a.target.value),maxLength:300}),e.jsxs("label",{className:"flex items-start gap-3 py-1",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5 rounded border-gray-300 text-band-600 focus:ring-band-500 h-5 w-5",checked:h,onChange:a=>p(a.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium text-gray-800",children:"This is a team"}),e.jsx("span",{className:"block text-xs text-gray-500",children:"For people who can do certain jobs, like driving. A Help wanted job can be only for this team. It gives no extra access."})]})]}),h&&e.jsxs("label",{className:"flex items-start gap-3 py-1",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5 rounded border-gray-300 text-band-600 focus:ring-band-500 h-5 w-5",checked:b,onChange:a=>v(a.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium text-gray-800",children:"This team is paid for its jobs"}),e.jsx("span",{className:"block text-xs text-gray-500",children:"For paid work, like driving the trailer. Its Help wanted jobs count no volunteer hours."})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 mb-1",children:"Members"}),e.jsx(W,{members:D,selected:k,onToggle:c,label:"Search members"})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2 mt-4",children:[e.jsx(S,{type:"submit",variant:"primary",isLoading:y,disabled:!x.trim(),children:l?"Create":"Save changes"}),e.jsx(S,{type:"button",variant:"ghost",onClick:j,disabled:y,children:"Cancel"}),!l&&i("groups:manage")&&e.jsx(S,{type:"button",variant:"danger",className:"ml-auto",onClick:()=>s(!0),disabled:y,children:"Delete"})]}),e.jsx(X,{isOpen:d,title:"Delete list?",message:`"${r?.name}" will be deleted. This doesn't affect the members themselves.`,confirmLabel:"Delete",onConfirm:g,onClose:()=>s(!1)})]})}export{oe as GroupsPage,oe 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.