1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3838],{1308:function(e,s,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/sms-messages",function(){return t(22674)}])},26054:function(e,s,t){"use strict";t.d(s,{Y:function(){return d}});var i=t(85893),n=t(67294),a=t(37174),r=t(52435),l=t(79381);const d=n.forwardRef(((e,s)=>{let{className:t,...n}=e;const{data:d,isLoading:c,error:o}=r.S.tenantUser.get.useQuery();return c&&!o?(0,i.jsx)("div",{children:(0,i.jsx)(l.g,{active:c})}):"ADMIN"!==(null===d||void 0===d?void 0:d.role)||!d||o?(0,i.jsxs)("div",{className:"bg-background dark:bg-background-10 text-foreground m-4 rounded-md p-6 shadow sm:overflow-hidden",children:[(0,i.jsx)("h1",{className:"mb-1 text-2xl font-medium",children:"Unable to Access Admin"}),(0,i.jsx)("p",{className:"text-sm",children:"This page is only for administrators, but your user role is not administrator. Please try again later. If this issue keeps happening, contact our customer support."})]}):(0,i.jsx)("div",{ref:s,className:(0,a.cn)("container mb-5 max-w-4xl",t),...n})}));d.displayName="AdminPageContainer"},22674:function(e,s,t){"use strict";t.r(s),t.d(s,{default:function(){return R}});var i=t(85893),n=t(40163),a=t(26054),r=t(53766),l=t(55178),d=t(67294),c=t(23279),o=t.n(c),m=t(52435),h=t(26051),x=t(92395),u=t(18922);var p=e=>{let{addRecipients:s}=e;const[t,n]=(0,d.useState)([]),[a,r]=(0,d.useState)(""),{data:l,isFetching:c}=m.S.tenantUser.getAll.useQuery({search:a,sort:{search:"desc"}},{keepPreviousData:!0}),{data:o,isFetching:p}=m.S.tenantUser.getAll.useQuery({ids:t,sort:{firstName:"asc"}},{keepPreviousData:!0});return(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(h.P,{selectFrom:(null===l||void 0===l?void 0:l.users)||[],selectFromIsLoading:c||p,selectedIDs:t,setSelectedIDs:n,search:a,setSearch:r,selectedUsers:(null===o||void 0===o?void 0:o.users)||[]}),(0,i.jsxs)("div",{className:"flex justify-end space-x-4",children:[(0,i.jsx)("div",{children:0!==t.length&&(0,i.jsxs)("div",{className:"mt-1 flex space-x-2 text-sm ",children:[(0,i.jsx)("span",{children:"Add selected users to recipients list"}),(0,i.jsx)(x.DpU,{})]})}),(0,i.jsx)(u.z,{type:"default",size:"tiny",icon:(0,i.jsx)(x.SC9,{}),onClick:()=>{s((null===o||void 0===o?void 0:o.users)||[]),n([])},children:"Add Users"})]})]})},j=t(97366);var f=e=>{let{recipients:s,removeRecipient:t}=e;const n=s.map(((e,s)=>(0,i.jsxs)("tr",{className:s%2!==0?"bg-background-10 text-sm":"text-sm",children:[(0,i.jsxs)("td",{className:"flex p-1",children:[(0,i.jsx)(j.Yt,{user:e,className:"h-5 w-5 text-xs"}),(0,i.jsxs)("p",{children:[e.firstName," ",e.lastName]})]}),(0,i.jsx)("td",{className:"p-1",children:e.location?e.location.label:"N/A"}),(0,i.jsxs)("td",{className:"p-1",children:[e.smsMessagesEnabled&&e.phoneNumber?"Yes":"",e.smsMessagesEnabled&&!e.phoneNumber?"No phone number":"",!e.smsMessagesEnabled&&e.phoneNumber?"SMS disabled":""]}),(0,i.jsx)("td",{className:"flex justify-center",children:(0,i.jsx)(u.z,{type:"default",size:"tiny",icon:(0,i.jsx)(x.UrD,{}),onClick:()=>{t(e.id)}})})]},s)));return(0,i.jsx)("div",{children:(0,i.jsxs)("table",{className:"w-full table-auto border-separate rounded-xl border-2",children:[(0,i.jsx)("thead",{className:"",children:(0,i.jsxs)("tr",{className:"border-separate border-b-2 text-left",children:[(0,i.jsx)("th",{className:"border-b-2 p-1 font-normal",children:"Name"}),(0,i.jsx)("th",{className:"border-b-2 p-1 font-normal",children:"Location"}),(0,i.jsx)("th",{className:"border-b-2 p-1 font-normal",children:"SMS Eligible"}),(0,i.jsx)("th",{className:"border-b-2 p-1 font-normal",children:"Remove"})]})}),(0,i.jsx)("tbody",{children:n})]})})},g=t(62472),b=t(5628),v=t(86501),N=t(77818),S=t(70385),y=t(44886),M=t(96109),w=t(44814),k=t(37174),E=t(42393);function P(e){let{selectFrom:s,selectFromIsLoading:t,autoOpen:n=!1,search:a,setSearch:r,selectedEvents:l,setSelectedEvents:c}=e;const[o,m]=(0,d.useState)(n);function h(e,s){s.stopPropagation(),function(e){c(l.filter((s=>s.id!==e.id)))}(e)}function u(e){return l.some((s=>s.id===e.id))}return(0,i.jsxs)(w.J2,{open:o,onOpenChange:m,children:[(0,i.jsx)(y.Q$,{open:o,placeholder:"Pick Events",children:l.map((e=>(0,i.jsx)(y.Sf,{onClick:s=>h(e,s),className:"gap-2",children:(0,i.jsx)("p",{children:e.title})},e.id)))}),(0,i.jsx)(y.oF,{open:o,children:(0,i.jsxs)(M.mY,{className:"flex gap-3 p-1 pb-3",children:[(0,i.jsx)(M.sZ,{value:a,onValueChange:r,placeholder:"Search Events...",rightIcon:(0,i.jsx)(E.T,{className:(0,k.cn)("relative !bottom-auto !left-auto !right-auto !top-auto ",t?"opacity-100":"opacity-0"),active:!0})}),(0,i.jsxs)(M.e8,{children:[(0,i.jsx)(M.rb,{children:"No Event found"}),(0,i.jsx)(M.fu,{children:null===s||void 0===s?void 0:s.map(((e,s)=>(0,i.jsxs)(M.di,{value:"".concat(e.title," ").concat(s),onSelect:()=>function(e){if(!l)return;const s=l.some((s=>s.id===e.id));c(s?l.filter((s=>s.id!==e.id)):[...l,e])}(e),className:"flex cursor-pointer justify-between",children:[(0,i.jsx)("div",{className:"flex gap-2",children:(0,i.jsx)("p",{className:u(e)?"font-semibold":"",children:e.title})}),(0,i.jsx)(x.NOm,{className:(0,k.cn)("mr-2 h-4 w-4",u(e)?"opacity-100":"opacity-0")})]},e.id)))})]})]})})]})}var A=e=>{let{addRecipients:s}=e;const{client:t}=m.S.useContext(),[n,a]=(0,d.useState)([]),[r,l]=(0,d.useState)(""),[c,o]=(0,d.useState)(!1),{data:h,isLoading:p}=m.S.posts.searchPostsByTitle.useQuery({query:r,limit:20,postType:S.PostType.event},{keepPreviousData:!0}),j=async e=>{try{const i=(await t.reactions.getAll.query({limit:1e3,forType:"post",forId:e.id,types:["going"],includePhoneInfo:!0,includeLocation:!0}
1)).reactions.map((e=>e.creator));s(i)}catch(i){console.error(i),v.ZP.error("There was an error while adding attendees to recipients list")}};return(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(P,{selectFrom:(null===h||void 0===h?void 0:h.posts)||[],selectFromIsLoading:p,search:r,setSearch:l,selectedEvents:n,setSelectedEvents:a}),(0,i.jsxs)("div",{className:"flex justify-end space-x-4",children:[(0,i.jsx)("div",{children:0!==n.length&&(0,i.jsxs)("div",{className:"mt-1 flex space-x-2 text-sm ",children:[(0,i.jsx)("span",{children:"You need to add selected users from the events to recipients list"}),(0,i.jsx)(x.DpU,{})]})}),(0,i.jsx)(u.z,{type:"default",size:"tiny",icon:(0,i.jsx)(x.SC9,{}),loading:c,onClick:()=>{(async()=>{o(!0);for(const e of n)await j(e);a([]),o(!1)})()},children:"Add Users"})]})]})},C=t(39188),D=t(11163);var T=()=>{const e=(0,D.useRouter)(),s=(0,b.Z)(),[t,n]=(0,d.useState)(""),a=o()(n,300),[r,l]=(0,d.useState)([]),[c,h]=(0,d.useState)([]);(0,d.useEffect)((()=>{h(r.filter((e=>e.smsMessagesEnabled&&e.phoneNumber)))}),[r]);const j=e=>{l((s=>{const t=e.filter((e=>!s.some((s=>s.id===e.id))));return[...s,...t]}))},{mutate:S,isLoading:y}=m.S.smsRouter.sendSMSMessage.useMutation({onSuccess(s){v.ZP.success("SMS Messages dispatched"),e.push((0,C.Y$)(s.id))},onError(e){v.ZP.error(e.message)}});return(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-foreground-10 mb-3 mt-1 text-sm",children:"Compose new message to your members. Please avoid using special characters. Long messages will be split into multiple SMS. Please select recipients below."}),(0,i.jsx)("textarea",{id:"smsMessageBody",name:"smsMessageBody",rows:3,className:"text-foreground focus-within:border-link focus-within:ring-link mt-1 block w-full rounded-md shadow-sm sm:text-sm",onChange:e=>{a(e.target.value)}}),(0,i.jsxs)("div",{className:"text-foreground-10 mb-3 mt-1 text-right text-sm",children:[160*Math.ceil(t.length/160)-t.length||160," ","/ ",Math.ceil(t.length/160)," SMS"]}),(0,i.jsxs)("div",{className:"flex items-center justify-between pb-4 pt-0",children:[(0,i.jsxs)("div",{className:"flex space-x-2",children:[(0,i.jsxs)("div",{children:["Eligible SMS recipients: ",c.length]}),(0,i.jsx)("span",{className:"",children:(0,i.jsx)(N.b,{infoFor:"",children:"If the user doe not have phone details filled in or has SMS messages disabled they are not eligible for SMS message."})})]}),(0,i.jsx)(u.z,{type:"default",size:"tiny",icon:(0,i.jsx)(x.h9l,{}),disabled:0===c.length||0===t.length||c.length>3e4,loading:y,onClick:async()=>{await s({title:"Confirm sending SMS",description:"You will send this message to ".concat(c.length," members. You will be billed as per your integration pricing. Are you sure?"),confirmText:"Send SMS"})&&S({message:t,recipientsIds:c.map((e=>e.id))})},children:"Send SMS"})]}),(0,i.jsx)(g.i,{}),(0,i.jsxs)("div",{className:"pt-4",children:[(0,i.jsx)("label",{className:"text-foreground text-md block",children:"Add recipients by Username"}),(0,i.jsx)(p,{addRecipients:j}),(0,i.jsx)("label",{className:"text-foreground text-md block",children:"Add recipients by Event"}),(0,i.jsx)(A,{addRecipients:j})]}),(0,i.jsx)("label",{className:"text-foreground block text-lg ",children:"Selected recipients"}),(0,i.jsx)("div",{children:(0,i.jsx)(f,{recipients:r,removeRecipient:e=>{l((s=>s.filter((s=>s.id!==e))))}})})]})},I=t(2962),L=t(30120);var _=()=>{const e=(0,D.useRouter)(),{data:s,isFetching:t}=m.S.smsRouter.getAllSMSMessages.useQuery();if(t)return(0,i.jsx)("div",{children:"Loading..."});if(!s)return(0,i.jsx)("div",{children:"No messages found"});const n=s.map(((s,t)=>(0,i.jsxs)("tr",{className:"border-2 text-sm",children:[(0,i.jsx)("td",{className:"border-2 p-1",children:L.ou.fromJSDate(s.createdAt).setLocale("en-US").toLocaleString(L.ou.DATETIME_MED)}),(0,i.jsx)("td",{className:"h-[3.5rem] overflow-hidden overflow-ellipsis border-2 p-1",children:(0,i.jsx)("div",{className:"line-clamp-2 whitespace-normal",children:s.messageText})}),(0,i.jsx)("td",{className:"flex items-center justify-center p-1",children:(0,i.jsx)(u.z,{onClick:()=>e.push((0,C.Y$)(s.id)),children:"Details"})})]},t)));return(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{children:"Your Past Messages"}),(0,i.jsxs)("table",{className:"w-full table-fixed border-2",children:[(0,i.jsx)("thead",{className:"border-2",children:(0,i.jsxs)("tr",{children:[(0,i.jsx)("td",{className:"w-[120px] border-2 p-1",children:"Date"}),(0,i.jsx)("td",{className:"border-2 p-1",children:"Message"}),(0,i.jsx)("td",{className:"w-[80px] border-2 p-1",children:"Details"})]})}),(0,i.jsx)("tbody",{children:n})]})]})};const F=()=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(I.PB,{title:"Send SMS Messages",noindex:!0}),(0,i.jsx)(a.Y,{children:(0,i.jsx)("main",{children:(0,i.jsx)(r.Zb,{className:"sm:overflow-hidden",edgeToEdgeMobile:!0,children:(0,i.jsxs)(r.aY,{className:"space-y-4 ",children:[(0,i.jsx)("div",{className:"flex items-center gap-2",children:(0,i.jsx)("h1",{className:"text-xl font-medium",children:"Send SMS Messages to users"})}),(0,i.jsxs)(l.m,{type:"underlined",size:"large",scrollable:!0,children:[(0,i.jsx)(l.m.Panel,{id:"sendSMS",label:"New SMS",children:(0,i.jsx)(T,{})}),(0,i.jsx)(l.m.Panel,{id:"SMSmessages",label:"SMS History",children:(0,i.jsx)(_,{})})]})]})})})})]});F.getLayout=function(e){return(0,i.jsx)(n.Z,{children:e})};var R=F}},function(e){e.O(0,[6911,3662,1664,108,5216,9332,8394,2039,1818,8214,7913,6309,9774,2888,179],(function(){return s=1308,e(e.s=s);var s}));var s=e.O();_N_E=s}]);
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.