1import{r as u,c as S,b as w,j as e,M as k,B as v,g as C,h as E,s as M,L as N,d as A}from"./index-_aijvlUq.js";import{P}from"./PageHeader-DCofr6qo.js";import{u as O}from"./useNotificationStore-IfNXEQfW.js";import"./notifications-B26coFA7.js";function F({open:n,orgName:o,onClose:c,onConsent:g}){const[d,m]=u.useState(!1),[x,i]=u.useState(!1),b=S(a=>a.showError),y=w(a=>a.recordSmsConsent);async function h(){if(d){i(!0);try{await y(),g()}catch(a){b(a.message||"Could not record your SMS consent. Please try again.")}finally{i(!1)}}}function p(){m(!1),c()}const f=o||"your organization";return e.jsx(k,{isOpen:n,onClose:p,title:"Receive SMS notifications?",children:e.jsxs("div",{className:"space-y-4 text-sm text-gray-700",children:[e.jsxs("p",{children:["By opting in, you agree to receive automated texts from Backstage Baton on behalf of"," ",e.jsx("strong",{children:f}),": rehearsal reminders, performance updates, and announcements. Frequency varies, ~2-8 msgs/month. Msg & data rates may apply. Reply ",e.jsx("strong",{children:"STOP"})," to unsubscribe, ",e.jsx("strong",{children:"HELP"})," for help. Privacy:"," ",e.jsx("a",{href:"https://app.backstagebaton.com/privacy#sms-messaging",target:"_blank",rel:"noopener noreferrer",className:"text-brand-primary hover:underline break-all",children:"https://app.backstagebaton.com/privacy#sms-messaging"})]}),e.jsxs("label",{className:"flex items-start gap-2 pt-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:d,onChange:a=>m(a.target.checked),className:"mt-0.5 h-4 w-4 rounded border-gray-300 text-brand-primary focus:ring-brand-primary"}),e.jsx("span",{className:"text-sm text-gray-800",children:"I agree to receive SMS messages from Backstage Baton as described above."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-gray-100 mt-4",children:[e.jsx(v,{variant:"secondary",onClick:p,disabled:x,children:"Cancel"}),e.jsx(v,{onClick:h,disabled:!d||x,isLoading:x,children:"Turn on text reminders"})]})]})})}const B=[{key:"member",label:"Members"},{key:"performance",label:"Performances"},{key:"rehearsal",label:"Rehearsals"},{key:"music",label:"Music"},{key:"setlist",label:"Music"},{key:"birthday",label:"System"}];function I(n){const o=n.split(".")[0];return B.find(g=>g.key===o)?.label||"Other"}function j({checked:n,onChange:o,label:c}){return e.jsx("button",{type:"button",role:"switch","aria-checked":n,"aria-label":c,onClick:()=>o(!n),className:"inline-flex items-center justify-center px-1 -mx-1 py-3 -my-3 rounded-full focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-primary",children:e.jsx("span",{className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${n?"bg-brand-primary":"bg-gray-300"}`,children:e.jsx("span",{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-white transition-transform ${n?"translate-x-4.5":"translate-x-0.5"}`})})})}function $(){const n=C(),{preferences:o,loading:c,loadPreferences:g,toggleAndSave:d}=O(),m=w(s=>s.user),x=E(s=>s.currentOrg),i=M(x?.planTier,"sms"),b=S(s=>s.showError),[y,h]=u.useState(null);u.useEffect(()=>{g()},[]);async function p(s,r,t){if(r==="smsEnabled"&&t===!0&&!m?.smsConsentAt){h({eventKe
1y:s,nextValue:t});return}try{await d(s,r,t)}catch(l){b(l.message||"Failed to save preference")}}async function f(){const s=y;if(h(null),s)try{await d(s.eventKey,"smsEnabled",s.nextValue)}catch(r){b(r.message||"Failed to save preference")}}const a={};for(const s of o){const r=I(s.eventKey);a[r]||(a[r]=[]),a[r].push(s)}return e.jsxs("div",{className:"px-4 pt-3 md:px-0 md:pt-0",children:[!n&&e.jsx(P,{title:"Notification Preferences",subtitle:"Control how and when you receive notifications",breadcrumbs:[{label:"Home",to:"/"},{label:"Account"},{label:"Notifications"}],actions:e.jsx(N,{to:"/account/notifications/history",className:"text-sm text-brand-primary hover:underline",children:"View history"})}),n&&e.jsx("p",{className:"mb-3 text-sm",children:e.jsx(N,{to:"/account/notifications/history",className:"text-brand-primary hover:underline",children:"View history"})}),c&&o.length===0?e.jsx("p",{className:"text-gray-500 text-sm",children:"Loading preferences..."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bg-white rounded-lg border border-gray-200 overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 sm:px-4 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Event"}),e.jsx("th",{className:"px-1 sm:px-4 py-3 text-center text-xs font-semibold text-gray-500 uppercase tracking-wider w-14 sm:w-20",children:"Email"}),i&&e.jsx("th",{className:"px-1 sm:px-4 py-3 text-center text-xs font-semibold text-gray-500 uppercase tracking-wider w-14 sm:w-20",children:"SMS"}),e.jsx("th",{className:"px-1 sm:px-4 py-3 text-center text-xs font-semibold text-gray-500 uppercase tracking-wider w-14 sm:w-20",children:"In-App"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100",children:Object.entries(a).map(([s,r])=>e.jsxs(u.Fragment,{children:[e.jsx("tr",{children:e.jsx("td",{colSpan:i?4:3,className:"px-4 py-2 bg-gray-50",children:e.jsx("span",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider",children:s})})}),r.map(t=>e.jsxs("tr",{children:[e.jsxs("td",{className:"px-3 sm:px-4 py-3",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:t.label}),t.description&&e.jsx("p",{className:"text-xs text-gray-500",children:t.description})]}),e.jsx("td",{className:"px-1 sm:px-4 py-3 text-center",children:e.jsx(j,{checked:t.emailEnabled,onChange:l=>p(t.eventKey,"emailEnabled",l),label:`Email for ${t.label}`})}),i&&e.jsx("td",{className:"px-1 sm:px-4 py-3 text-center",children:e.jsx(j,{checked:t.smsEnabled,onChange:l=>p(t.eventKey,"smsEnabled",l),label:`SMS for ${t.label}`})}),e.jsx("td",{className:"px-1 sm:px-4 py-3 text-center",children:e.jsx(j,{checked:t.inAppEnabled,onChange:l=>p(t.eventKey,"inAppEnabled",l),label:`In-App for ${t.label}`})})]},t.eventKey))]},s))})]})}),e.jsx("p",{className:"mt-3 text-xs text-gray-400",children:"Changes save automatically."}),i&&m?.smsConsentAt&&e.jsxs("p",{className:"mt-3 text-xs text-gray-400",children:["You agreed to receive SMS messages on ",A(m.smsConsentAt),". Reply STOP to any message to unsubscribe, or turn off the SMS toggles above."]})]}),e.jsx(F,{open:!!y,orgName:x?.name,onClose:()=>h(null),onConsent:f})]})}export{$ as NotificationPreferencesPage};
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.