1import{g as L,b as A,c as I,r as l,v as f,t as H,j as e,B as E,E as R}from"./index-_aijvlUq.js";import{P as y}from"./PageHeader-DCofr6qo.js";const c={all_band:"All band members",section_only:"Just my section",private:"Hidden (admins only)"},v={all_band:"Anyone in the band can see this and reach out directly.",section_only:"Only members of your own section can see this. Other band members will see your name but not this contact info.",private:"No band members see this. Only directors, the membership coordinator, and other admins with access still see it."},$=[{key:"email",label:"Email address",helpKey:"contactSharingEmail"},{key:"phone",label:"Phone number",helpKey:"contactSharingPhone"}];function M(){const r=L(),{user:t}=A(),{showSuccess:u,showError:d}=I(),[x,n]=l.useState(!0),[s,i]=l.useState(!1),[m,S]=l.useState(null),[P,w]=l.useState({email:"all_band",phone:"all_band"}),[h,g]=l.useState(null),[b,p]=l.useState(null);l.useEffect(()=>{if(!t?.memberId){n(!1);return}Promise.all([f.get(`/members/${t.memberId}`),t.orgId?f.get(`/organizations/${t.orgId}`):Promise.resolve(null)]).then(([a,o])=>{S(a),g(a.contactSharingEmail??null),p(a.contactSharingPhone??null),o&&w({email:o.defaultContactSharingEmail||"all_band",phone:o.defaultContactSharingPhone||"all_band"})}).catch(()=>d(H("contact sharing settings"))).finally(()=>n(!1))},[t?.memberId,t?.orgId]);async function C(){if(t?.memberId){i(!0);try{await f.put("/members/me",{contactSharingEmail:h,contactSharingPhone:b}),u("Contact sharing settings saved."),S(a=>a&&{...a,contactSharingEmail:h,contactSharingPhone:b})}catch(a){d(a.message||R)}finally{i(!1)}}}if(!t?.memberId)return e.jsx("div",{className:"px-4 pt-3 md:px-0 md:pt-0",children:e.jsxs("div",{className:"max-w-2xl",children:[!r&&e.jsx(y,{title:"Contact Sharing",breadcrumbs:[{label:"Home",to:"/"},{label:"Account"},{label:"Contact Sharing"}]}),e.jsx("p",{className:"text-sm text-gray-600 mt-4",children:"This page is only available to members linked to a band profile."})]})});if(x)return e.jsx("div",{className:"px-4 pt-3 md:px-0 md:pt-0",children:e.jsxs("div",{className:"max-w-2xl",children:[!r&&e.jsx(y,{title:"Contact Sharing",breadcrumbs:[{label:"Home",to:"/"},{label:"Account"},{label:"Contact Sharing"}]}),e.jsx("p",{className:"text-sm text-gray-500 mt-4",children:"Loadingâ¦"})]})});const j=h!==(m?.contactSharingEmail??null)||b!==(m?.contactSharingPhone??null);return e.jsx("div",{className:"px-4 pt-3 md:px-0 md:pt-0",children:e.jsxs("div",{className:"max-w-2xl",children:[!r&&e.jsx(y,{title:"Contact Sharing",subtitle:"Choose who in your band can see your email and phone number.",breadcrumbs:[{label:"Home",to:"/"},{label:"Account"},{label:"Contact Sharing"}]}),e.jsxs("div",{className:"bg-band-50 border border-band-200 rounded-xl p-4 mt-4 text-sm text-band-900",children:[e.jsx("p",{className:"font-semibold mb-1",children:"How this works"}),e.jsx("p",{className:"text-band-800",children:"Pick a setting for each channel below. Your choice overrides the band's default. Directors, the membership coordinator, and other admins with access always see your contact info regardless of these settings â they need it to reach you about rehearsals, performances, and dues."})]}),e.jsx("div",{className:"space-y-4 mt-6",children:$.map(a=>{const o=a.key==="email"?h:b,_=a.key==="email"?g:p,N=P[a.key],k=o||N;return e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-500 uppercase tracking-wide",children:a.label}),e.jsxs("span",{className:"inline-flex items-center px-2.5 py-1 rounded-full text-xs font-medium bg-band-100 text-band-700",children:["Currently: ",c[k]]})]}),e.jsx(D,{name:a.key,value:o,onChange:_,orgDefault:N})]},a.key)})}),e.jsxs("div",{className:"flex gap-2 pt-2 mt-4",children:[e.jsx(E,{onClick:C,disabled:s||!j,isLoading:s,children:"Save changes"}),j&&e.jsx(E,{variant:"ghost",onClick:()=>{g(m?.contactSharingEmail??null),p(m?.contactSharingPhone??null)},disabled:s,children:"Reset"})]})]})})}
1function D({name:r,value:t,onChange:u,orgDefault:d}){const x=[{val:null,title:"Use the band's default",sub:`Currently set to ${c[d]}.`},{val:"all_band",title:c.all_band,sub:v.all_band},{val:"section_only",title:c.section_only,sub:v.section_only},{val:"private",title:c.private,sub:v.private}];return e.jsx("div",{className:"space-y-2",children:x.map(n=>{const s=`${r}-${n.val??"default"}`,i=t===n.val;return e.jsxs("label",{htmlFor:s,className:`flex gap-3 items-start rounded-lg border p-3 cursor-pointer transition-colors ${i?"border-band-400 bg-band-50":"border-gray-200 hover:border-band-300"}`,children:[e.jsx("input",{type:"radio",id:s,name:r,checked:i,onChange:()=>u(n.val),className:"mt-0.5 h-4 w-4 text-band-600 focus:ring-band-500"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:`text-sm font-medium ${i?"text-band-900":"text-gray-900"}`,children:n.title}),e.jsx("div",{className:"text-xs text-gray-500 mt-0.5",children:n.sub})]})]},s)})})}export{M as AccountSharingPage};
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.