(window.webpackJsonp=window.webpackJsonp||[]).push([[15],{381:function(e,a,t){"use strict";t.r(a);var n=t(18),s=t.n(n),r=t(0),l=t.n(r),c=t(1),m=t.n(c),o=t(382),i=t(33),u=t(40),d=t.n(u),p=t(54),f=t(27),E=t.n(f),g=t(22),b=t(31),N=t(2),v=t(24),h=t(81),S=t(52),y=t(46),C=t(60),M=t(20),k=function(e){var a=Object(r.useState)([]),t=s()(a,2),n=t[0],c=t[1],m=Object(r.useState)([]),o=s()(m,2),i=o[0],u=o[1],f=Object(r.useState)(0),k=s()(f,2),D=k[0],P=k[1],O=Object(r.useState)([]),j=s()(O,2),x=j[0],I=j[1],w=Object(r.useState)("groups"),T=s()(w,2),L=T[0],A=T[1],F=Object(r.useState)(!1),R=s()(F,2),G=R[0],V=R[1],_=Object(r.useState)(""),B=s()(_,2),q=B[0],U=B[1],W=Object(r.useState)(""),Y=s()(W,2),Q=Y[0],z=Y[1],J=Object(r.useState)([]),$=s()(J,2),H=$[0],K=$[1],X=Object(r.useState)([]),Z=s()(X,2),ee=Z[0],ae=Z[1],te=Object(r.useState)(""),ne=s()(te,2),se=ne[0],re=ne[1],le=Object(r.useState)(!0),ce=s()(le,2),me=ce[0],oe=ce[1],ie=Object(b.a)(),ue=ie.register,de=ie.handleSubmit,pe=ie.errors,fe=ie.getValues,Ee=ie.formState,ge=ie.unregister,be=n.filter((function(e){return e.contactsCount>0})).map((function(e){return{label:e.name+" ("+e.contactsCount+")",value:e.id,data:e}})),Ne=i.map((function(e){return{label:e.firstName+" "+(e.lastName?e.lastName:""),value:e.id,data:e}}));Object(r.useEffect)((function(){ve()}),[]);var ve=function(){h.a.loadSmsDevices().then((function(e){e.success&&I(e.result.data.filter((function(e){return!1===e.isDeleted})))})),y.a.loadAllGroups().then((function(e){e.success&&c(e.result.data)})),S.a.loadAllContacts().then((function(e){e.success&&u(e.result.data)}))},he=function(e){pe.contacts=e&&e.length?null:{message:"Please select at least one of the contacts"},ae(e)},Se=function(e){pe.groups=e&&e.length?null:{message:"Please select at least one contact groups"},K(e)},ye=function(e){switch(e){case"groups":ge("contacts"),A("groups");break;case"contacts":ge("groups"),A("contacts");break;default:ge("groups"),ge("contacts"),A("numbers")}};return l.a.createElement("form",{onSubmit:de((function(a,t){V(!0),a.groups=H.map((function(e){return e.data})),a.userContacts=ee.map((function(e){return e.data})),C.a.createNewSms(a).then((function(a){a.success&&(E.a.publish("SMS:ADDED",a.result.data),g.a.success(a.message,{position:"top-right"}),V(!1),t.target.reset(),K([]),ae([]),e.cancel())}),(function(e){g.a.error(e.message,{position:"top-right"}),V(!1)}))}))},l.a.createElement("div",{className:"modal-body "+(G?"spinner pl-0":"")},l.a.createElement(N.a,{isLoading:G}),l.a.createElement("div",{className:"form-group"},l.a.createElement("label",{className:"form-label"},"Send SMS To:"),l.a.createElement("div",{className:"selectgroup w-100"},l.a.createElement("label",{className:"selectgroup-item"},l.a.createElement("input",{type:"radio",name:"transportation",defaultValue:"groups",className:"selectgroup-input",defaultChecked:"groups"===L}),l.a.createElement("span",{className:"selectgroup-button selectgroup-button-icon",onClick:function(){return ye("groups")}},l.a.createElement("i",{className:"fa fa-address-book"}),"  Contact Groups")),l.a.createElement("label",{className:"selectgroup-item"},l.a.createElement("input",{type:"radio",name:"transportation",defaultValue:"contacts",className:"selectgroup-input",defaultChecked:"contacts"===L}),l.a.createElement("span",{className:"selectgroup-button selectgroup-button-icon",onClick:function(){return ye("contacts")}},l.a.createElement("i",{className:"fa fa-users"}),"  Selected Contacts")),l.a.createElement("label",{className:"selectgroup-item"},l.a.createElement("input",{type:"radio",name:"transportation",defaultValue:"numbers",className:"selectgroup-input",defaultChecked:"numbers"===L}),l.a.createElement("span",{className:"selectgroup-button selectgroup-button-icon",onClick:function(){return ye("numbers")}},l.a.createElement("i",{className:"fas fa-mobile"}),"  Specified Phone Numbers")))),l.a.createElement("div",{className:"row"},l.a.createElement("div",{className:"col-lg-4"},l.a.createElement("div",{className:"form-group"},l.a.createElement("label",{className:"form-control-label",htmlFor:"input-device"},"Choose Device:"),l.a.createElement("select",{id:"input-device",name:"smsDeviceId",className:"custom-select"+M.a.checkValadity("smsDeviceId",pe,Ee),ref:ue({required:"Please select a SMS Device"}),onChange:function(e){return z(e.target.value)}},l.a.createElement("option",{key:"opt-no-device",value:""},"Select SMS Device"),x.filter((function(e){return e.isActive})).map((function(e){return l.a.createElement("option",{key:e.uuid,value:e.uuid},e.deviceName)}))),l.a.createElement("div",{className:"help-block"},l.a.createElement(v.a,{error:pe.smsDeviceId})))),l.a.createElement("div",{className:"col-lg-4"},l.a.createElement("div",{className:"form-group"},l.a.createElement("label",{className:"form-control-label",htmlFor:"input-device"},"SIM Card Options:"),l.a.createElement("select",{id:"input-device",name:"smsSimCardOption",className:"custom-select"+M.a.checkValadity("smsSimCardOption",pe,Ee),ref:ue({required:"Please select a SMS Device"}),onChange:function(e){return re(e.target.value)}},l.a.createElement("option",{value:""},"Select SMS Device"),l.a.createElement("option",{value:"AUTO_SELECT"},"Auto Select SIM Card"),l.a.createElement("option",{value:"DEFAULT"},"Default SIM Card"),l.a.createElement("option",{value:"SELECTED"},"Selected SIM Card")),l.a.createElement("div",{className:"help-block"},l.a.createElement(v.a,{error:pe.smsSimCardOption})))),"SELECTED"===se?l.a.createElement("div",{className:"col-lg-4"},l.a.createElement("div",{className:"form-group"},l.a.createElement("label",{className:"form-control-label",htmlFor:"input-sim-card"},"Choose SIM Card:"),l.a.createElement("select",{id:"input-sim-card",name:"simCardId",ref:ue({required:"Please select the SIM card."}),className:"custom-select"+M.a.checkValadity("simCardId",pe,Ee)},function(e){var a=l.a.createElement("option",{key:"opt-none",value:""},"No SIM Cards");if(e){var t=x.find((function(a){return a.uuid===e}));t&&(a=[l.a.createElement("option",{key:"opt-select",value:""},"Select SIM Cards")].concat(d()(t.cards.filter((function(e){return e.isActive&&!e.isDeleted})).map((function(e){return l.a.createElement("option",{key:e.uuid,value:e.uuid},e.displayName)})))))}return a}(Q)),l.a.createElement("div",{className:"help-block"},l.a.createElement(v.a,{error:pe.simCardId})))):""),l.a.createElement("div",{className:"row"},l.a.createElement("div",{className:"col-lg-8"},l.a.createElement("div",{className:"form-group"},l.a.createElement("label",{className:"form-control-label",htmlFor:"input-title"},"Message Title:"),l.a.createElement("input",{type:"text",id:"input-title",name:"title",placeholder:"Message title",className:"form-control"+M.a.checkValadity("title",pe,Ee),tabIndex:"1",ref:ue({required:"Please enter your Message Title.",minLength:{value:6,message:"Message Title should be minimum of 6 characters."}})}),l.a.createElement("div",{className:"help-block"},l.a.createElement(v.a,{error:pe.title})))),l.a.createElement("div",{className:"col-lg-4"},l.a.createElement("div",{className:"form-group"},l.a.createElement("label",{className:"form-control-label",htmlFor:"input-type"},"Choose SMS Type:"),l.a.createElement("select",{id:"input-type",name:"smsType",className:"custom-select"+M.a.checkValadity("smsType",pe,Ee),ref:ue({required:"Please select a Message Type"})},l.a.createElement("option",{key:"opt-no-device",value:""},"Select Message Type"),l.a.createElement("option",{key:"Business",value:"Business"},"Business"),l.a.createElement("option",{key:"Promotion",value:"Promotion"},"Promotion"),l.a.createElement("option",{key:"Offer",value:"Offer"},"Offer"),l.a.createElement("option",{key:"Wishes",value:"Wishes"},"Wishes"),l.a.createElement("option",{key:"Notification",value:"Notification"},"Notification"),l.a.createElement("option",{key:"Others",value:"Others"},"Others")),l.a.createElement("div",{className:"help-block"},l.a.createElement(v.a,{error:pe.smsType})))),l.a.createElement("div",{className:"col-lg-12"},l.a.createElement("div",{className:"form-group"},l.a.createElement("label",{htmlFor:"contents",className:"form-control-label mb-0"},"Message Body:"),l.a.createElement("div",{className:"mt-0 mb-2"},l.a.createElement("span",{className:"text-primary"},l.a.createElement("strong",null,l.a.createElement("i",{className:"fa fa-info-circle"})," Quick Tip:"," "),"You can customize the message using placeholders by clicking the ones below the message box.")),l.a.createElement("textarea",{name:"contents",rows:"4",placeholder:"Write your message here ...",className:"form-control"+M.a.checkValadity("contents",pe,Ee),tabIndex:"1",value:q,onChange:function(e){U(e.target.value),P(fe().contents.length)},ref:ue({required:"Please enter your Message Body.",minLength:{value:10,message:"Message Body should be minimum of 10 characters."}})}),l.a.createElement("div",{className:"help-block"},l.a.createElement(v.a,{error:pe.contents})),l.a.createElement("div",{className:"bg-black pt-2"},l.a.createElement("span",null,l.a.createElement("strong",null,"Placeholders:")),l.a.createElement("span",{className:"float-right"},l.a.createElement("strong",null,l.a.createElement("span",{className:D>10&&D<=160?"text-success":"text-warning"},"Characters:"," "," ",D),l.a.createElement("span",{className:"text-light"}," ","|"," "),l.a.createElement("span",{className:"text-danger"},Math.ceil(D/160).toFixed(0)," Message(s)"))),l.a.createElement("div",{className:"mt-1"},l.a.createElement("span",{className:"badge pointer badge-primary pl-3 pr-3 pb-2 mr-2 mb-2",onClick:function(e){e.preventDefault(),U(q+" {firstName}")}},"First Name"),l.a.createElement("span",{className:"badge pointer badge-secondary pl-3 pr-3 pb-2 mr-2 mb-2",onClick:function(e){e.preventDefault(),U(q+"{lastName}")}},"Last Name"),l.a.createElement("span",{className:"badge pointer badge-warning pl-3 pr-3 pb-2 mr-2 mb-2",onClick:function(e){e.preventDefault(),U(q+" {senderName}")}},"Sender Name"),l.a.createElement("span",{className:"badge pointer badge-success pl-3 pr-3 pb-2 mr-2 mb-2",onClick:function(e){e.preventDefault(),U(q+" {senderEmail}")}},"Sender Email"))))),function(){if(!L)return"";var e="";switch(L){case"groups":e=l.a.createElement("div",{className:"col-lg-12"},l.a.createElement("div",{className:"form-group"},l.a.createElement("label",{htmlFor:"groups",className:"form-control-label mb-0"},"Select Groups:"),l.a.createElement("div",{className:"mt-0 mb-2"},l.a.createElement("span",{className:"text-primary"},l.a.createElement("strong",null,l.a.createElement("i",{className:"fa fa-info-circle"})," Info:"," ")," ","Choose the Group(s) to which this SMS message needs to be sent.")),l.a.createElement(p.a,{id:"groups",name:"groups",isMulti:!0,closeMenuOnSelect:!1,placeholder:"Select Messaging Groups",onChange:Se,options:be||[],value:H,ref:ue({name:"groups"},{validate:function(){return!(!H||!H.length)||"Please select at least one contact groups"}})}),l.a.createElement("div",{className:"help-block"},l.a.createElement(v.a,{error:pe.groups}))));break;case"contacts":ge("groups"),e=l.a.createElement("div",{className:"col-lg-12"},l.a.createElement("div",{className:"form-group"},l.a.createElement("label",{htmlFor:"contacts",className:"form-control-label mb-0"},"Select Contacts:"),l.a.createElement("div",{className:"mt-0 mb-2"},l.a.createElement("span",{className:"text-primary"},l.a.createElement("strong",null,l.a.createElement("i",{className:"fa fa-info-circle"})," Info:"," ")," ","Choose the Contact(s) to which this SMS message needs to be sent.")),l.a.createElement(p.a,{id:"contacts",name:"contacts",isMulti:!0,options:Ne,closeMenuOnSelect:!1,placeholder:"Search Messaging Contacts",onChange:he,value:ee,ref:ue({name:"contacts"},{validate:function(){return!(!ee||!ee.length)||"Please select at least one of the contacts"}})}),l.a.createElement("div",{className:"help-block"},l.a.createElement(v.a,{error:pe.contacts}))));break;case"numbers":ge("groups"),ge("contacts"),e=l.a.createElement("div",{className:"col-lg-12"},l.a.createElement("div",{className:"form-group"},l.a.createElement("label",{htmlFor:"recepients",className:"form-control-label"},"Recepients:"),l.a.createElement("div",{className:"mt-0 mb-2"},l.a.createElement("span",{className:"text-primary"},l.a.createElement("i",{className:"fa fa-info-circle"})," Info:"," ",' "+" will be added automatically.')),l.a.createElement("input",{id:"recepients",name:"recepients",placeholder:"Eg. 977 9849038932, 977 8743987843",className:"form-control"+M.a.checkValadity("recepients",pe,Ee),ref:ue({required:"Please enter your recepients.",pattern:{value:/^\d{9,13}(, \d{9,13})*$/i,message:"Each recepient must be separated by comma(,)"}})}),l.a.createElement("div",{className:"help-block"},l.a.createElement(v.a,{error:pe.recepients}))));break;default:e=l.a.createElement("div",{className:"text-danger"},"Recepient(s) is required.")}return e}(),l.a.createElement("div",{className:"col-lg-12"},l.a.createElement("div",{className:"form-group"},l.a.createElement("div",{className:"form-control-label"},l.a.createElement("strong",null,"Save as Draft Message"),l.a.createElement("div",{className:"mt-0 mb-2"},l.a.createElement("span",{className:"text-primary"},l.a.createElement("strong",null,l.a.createElement("i",{className:"fa fa-info-circle"})," Tip:"," "),"Saving the message as ",l.a.createElement("strong",null,"Draft Message"),", you can edit it later, where will not be editable."))),l.a.createElement("label",{className:"custom-switch mt-0 pl-0"},l.a.createElement("input",{type:"checkbox",name:"isInDraft",value:me,className:"custom-switch-input",defaultChecked:me,ref:ue()}),l.a.createElement("div",{className:"help-block"},l.a.createElement(v.a,{error:pe.isInDraft})),l.a.createElement("span",{className:"custom-switch-indicator mt-2",onClick:function(){return oe(!me)}}),l.a.createElement("span",{className:"custom-switch-description mt-2",onClick:function(){return oe(!me)}},me?"Yes, Save as Draft Messsage.":"Save as final Message.")))))),l.a.createElement("div",{className:"modal-footer bg-whitesmoke"},l.a.createElement("div",{className:"text-left"},l.a.createElement("button",{className:"btn btn-lg btn-primary mr-2",type:"submit"},me?"Save as Draft Message":"Save Messsage & Process Later"),l.a.createElement("button",{className:"btn btn-lg btn-danger mr-2",type:"buton","data-dismiss":"modal",onClick:e.cancel},"Cancel"))))};k.propTypes={history:m.a.any,cancel:m.a.func};var D=Object(i.g)(l.a.memo(k)),P=t(82),O=t(16),j=function(e){var a=Object(r.useState)(!1),t=s()(a,2),n=t[0],c=t[1],m=Object(r.useState)(e.smsMessage),o=s()(m,1)[0];return l.a.createElement("tr",null,l.a.createElement("td",null,M.a.truncateString(o.title,30)),l.a.createElement("td",{className:"text-center"},l.a.createElement("span",{className:"badge custom-badge badge-primary"},o.smsType.toUpperCase())),l.a.createElement("td",{className:"text-center"},o.senderDevice.deviceName),l.a.createElement("td",{className:"text-center"},"SELECTED_SIM_CARD"===o.simCardOption?l.a.createElement("span",{className:"badge custom-badge badge-"+("Ncell"===o.senderSimCard.carrierName?"primary":"info")},o.senderSimCard.carrierName.toUpperCase()):l.a.createElement("span",{className:"text-info"},l.a.createElement("i",{className:"fas fa-check-circle"})," ",M.a.capatalize(o.simCardOption))),l.a.createElement("td",{className:"text-center"},l.a.createElement("div",{className:"badge badge-"+(o.isInDraft?"success":"info")},o.isInDraft?"Yes":"No")),l.a.createElement("td",{className:"text-center"},o.createdDate),l.a.createElement("td",null,"NEWLY_CREATED"===o.status&&l.a.createElement("span",{className:"btn btn-primary btn btn-sm text-small mr-1",title:"Send for Processing",onClick:function(a){return t=a,n=o.uuid,t.preventDefault(),c(!0),void C.a.startSmsProcessing(n).then((function(a){a.success&&(g.a.success(a.message,{position:"top-right"}),e.onDeleted(n))}),(function(e){g.a.error(e.message,{position:"top-right"})})).finally((function(){c(!1)}));var t,n}},n?l.a.createElement("span",{className:"spinner-grow spinner-grow-sm"}):l.a.createElement("span",{className:"fa fa-paper-plane"})," "),l.a.createElement(O.b,{className:"btn btn-info mr-1 btn-sm text-small",title:"View Detail",to:"/dashboard/sms-messages/"+o.uuid+"/view"},l.a.createElement("i",{className:"fas fa-eye"})),o.isInDraft&&l.a.createElement(O.b,{className:"btn btn-success mr-1 btn-sm text-small",title:"Edit Message",to:"/dashboard/sms-messages/"+o.uuid+"/edit"},l.a.createElement("i",{className:"far fa-edit"})),l.a.createElement("a",{className:"btn btn-danger btn-sm text-small",href:"#",title:"DeleteMessage",onClick:function(a){return t=a,n=o.uuid,t.preventDefault(),c(!0),void C.a.deleteSmsById(n).then((function(a){c(!1),a.success&&(g.a.success(a.message,{position:"top-right"}),e.onDeleted(n))}));var t,n}},l.a.createElement("i",{className:"fas fa-trash"}))))};j.propTypes={history:m.a.any,smsMessage:m.a.object.isRequired,onDeleted:m.a.func.isRequired};var x=Object(i.g)(l.a.memo(j)),I=window.console,w=function(){var e=Object(r.useState)(10),a=s()(e,1)[0],t=Object(r.useState)(!1),n=s()(t,2),c=n[0],m=n[1],o=Object(r.useState)(0),i=s()(o,2),u=i[0],d=i[1],p=Object(r.useState)({count:0,items:[]}),f=s()(p,2),g=f[0],b=f[1],v=Object(r.useState)({class:"primary",label:"Newly Created",status:"NEWLY_CREATED"}),h=s()(v,2),S=h[0],y=h[1];Object(r.useEffect)((function(){return D(),function(){E.a.clearAllSubscriptions()}}),[]);var M,k,D=function(){E.a.subscribe("SMS:ADDED",(function(e,a){I.log(a),d((function(a){"SMS:ADDED"===e&&P("NEWLY_CREATED",a)}))})),P("NEWLY_CREATED",u)},P=function(e,t){m(!0),C.a.loadPaginatedSmsMessages(e,t,a).then((function(e){m(!1),e.success&&(d(t),b(e.result.data))}),(function(e){m(!1),I.log(e.message)}))},O=function(e){b({count:g.count--,items:g.items.filter((function(a){return a.uuid!==e}))})},j=function(e,a){e.preventDefault(),a.status!==S.status&&(P(a.status,0),y(a))};return l.a.createElement("div",{className:"card card-"+S.class},l.a.createElement("div",{className:"card-header"},l.a.createElement("div",{className:"mr-2 mb-2",onClick:function(e){return j(e,{class:"primary",status:"NEWLY_CREATED",label:"Newly Created"})}},l.a.createElement("a",{className:"btn btn-block text-left note-btn"+("Newly Created"===S.label?" btn-primary":" btn-outline-primary"),href:"#"},l.a.createElement("span",{className:"badge badge-secondary"},l.a.createElement("i",{className:"fa fa-envelope"}))," "," All Newly Added")),l.a.createElement("div",{className:"mr-2 mb-2",onClick:function(e){return j(e,{class:"info",status:"SENT_FOR_PROCESSING",label:"Queued"})}},l.a.createElement("a",{className:"btn btn-block text-left note-btn"+("All Scheduled"===S.label?" btn-info":" btn-outline-info"),href:"#"},l.a.createElement("span",{className:"badge badge-info"},l.a.createElement("i",{className:"fa fa-ellipsis-h"}))," "," Ready to Process Messages")),l.a.createElement("div",{className:"mr-2 mb-2",onClick:function(e){return j(e,{class:"warning",status:"BEING_PROCESSED",label:"Being Processed"})}},l.a.createElement("a",{className:"btn btn-block text-left note-btn"+("Being Processed"===S.label?" btn-warning":" btn-outline-warning"),href:"#"},l.a.createElement("span",{className:"badge badge-warning"},l.a.createElement("i",{className:"fa fa-envelope-open"}))," "," Being Processed")),l.a.createElement("div",{className:"mr-2 mb-2",onClick:function(e){return j(e,{class:"success",status:"PROCESSING_COMPLETE",label:"Processing Complete"})}},l.a.createElement("a",{className:"btn btn-block text-left note-btn"+("Processing Complete"===S.label?" btn-success":" btn-outline-success"),href:"#"},l.a.createElement("span",{className:"badge badge-success"},l.a.createElement("i",{className:"fa fa-check"}))," "," Processing Complete"))),l.a.createElement("div",{className:"card-body p-0 card-"+S.class+(c?" spinner":"")},l.a.createElement(N.a,{isLoading:c}),l.a.createElement("div",{className:"standard-table table-responsive"},l.a.createElement("table",{className:"table table-stripped"},l.a.createElement("thead",null,l.a.createElement("tr",null,l.a.createElement("th",null,"Message Title"),l.a.createElement("th",{className:"text-center"},"Type"),l.a.createElement("th",{className:"text-center"},"Sending Device"),l.a.createElement("th",{className:"text-center"},"Sending SIM Card"),l.a.createElement("th",{className:"text-center"},"Is Draft?"),l.a.createElement("th",{className:"text-center"},"Created Date"),l.a.createElement("th",{className:"fixed-width-2"}))),l.a.createElement("tbody",null,g.items.length?g.items.map((function(e){return l.a.createElement(x,{key:e.uuid,smsMessage:e,onDeleted:O})})):l.a.createElement("tr",{className:"text-"+S.class+" text-center"},l.a.createElement("td",{colSpan:7},l.a.createElement("strong",null,l.a.createElement("i",{className:"fa fa-info-circle"})," Info:"," "),l.a.createElement("span",{className:"mr-4"},"There are no SMS messages in this list yet!")))))),l.a.createElement("div",{className:"text-center pb-4"},(M=g.count,k=Math.ceil(M/a),l.a.createElement("nav",{"aria-label":"Sms Messages Pagination"},l.a.createElement("ul",{className:"pagination justify-content-center mb-0"},l.a.createElement("li",{className:"page-item "+(u<=0?"disabled":"")},l.a.createElement("span",{className:"page-link",tabIndex:"-1",onClick:function(){return P(S.status,u-1)}},l.a.createElement("i",{className:"fas fa-angle-left"}),l.a.createElement("span",{className:"sr-only"},"Previous"))),function(){for(var e=[],a=function(a){e.push(l.a.createElement("li",{className:"page-item"+(a===u?" active":""),key:a,onClick:function(){return P(S.status,a)}},l.a.createElement("span",{className:"page-link"},a+1)))},t=0;t<k;t++)a(t);return l.a.createElement(r.Fragment,null,e)}(),l.a.createElement("li",{className:"page-item "+(k===u+1?"disabled":"")},l.a.createElement("span",{className:"page-link",onClick:function(){return P(S.status,u+1)}},l.a.createElement("i",{className:"fas fa-angle-right"}),l.a.createElement("span",{className:"sr-only"},"Next")))))))))};w.propTypes={history:m.a.any};var T=Object(i.g)(l.a.memo(w)),L=function(e){var a=Object(r.useState)(20),t=s()(a,1)[0],n=Object(r.useState)(!1),c=s()(n,2),m=c[0],i=c[1],u=Object(r.useState)(0),d=s()(u,2),p=d[0],f=d[1],g=Object(r.useState)(!1),b=s()(g,2),v=b[0],h=b[1],S=Object(r.useState)(!1),y=s()(S,2),k=y[0],D=y[1],P=Object(r.useState)({uuid:"",title:"",body:"",groups:[],status:""}),O=s()(P,2),j=O[0],x=O[1],I=Object(r.useState)({count:0,items:[]}),w=s()(I,2),T=w[0],L=w[1],A=Object(r.useState)({class:"primary",label:"Queued",status:"SMS_QUEUED"}),F=s()(A,2),R=F[0],G=F[1];Object(r.useEffect)((function(){return q(),function(){E.a.clearAllSubscriptions()}}),[]);var V,_,B,q=function(){U(e.match.params.smsMessageId)},U=function(e){h(!0),C.a.getSmsMessage(e).then((function(a){h(!1),a.success&&(x(a.result.data),W(e,R.status,p))}))},W=function(e,a,n){D(!0),C.a.getSmsMessageSchedule(e,a,n,t).then((function(e){D(!1),e.success&&(f(n),L(e.result.data))}),(function(e){E.a.publish("ERROR:MESSAGE",e.message),D(!1)}))},Y=function(e,a){e.preventDefault(),W(j.uuid,a.status,0),G(a)};return l.a.createElement(o.a,{in:!0,appear:!0,timeout:1500,classNames:"fade"},l.a.createElement("div",{className:"row"},l.a.createElement("div",{className:"col-md-4 col-lg-4"},l.a.createElement("div",{className:"card "+("NEWLY_CREATED"!==j.status?"card-info":" card-primary")},l.a.createElement("div",{className:"card-header"},l.a.createElement("h4",null,l.a.createElement("i",{className:"fa fa-address-card"})," SMS Details"),l.a.createElement("div",{className:"card-header-action"},l.a.createElement("span",{className:"badge badge-"+(j.isInDraft?"warning":"info")},l.a.createElement("i",{className:"fas fa-"+(j.isInDraft?"file":"check")})," ",j.isInDraft?"Saved as Draft":M.a.capatalize(j.status)))),l.a.createElement("div",{className:"card-body"+(v?" pl-0 spinner min-height-500":"")},l.a.createElement(N.a,{isLoading:v}),l.a.createElement("div",{className:"row"},l.a.createElement("div",{className:"col-lg-12"},l.a.createElement("div",null,l.a.createElement("div",{className:"heading-md mt-2 mb-1"},l.a.createElement("strong",null,"Title:")),l.a.createElement("span",null,j.title))),l.a.createElement("div",{className:"col-lg-12"},l.a.createElement("div",null,l.a.createElement("div",{className:"heading-md mt-2 mb-1"},l.a.createElement("strong",null,"Message Body:")),l.a.createElement("div",{className:"card card-body bg-light text-primary mb-1"},l.a.createElement("span",{style:{whiteSpace:"pre-wrap"}},j.contents)))),!(!j.groups||!j.groups.length)&&l.a.createElement("div",{className:"col-lg-12"},l.a.createElement("div",null,l.a.createElement("div",{className:"heading-md mt-2 mb-1"},l.a.createElement("strong",null,"Message Groups:")),j.groups.map((function(e){return l.a.createElement("span",{key:e.uuid,type:"button",title:e.notes,className:"badge pl-2 pr-2 pb-1 pt-1 mr-2 mb-2 "+(e.isFavourite?"badge-primary":"badge-warning")},e.name)})))),!(!j.contacts||!j.contacts.length)&&l.a.createElement("div",{className:"col-lg-12"},l.a.createElement("div",null,l.a.createElement("div",{className:"heading-md mt-2 mb-1"},l.a.createElement("strong",null,"Message Contacts:")),j.contacts.map((function(e){return l.a.createElement("span",{key:e.uuid,type:"button",title:e.firstName,className:"badge pl-2 pr-2 pb-1 pt-1 mr-2 mb-2 badge-primary"},e.firstName)})))),!(!j.recepients||!j.recepients.length)&&l.a.createElement("div",{className:"col-lg-12"},l.a.createElement("div",null,l.a.createElement("div",{className:"heading-md mt-2 mb-1"},l.a.createElement("strong",null,"Message Contacts:")),j.recepients.map((function(e){return l.a.createElement("span",{key:e,type:"button",title:e,className:"badge pl-2 pr-2 pb-1 pt-1 mr-2 mb-2 badge-primary"},e)})))),l.a.createElement("div",{className:"col-lg-12"},l.a.createElement("div",null,l.a.createElement("div",{className:"heading-md mt-2 mb-1"},l.a.createElement("strong",null,"Message Status:")),l.a.createElement("span",{className:"badge badge-info pl-2 pr-2 pb-1 pt-1 mr-2 mb-2"},M.a.capatalize(j.status)))),l.a.createElement("div",{className:"col-lg-12"},l.a.createElement("div",null,l.a.createElement("div",{className:"heading-md mt-2 mb-1"},l.a.createElement("strong",null,"Message Date:")),l.a.createElement("span",null,l.a.createElement("i",{className:"fa fa-clock"})," ",j.createdDate))))),l.a.createElement("div",{className:"card-footer"},v?"":(B="NEWLY_CREATED"!==j.status,l.a.createElement("div",{className:"text-center"},l.a.createElement("span",{className:"btn btn-md mr-2 "+(B?"btn-info disabled":"btn-success"),disabled:B||j.isInDraft,type:"button",onClick:function(){return!B&&(a=e.match.params.smsMessageId,i(!0),void C.a.startSmsProcessing(a).then((function(e){e.success&&(x(j),W(a,R.status,p),j.status="SENT_FOR_PROCESSING",E.a.publish("SUCCESS:MESSAGE",e.message),i(!1))}),(function(e){E.a.publish("ERROR:MESSAGE",e.message),i(!1)})));var a}},m?l.a.createElement("span",{className:"spinner-grow spinner-grow-sm"}):""," ",B?"Sent":"Send"," ","For Processing"),l.a.createElement("span",{className:"btn btn-md btn-primary mr-2"+(B?" disabled":""),title:"Edit SMS",type:"button",disabled:B&&!j.isInDraft,onClick:function(a){return!B&&(t=j,a.preventDefault(),e.history.push("/dashboard/sms-messages/"+t.uuid+"/edit"));var t}},l.a.createElement("i",{className:"fa fa-pen"})),l.a.createElement("span",{className:"btn btn-md btn-danger mr-2"+(B?" disabled":""),title:"Delete SMS",type:"buton",disabled:B,onClick:function(a){return!B&&(t=a,n=j.uuid,t.preventDefault(),h(!0),void C.a.deleteSmsById(n).then((function(a){h(!1),a.success&&e.history.push("/dashboard/sms-messages")})));var t,n}},l.a.createElement("i",{className:"fa fa-trash"}))))))),l.a.createElement("div",{className:"col-md-8 col-lg-8"},l.a.createElement("div",{className:"card card-"+R.class},l.a.createElement("div",{className:"card-header"},l.a.createElement("div",{className:"row"},l.a.createElement("div",{className:"col-lg-12"},l.a.createElement("ul",{className:"nav nav-pills"},l.a.createElement("li",{className:"mr-3",onClick:function(e){return Y(e,{class:"secondary",status:"SMS_QUEUED",label:"Queued"})}},l.a.createElement("a",{className:"btn btn-md "+("Queued"===R.label?"btn-primary":"btn-outline-primary"),href:"#"},"Queued"," ",l.a.createElement("span",{className:"text-xs badge badge-secondary"},l.a.createElement("i",{className:"fa fa-angle-double-right"})))),l.a.createElement("li",{className:"mr-3",onClick:function(e){return Y(e,{class:"warning",status:"SMS_TRIED",label:"Tried"})}},l.a.createElement("a",{className:"btn btn-md "+("Tried"===R.label?"btn-warning":"btn-outline-warning"),href:"#"},"Tried Sending"," ",l.a.createElement("span",{className:"text-xs badge badge-warning"},l.a.createElement("i",{className:"fa fa-ellipsis-h"})))),l.a.createElement("li",{className:"mr-3",onClick:function(e){return Y(e,{class:"info",status:"SMS_SENT",label:"Sent"})}},l.a.createElement("a",{className:"btn btn-md "+("Sent"===R.label?"btn-info":"btn-outline-info"),href:"#"},"Sent"," ",l.a.createElement("span",{className:"text-xs badge badge-info"},l.a.createElement("i",{className:"fa fa-paper-plane"})))),l.a.createElement("li",{className:"mr-3",onClick:function(e){return Y(e,{class:"success",status:"SMS_DELIVERED",label:"Delivered"})}},l.a.createElement("a",{className:"btn btn-md "+("Delivered"===R.label?"btn-success":"btn-outline-success"),href:"#"},"Delivered"," ",l.a.createElement("span",{className:"text-xs badge badge-success"},l.a.createElement("i",{className:"fa fa-check"})))),l.a.createElement("li",{className:"mr-3",onClick:function(e){return Y(e,{class:"danger",status:"SMS_FAILED",label:"Failed"})}},l.a.createElement("a",{className:"btn btn-md "+("Failed"===R.label?"btn-danger":"btn-outline-danger"),href:"#"},"Failed"," ",l.a.createElement("span",{className:"text-xs badge badge-danger"},l.a.createElement("i",{className:"fa fa-exclamation-circle"})))))))),l.a.createElement("div",{className:"card-body pt-0 pl-0 pr-0 min-height-500 "+(k?" spinner":"")},l.a.createElement(N.a,{isLoading:k}),l.a.createElement("div",{className:"table-responsive"},l.a.createElement("table",{className:"table table-striped c-table"},l.a.createElement("thead",null,l.a.createElement("tr",null,l.a.createElement("th",null),l.a.createElement("th",null,"Contact Name"),l.a.createElement("th",null,"Phone Number"),l.a.createElement("th",{className:"text-center"},"Sender SIM Card"))),l.a.createElement("tbody",null,T.items.length?T.items.map((function(e,a){return l.a.createElement("tr",{key:e.uuid},l.a.createElement("td",null,p+a+1),l.a.createElement("td",null,M.a.truncateString(e.receiver.name,25)),l.a.createElement("td",null,e.receiver.phoneNumber," ",l.a.createElement("small",{className:"badge custom-badge badge-"+("NCELL"===e.receiver.simType?"primary":"warning")},e.receiver.simType)),l.a.createElement("td",{className:"text-center"},l.a.createElement("span",{className:"badge pl-2 pr-2 pb-1 pt-1 badge-"+(e.sendingSimCard.isDefault?"primary":"success")},l.a.createElement("i",{className:"fa fa-check-circle"})," ",e.sendingSimCard.displayName)))})):l.a.createElement("tr",{className:"text-center text-"+R.class},l.a.createElement("td",{colSpan:4},l.a.createElement("strong",null,l.a.createElement("i",{className:"fa fa-info-circle"})," Info:"," "),l.a.createElement("span",{className:"mr-4"},"There are no SMS Messages yet!"))))))),l.a.createElement("div",{className:"card-footer"},(V=T.count,_=Math.ceil(V/t),l.a.createElement("nav",{"aria-label":"Sms Messages Pagination"},l.a.createElement("ul",{className:"pagination justify-content-center mb-0"},l.a.createElement("li",{className:"page-item "+(p<=0?"disabled":"")},l.a.createElement("span",{className:"page-link",tabIndex:"-1",onClick:function(){return W(j.uuid,R.status,p-1)}},l.a.createElement("i",{className:"fas fa-angle-left"}),l.a.createElement("span",{className:"sr-only"},"Previous"))),function(){for(var e=[],a=function(a){e.push(l.a.createElement("li",{className:"page-item"+(a===p?" active":""),key:a,onClick:function(){return W(j.uuid,R.status,a)}},l.a.createElement("span",{className:"page-link"},a+1)))},t=0;t<_;t++)a(t);return l.a.createElement(r.Fragment,null,e)}(),l.a.createElement("li",{className:"page-item "+(_===p+1?"disabled":"")},l.a.createElement("span",{className:"page-link",onClick:function(){return W(j.uuid,R.status,p+1)}},l.a.createElement("i",{className:"fas fa-angle-right"}),l.a.createElement("span",{className:"sr-only"},"Next")))))))))))};L.propTypes={history:m.a.any,match:m.a.any};var A=Object(i.g)(L),F=function(e){var a=Object(r.useState)([]),t=s()(a,2),n=t[0],c=t[1],m=Object(r.useState)([]),o=s()(m,2),i=o[0],u=o[1],f=Object(r.useState)(0),E=s()(f,2),k=E[0],D=E[1],P=Object(r.useState)([]),j=s()(P,2),x=j[0],I=j[1],w=Object(r.useState)("groups"),T=s()(w,2),L=T[0],A=T[1],F=Object(r.useState)(!1),R=s()(F,2),G=R[0],V=R[1],_=Object(r.useState)(""),B=s()(_,2),q=B[0],U=B[1],W=Object(r.useState)(!1),Y=s()(W,2),Q=Y[0],z=Y[1],J=Object(r.useState)({}),$=s()(J,2),H=$[0],K=$[1],X=Object(r.useState)([]),Z=s()(X,2),ee=Z[0],ae=Z[1],te=Object(r.useState)(null),ne=s()(te,2),se=ne[0],re=ne[1],le=Object(r.useState)([]),ce=s()(le,2),me=ce[0],oe=ce[1],ie=Object(r.useState)(null),ue=s()(ie,2),de=ue[0],pe=ue[1],fe=Object(r.useState)(null),Ee=s()(fe,2),ge=Ee[0],be=Ee[1],Ne=Object(r.useState)(null),ve=s()(Ne,2),he=ve[0],Se=ve[1],ye=Object(b.a)(),Ce=ye.register,Me=ye.handleSubmit,ke=ye.errors,De=ye.getValues,Pe=ye.formState,Oe=ye.unregister,je=n.filter((function(e){return e.contactsCount>0})).map((function(e){return{label:e.name+" ("+e.contactsCount+")",value:e.id,data:e}})),xe=i.map((function(e){return{label:e.firstName+" "+(e.lastName?e.lastName:""),value:e.id,data:e}})),Ie=x.filter((function(e){return!e.isDeleted&&e.isActive})).map((function(e){return{label:e.deviceName,value:e.uuid,data:e}})),we=[{label:"Auto Select SIM Card",value:"AUTO_SELECT"},{label:"Default SIM Card",value:"DEFAULT"},{label:"Selected SIM Card",value:"SELECTED"}],Te=[{label:"Business",value:"Business"},{label:"Promotion",value:"Promotion"},{label:"Offer",value:"Offer"},{label:"Wishes",value:"Wishes"},{label:"Notification",value:"Notification"},{label:"Others",value:"Others"}];Object(r.useEffect)((function(){Le(),Ae()}),[]);var Le=function(){y.a.loadAllGroups().then((function(e){e.success&&c(e.result.data)})),h.a.loadSmsDevices().then((function(e){e.success&&I(e.result.data.filter((function(e){return!1===e.isDeleted})))})),S.a.loadAllContacts().then((function(e){e.success&&u(e.result.data)})),V(!0),C.a.getSmsMessage(e.match.params.smsMessageId).then((function(e){e.success&&(K(e.result.data),z(e.result.data.isInDraft),U(e.result.data.contents),D(e.result.data.contents.length),be(Te.find((function(a){return a.value===e.result.data.smsType}))),re({label:e.result.data.senderDevice.deviceName,value:e.result.data.senderDevice.uuid,data:e.result.data.senderDevice}),e.result.data.contacts.length?(A("contacts"),oe(e.result.data.contacts.map((function(e){return{label:e.firstName+" "+e.lastName,value:e.uuid,data:e}})))):e.result.data.groups.length?(A("groups"),ae(e.result.data.groups.map((function(e){return{label:e.name,value:e.id,data:e}})))):e.result.data.recepients.length&&A("numbers"),e.result.data.simCardOption&&(Se(we.find((function(a){return a.value===e.result.data.simCardOption}))),"SELECTED"===e.result.data.simCardOption&&pe({label:e.result.data.senderSimCard.displayName,value:e.result.data.senderSimCard.uuid,data:e.result.data.senderSimCard}))),V(!1)}))},Ae=function(){M.a.loadAssets({cssLinks:[],jsLinks:[]})},Fe=function(e){ke.contacts=e&&e.length?null:{message:"Please select at least one of the contacts"},oe(e)},Re=function(e){ke.groups=e&&e.length?null:{message:"Please select at least one contact groups"},ae(e)},Ge=function(e){switch(e){case"groups":Oe("contacts"),A("groups");break;case"contacts":Oe("groups"),A("contacts");break;default:Oe("groups"),Oe("contacts"),A("numbers")}};return l.a.createElement("div",{className:"card"},l.a.createElement("div",{className:"card-body"},l.a.createElement("div",{className:"row align-items-center"},l.a.createElement("div",{className:"col-lg-12"},l.a.createElement("h3",{className:"mb-0"},"Edit SMS Message "),l.a.createElement("span",{className:"text-primary"},l.a.createElement("strong",null,l.a.createElement("i",{className:"fa fa-info-circle"})," Info:"," "),"Your SMS Message information will be saved using ",l.a.createElement("strong",null,"bank level security"),".")))),l.a.createElement("form",{onSubmit:Me((function(a){V(!0),a.uuid=e.match.params.smsMessageId,a.smsDeviceId=se.data.uuid,a.smsSimCardOption=he.value,a.smsType=ge.value,a.groups=ee.map((function(e){return e.data})),a.userContacts=me.map((function(e){return e.data})),a.simCardId="SELECTED"===he.value?de.data.uuid:null,C.a.updateSms(a).then((function(e){e.success&&(g.a.success(e.message,{position:"top-right"}),V(!1))}),(function(e){g.a.error(e.message,{position:"top-right"}),V(!1)}))}))},l.a.createElement("div",{className:"modal-body "+(G?"spinner pl-0":"")},l.a.createElement(N.a,{isLoading:G}),l.a.createElement("div",{className:"form-group"},l.a.createElement("label",{className:"form-label"},"Send SMS To:"),l.a.createElement("div",{className:"selectgroup w-100"},l.a.createElement("label",{className:"selectgroup-item"},l.a.createElement("input",{type:"radio",name:"transportation",defaultValue:"groups",className:"selectgroup-input",defaultChecked:"groups"===L}),l.a.createElement("span",{className:"selectgroup-button selectgroup-button-icon",onClick:function(){return Ge("groups")}},l.a.createElement("i",{className:"fa fa-address-book"}),"  Contact Groups")),l.a.createElement("label",{className:"selectgroup-item"},l.a.createElement("input",{type:"radio",name:"transportation",defaultValue:"contacts",className:"selectgroup-input",defaultChecked:"contacts"===L}),l.a.createElement("span",{className:"selectgroup-button selectgroup-button-icon",onClick:function(){return Ge("contacts")}},l.a.createElement("i",{className:"fa fa-users"}),"  Selected Contacts")),l.a.createElement("label",{className:"selectgroup-item"},l.a.createElement("input",{type:"radio",name:"transportation",defaultValue:"numbers",className:"selectgroup-input",defaultChecked:"numbers"===L}),l.a.createElement("span",{className:"selectgroup-button selectgroup-button-icon",onClick:function(){return Ge("numbers")}},l.a.createElement("i",{className:"fas fa-mobile"}),"  Specified Phone Numbers")))),l.a.createElement("div",{className:"row"},l.a.createElement("div",{className:"col-lg-4"},l.a.createElement("div",{className:"form-group"},l.a.createElement("label",{htmlFor:"smsDeviceId",className:"form-control-label"},"Choose SMS Device:"),l.a.createElement(p.a,{id:"smsDeviceId",name:"smsDeviceId",options:Ie||[],value:se,placeholder:"Search SMS Device",onChange:function(e){re(e)},ref:Ce({name:"smsDeviceId"},{validate:function(){return!!se||"Please select a SMS Device"}})}),l.a.createElement("div",{className:"help-block"},l.a.createElement(v.a,{error:ke.smsDeviceId})))),l.a.createElement("div",{className:"col-lg-4"},l.a.createElement("div",{className:"form-group"},l.a.createElement("label",{htmlFor:"simCardOption",className:"form-control-label"},"SIM Card Options:"),l.a.createElement(p.a,{id:"simCardOption",name:"simCardOption",options:we||[],value:he,placeholder:"Search SIM Card Options",onChange:function(e){Se(e)},ref:Ce({name:"simCardOption"},{validate:function(){return!!he||"Please select a SIM Card option"}})}),l.a.createElement("div",{className:"help-block"},l.a.createElement(v.a,{error:ke.simCardOption})))),he&&"SELECTED"===he.value?l.a.createElement("div",{className:"col-lg-4"},l.a.createElement("div",{className:"form-group"},l.a.createElement("label",{htmlFor:"simCardId",className:"form-control-label"},"Choose SIM Card:"),l.a.createElement(p.a,{id:"simCardId",name:"simCardId",options:function(e){var a=[];if(e){var t=x.find((function(a){return a.uuid===e.value}));t&&(a=d()(t.cards.filter((function(e){return e.isActive&&!e.isDeleted})).map((function(e){return{label:e.displayName,value:e.uuid,data:e}}))))}return a}(se)||[],value:de,placeholder:"Search SIM Card",onChange:function(e){pe(e)},ref:Ce({name:"simCardId"},{validate:function(){return!!de||"Please select a SIM Card"}})}),l.a.createElement("div",{className:"help-block"},l.a.createElement(v.a,{error:ke.simCardId})))):""),l.a.createElement("div",{className:"row"},l.a.createElement("div",{className:"col-lg-8"},l.a.createElement("div",{className:"form-group"},l.a.createElement("label",{className:"form-control-label",htmlFor:"input-title"},"Message Title:"),l.a.createElement("input",{type:"text",id:"input-title",name:"title",defaultValue:H.title,placeholder:"Message title",className:"form-control"+M.a.checkValadity("title",ke,Pe),tabIndex:"1",ref:Ce({required:"Please enter your Message Title.",minLength:{value:6,message:"Message Title should be minimum of 6 characters."}})}),l.a.createElement("div",{className:"help-block"},l.a.createElement(v.a,{error:ke.title})))),l.a.createElement("div",{className:"col-lg-4"},l.a.createElement("div",{className:"form-group"},l.a.createElement("label",{className:"form-control-label",htmlFor:"smsType"},"Choose SMS Type:"),l.a.createElement(p.a,{id:"smsType",name:"smsType",options:Te||[],value:ge,placeholder:"Search SMS Type",onChange:function(e){be(e)},ref:Ce({name:"smsType"},{validate:function(){return!!ge||"Please select a SMS Type"}})}),l.a.createElement("div",{className:"help-block"},l.a.createElement(v.a,{error:ke.smsType})))),l.a.createElement("div",{className:"col-lg-12"},l.a.createElement("div",{className:"form-group"},l.a.createElement("label",{htmlFor:"contents",className:"form-control-label mb-0"},"Message Body:"),l.a.createElement("div",{className:"mt-0 mb-2"},l.a.createElement("span",{className:"text-primary"},l.a.createElement("strong",null,l.a.createElement("i",{className:"fa fa-info-circle"})," Quick Tip:"," "),"You can customize the message using placeholders by clicking the ones below the message box.")),l.a.createElement("textarea",{name:"contents",rows:"4",placeholder:"Write your message here ...",className:"form-control"+M.a.checkValadity("contents",ke,Pe),tabIndex:"1",value:q,onChange:function(e){U(e.target.value),D(De().contents.length)},ref:Ce({required:"Please enter your Message Body.",minLength:{value:10,message:"Message Body should be minimum of 10 characters."}})}),l.a.createElement("div",{className:"help-block"},l.a.createElement(v.a,{error:ke.contents})),l.a.createElement("div",{className:"bg-black pt-2"},l.a.createElement("span",null,l.a.createElement("strong",null,"Placeholders:")),l.a.createElement("span",{className:"float-right"},l.a.createElement("strong",null,l.a.createElement("span",{className:k>10&&k<=160?"text-success":"text-warning"},"Characters:"," "," ",k),l.a.createElement("span",{className:"text-light"}," ","|"," "),l.a.createElement("span",{className:"text-danger"},Math.ceil(k/160).toFixed(0)," Message(s)"))),l.a.createElement("div",{className:"mt-1"},l.a.createElement("span",{className:"badge pointer badge-primary pl-3 pr-3 pb-2 mr-2 mb-2",onClick:function(e){e.preventDefault(),U(q+" {firstName}")}},"First Name"),l.a.createElement("span",{className:"badge pointer badge-secondary pl-3 pr-3 pb-2 mr-2 mb-2",onClick:function(e){e.preventDefault(),U(q+"{lastName}")}},"Last Name"),l.a.createElement("span",{className:"badge pointer badge-warning pl-3 pr-3 pb-2 mr-2 mb-2",onClick:function(e){e.preventDefault(),U(q+" {senderName}")}},"Sender Name"),l.a.createElement("span",{className:"badge pointer badge-success pl-3 pr-3 pb-2 mr-2 mb-2",onClick:function(e){e.preventDefault(),U(q+" {senderEmail}")}},"Sender Email"))))),function(){if(!L)return"";var e="";switch(L){case"groups":e=l.a.createElement("div",{className:"col-lg-12"},l.a.createElement("div",{className:"form-group"},l.a.createElement("label",{htmlFor:"groups",className:"form-control-label mb-0"},"Select Groups:"),l.a.createElement("div",{className:"mt-0 mb-2"},l.a.createElement("span",{className:"text-primary"},l.a.createElement("strong",null,l.a.createElement("i",{className:"fa fa-info-circle"})," Info:"," ")," ","Choose the Group(s) to which this SMS message needs to be sent.")),l.a.createElement(p.a,{id:"groups",name:"groups",isMulti:!0,closeMenuOnSelect:!1,placeholder:"Select Messaging Groups",onChange:Re,options:je||[],value:ee,ref:Ce({name:"groups"},{validate:function(){return!(!ee||!ee.length)||"Please select at least one contact groups"}})}),l.a.createElement("div",{className:"help-block"},l.a.createElement(v.a,{error:ke.groups}))));break;case"contacts":Oe("groups"),e=l.a.createElement("div",{className:"col-lg-12"},l.a.createElement("div",{className:"form-group"},l.a.createElement("label",{htmlFor:"contacts",className:"form-control-label mb-0"},"Select Contacts:"),l.a.createElement("div",{className:"mt-0 mb-2"},l.a.createElement("span",{className:"text-primary"},l.a.createElement("strong",null,l.a.createElement("i",{className:"fa fa-info-circle"})," Info:"," ")," ","Choose the Contact(s) to which this SMS message needs to be sent.")),l.a.createElement(p.a,{id:"contacts",name:"contacts",isMulti:!0,options:xe,closeMenuOnSelect:!1,placeholder:"Search Messaging Contacts",onChange:Fe,value:me,ref:Ce({name:"contacts"},{validate:function(){return!(!me||!me.length)||"Please select at least one of the contacts"}})}),l.a.createElement("div",{className:"help-block"},l.a.createElement(v.a,{error:ke.contacts}))));break;case"numbers":Oe("groups"),Oe("contacts"),e=l.a.createElement("div",{className:"col-lg-12"},l.a.createElement("div",{className:"form-group"},l.a.createElement("label",{htmlFor:"recepients",className:"form-control-label"},"Recepients:"),l.a.createElement("div",{className:"mt-0 mb-2"},l.a.createElement("span",{className:"text-primary"},l.a.createElement("i",{className:"fa fa-info-circle"})," Info:"," ",' "+" will be added automatically.')),l.a.createElement("input",{id:"recepients",name:"recepients",placeholder:"Eg. 977 9849038932, 977 8743987843",defaultValue:H.recepients?H.recepients.join(", "):"",className:"form-control"+M.a.checkValadity("recepients",ke,Pe),ref:Ce({required:"Please enter your recepients.",pattern:{value:/^\d{9,13}(, \d{9,13})*$/i,message:"Each recepient must be separated by comma(,)"}})}),l.a.createElement("div",{className:"help-block"},l.a.createElement(v.a,{error:ke.recepients}))));break;default:e=l.a.createElement("div",{className:"text-danger"},"Recepient(s) is required.")}return e}(),l.a.createElement("div",{className:"col-lg-4"},l.a.createElement("div",{className:"form-group"},l.a.createElement("div",{className:"form-control-label"},l.a.createElement("strong",null,"Save as Draft Message")),l.a.createElement("label",{className:"custom-switch mt-0 pl-0"},l.a.createElement("input",{type:"checkbox",name:"isInDraft",value:Q,className:"custom-switch-input",checked:Q,ref:Ce(),onChange:function(e){return e}}),l.a.createElement("div",{className:"help-block"},l.a.createElement(v.a,{error:ke.isInDraft})),l.a.createElement("span",{className:"custom-switch-indicator mt-2",onClick:function(){return z(!Q)}}),l.a.createElement("span",{className:"custom-switch-description mt-2",onClick:function(){return z(!Q)}},Q?"Yes, Save as Draft Messsage.":"Save as final Message.")))))),l.a.createElement("div",{className:"modal-footer bg-whitesmoke"},l.a.createElement("div",{className:"text-left"},l.a.createElement("button",{className:"btn btn-lg btn-primary mr-2",type:"submit"},"Update SMS Message"),l.a.createElement(O.b,{className:"btn btn-lg btn-danger mr-2",to:"/dashboard/sms-messages"},"Cancel")))))};F.propTypes={history:m.a.any,match:m.a.object};var R=Object(i.g)(l.a.memo(F)),G=[{path:"/dashboard/sms-messages",exact:!0,sidebar:function(){return l.a.createElement("div",null,"SMS Messages")},main:function(){return l.a.createElement(l.a.Suspense,{fallback:l.a.createElement(N.a,{isLoading:!0})},l.a.createElement(T,{title:"SMS Messages"}))}},{path:"/dashboard/sms-messages/:smsMessageId/view",exact:!0,sidebar:function(){return l.a.createElement("div",null,"View SMS Messages")},main:function(){return l.a.createElement(l.a.Suspense,{fallback:l.a.createElement(N.a,{isLoading:!0})},l.a.createElement(A,{title:"SMS Message Details"}))}},{path:"/dashboard/sms-messages/:smsMessageId/edit",exact:!0,sidebar:function(){return l.a.createElement("div",null,"Edit SMS Messages")},main:function(){return l.a.createElement(l.a.Suspense,{fallback:l.a.createElement(N.a,{isLoading:!0})},l.a.createElement(R,{title:"SMS Message Edit Form"}))}}],V=function(){var e=Object(r.useState)(!1),a=s()(e,2),t=a[0],n=a[1];Object(r.useEffect)((function(){c()}),[]);var c=function(){M.a.loadAssets({cssLinks:[],jsLinks:[""]})},m=function(){n(!t)},u=function(){return l.a.createElement("div",{className:"row align-items-center"},l.a.createElement("div",{className:"col-lg-12"},l.a.createElement("h3",{className:"mb-0"},"Create SMS Message "),l.a.createElement("span",{className:"text-primary"},l.a.createElement("strong",null,l.a.createElement("i",{className:"fa fa-info-circle"})," Info:"," "),"Your SMS Message information will be saved using ",l.a.createElement("strong",null,"bank level security"),".")))};return l.a.createElement("div",null,l.a.createElement(i.d,null,G.map((function(e,a){return l.a.createElement(i.b,{key:a,path:e.path,exact:e.exact})}))),l.a.createElement("section",{className:"section"},l.a.createElement(o.a,{in:!0,appear:!0,timeout:500,classNames:"hero"},l.a.createElement("div",{className:"section-header"},l.a.createElement("h5",{className:"mb-0 mr-5"},l.a.createElement("i",{className:"fa fa-comments"})," SMS Messages"),l.a.createElement("div",{className:"buttons"},l.a.createElement("button",{type:"button",className:"btn mb-0 btn-primary btn-md text-small mr-3",onClick:function(){return m()}},l.a.createElement("span",{className:"badge badge-transparent"},l.a.createElement("i",{className:"fa fa-envelope"}))," ","New SMS Message")),l.a.createElement("div",{className:"section-header-breadcrumb"},l.a.createElement("div",{className:"breadcrumb-item active"},l.a.createElement("a",{href:"#"},"Dashboard")),l.a.createElement("div",{className:"breadcrumb-item"},"SMS Messages")))),l.a.createElement(o.a,{in:!0,appear:!0,timeout:1500,classNames:"fade"},l.a.createElement("div",{className:"section-body"},l.a.createElement("div",{className:"alert alert-light alert-has-icon"},l.a.createElement("div",{className:"alert-icon text-warning"},l.a.createElement("i",{className:"far fa-lightbulb"})),l.a.createElement("div",{className:"alert-body"},l.a.createElement("span",{className:"close","data-dismiss":"alert"},l.a.createElement("span",null,"×")),l.a.createElement("div",{className:"pt-1"},l.a.createElement("span",{className:"text-primary"},"Once the messages are ",l.a.createElement("strong",null,"sent for processing"),", you need to ",l.a.createElement("strong",null,"check your mobile app to send it to your contacts"),".")))),l.a.createElement(i.d,null,G.map((function(e,a){return l.a.createElement(i.b,{key:a,path:e.path,exact:e.exact,children:l.a.createElement(e.main,null)})})))))),l.a.createElement(P.a,{isOpen:t,header:l.a.createElement(u,null),content:l.a.createElement(D,{cancel:m}),closeModal:m}))};V.propTypes={history:m.a.any};a.default=Object(i.g)(l.a.memo(V))},46:function(e,a,t){"use strict";var n=t(25),s={createGroup:function(e){return n.a.post("/groups/create",e,!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},updateGroup:function(e,a){return n.a.update("/groups/"+a,e,!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},quickUpdateUserGroup:function(e,a,t){return n.a.get("/user/groups/"+e+"/quick-update/"+a+"/"+t,!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},getGroup:function(e){return n.a.get("/groups/"+e,!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},assignContactsToGroup:function(e){return n.a.post("/groups/assign-contacts",e,!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},listUserGroups:function(e,a){return n.a.get("/user/groups/"+e+"/"+a,!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},loadAllGroups:function(){return n.a.get("/user/groups",!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},deleteGroupById:function(e){return n.a.delete("/groups/".concat(e),!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))}};a.a=s},52:function(e,a,t){"use strict";var n=t(25),s={createContact:function(e){return n.a.post("/contacts/create",e,!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},loadAllContacts:function(){return n.a.get("/user/contacts",!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},updateContact:function(e,a){return n.a.update("/user/contacts/"+e,a,!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},quickUpdateUserContact:function(e,a,t){return n.a.get("/user/contacts/"+e+"/quick-update/"+a+"/"+t,!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},uploadContacts:function(e){var a=new FormData;return a.append("action","import-contacts"),e.files.forEach((function(e){return a.append("files",e)})),n.a.post("/import/contacts",a,!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},uploadGroupContacts:function(e){var a=new FormData;return a.append("groups",e.groups),e.files.forEach((function(e){return a.append("files",e)})),n.a.post("/import/group/contacts",a,!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},searchContacts:function(e){return n.a.get("/user/contacts/search?query="+e,!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},loadContactByUuid:function(e){return n.a.get("/user/contacts/"+e,!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},loadPaginatedContacts:function(e,a){return n.a.get("/user/contacts/"+e+"/"+a,!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},blockContacts:function(e){return n.a.post("/user/contacts/block",e,!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},deleteContacts:function(e){return n.a.post("/user/contacts/delete",e,!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},deleteContactById:function(e){return n.a.delete("/user/contacts/".concat(e),!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))}};a.a=s},60:function(e,a,t){"use strict";var n=t(25),s={createNewSms:function(e){return n.a.post("/smses/create",e,!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},updateSms:function(e){return n.a.update("/smses/".concat(e.uuid),e,!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},loadSmsMessages:function(){return n.a.get("user/smses",!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},deleteSmsById:function(e){return n.a.delete("/smses/".concat(e),!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},getSmsMessage:function(e){return n.a.get("/smses/".concat(e),!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},startSmsProcessing:function(e){return n.a.post("/smses/".concat(e,"/schedule"),{},!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},getSmsMessageSchedule:function(e,a,t,s){return n.a.get("/smses/".concat(e,"/schedule/").concat(t,"/").concat(s,"?status=").concat(a),!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))},loadPaginatedSmsMessages:function(e,a,t){return n.a.get("/user/smses/"+a+"/"+t+"?status="+e,!0).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))}};a.a=s}}]);