1import{a as Me}from"./chunk-TJUA5DJG.js";import{a as Ce,b as fe}from"./chunk-N7OHRZLZ.js";import{b as pe,c as me,d as ve}from"./chunk-YEQDNBIG.js";import{a as ie,b as ae,c as oe,d as re,e as se,f as le}from"./chunk-UGQICUYY.js";import{a as ce}from"./chunk-MNGQ4JVX.js";import{a as _e,b as ue,c as be,d as xe}from"./chunk-ZVKVS6QM.js";import{a as de}from"./chunk-OVNK2ETZ.js";import"./chunk-6UHQPIVE.js";import{a as ge,b as he}from"./chunk-ZXSNIZ6S.js";import{a as te,b as ne}from"./chunk-5T5T7ANT.js";import{a as T}from"./chunk-JEL6HJ7P.js";import{aa as Z,na as ee,p as Y}from"./chunk-YQOD7X2Z.js";import"./chunk-563YFTIG.js";import"./chunk-36JN3LZY.js";import{ra as K,sa as X}from"./chunk-WPHW6CRH.js";import{K as z,h as G,o as W}from"./chunk-76O7YCWW.js";import"./chunk-YYIIKC2W.js";import"./chunk-3WYGUSDH.js";import{a as Q,c as q}from"./chunk-LU7SZU5X.js";import{A as J,v as V}from"./chunk-PO2RDVKE.js";import{Ac as w,Bc as D,E as C,Ec as L,Fc as R,Gc as U,Ic as N,J as k,Mb as x,Pb as u,Rb as g,Sb as A,Tc as j,Ub as E,Uc as H,Vb as P,Wb as m,Xb as r,Yb as l,Zb as v,ca as F,db as s,ec as B,ha as _,jc as M,lc as c,n as I,oa as f,pa as b,s as y,ub as $,y as O,zc as p}from"./chunk-3URBZWPM.js";import"./chunk-ODN5LVDJ.js";var Se=(()=>{let o=class o{constructor(){this._httpClient=_(q)}getProgrammeRegistration(t){return this._httpClient.get(`${T.API_URL}/programme-registration/${t}`,{headers:this._prepareHeaders()}).pipe(y(i=>i),C(i=>I(i)))}getAllRegistrations(t){return this._httpClient.get(`${T.API_URL}/registration/contact/${t}?getAll=true`,{headers:this._prepareHeaders()}).pipe(y(i=>i),C(i=>I(i)))}deleteUserFromContact(t){return this._httpClient.delete(`${T.API_URL}/contact/${t}`,{headers:this._prepareHeaders()}).pipe(y(i=>i),C(i=>i))}deleteUserFromContactRel(t){return this._httpClient.delete(`${T.API_URL}/contact-relationship/${t}`,{headers:this._prepareHeaders()}).pipe(y(i=>i),C(i=>i))}contactSearch(t){return this._httpClient.get(`${T.API_URL}/contact/search/${t}`,{headers:this._prepareHeaders()}).pipe(y(i=>i.map(a=>({id:a.contactId,name:`${a.name.givenName} ${a.name.familyName}`,data:a})).filter(Boolean)))}_prepareHeaders(){return new Q({"Content-Type":"application/json"})}};o.\u0275fac=function(i){return new(i||o)},o.\u0275prov=F({token:o,factory:o.\u0275fac,providedIn:"root"});let e=o;return e})();var d=(function(e){return e.CONTACT="contact",e.COGNITO="cognito",e.RELATIONSHIP="relationship",e.SUBSCRIPTIONS="subscriptions",e.PROGRAMMES="programmes",e.CONNECTIONS="connections",e.APPLICATIONS="applications",e.REGISTRATIONS="registrations",e.EMAILS="emails",e})(d||{}),ye=[{header:"Cognito Data",id:d.COGNITO},{header:"Contact Data",id:d.CONTACT},{header:"Emails",id:d.EMAILS},{header:"Contact Relationship Data",id:d.RELATIONSHIP},{header:"Subscriptions Data",id:d.SUBSCRIPTIONS},{header:"Programme Registrations Data",id:d.PROGRAMMES},{header:"Connections Data",id:d.CONNECTIONS},{header:"Membership Applications Data",id:d.APPLICATIONS},{header:"Registrations Data",id:d.REGISTRATIONS}];function Ie(e,o){e&1&&(r(0,"div",1),v(1,"p-progress-spinner",2),l())}function we(e,o){if(e&1){let n=B();r(0,"div",4)(1,"p-button",6),M("onClick",function(){f(n);let i=c(2);return b(i.deleteUserButton.action())}),l(),r(2,"p-button",5),M("onClick",function(){f(n);let i=c(2);return b(i.logOutButton.action())}),l()()}if(e&2){let n=c(2);s(),m("label",n.deleteUserButton.label)("loading",n.deleteUserButton.loading),x("data-auto",n.deleteUserButton.label.toLowerCase()),s(),m("label",n.logOutButton.label)("loading",n.logOutButton.loading),x("data-auto",n.logOutButton.label.toLowerCase())}}function De(e,o){if(e&1&&(r(0,"p-message",7),p(1),l()),e&2){let n=c(2);m("severity",N(n.messages.type)),s(),w(n.messages.message)}}function Oe(e,o){if(e&1&&(r(0,"p-tab",12),p(1),l()),e&2){let n=o.$implicit,t=o.$index;m("value",t),x("data-auto",n.header.toLowerCase()),s(),D("",n.header," ")}}function Ae(e,o){e&1&&(r(0,"p"),p(1," The selected contact does not have an account in our MyAAT authentication provider (Cognito). Please resync the account in CRM and check again in a couple of minutes. "),l())}function Ee(e,o){if(e&1&&(r(0,"div",14)(1,"p"),p(2," Our authentication provider (Cognito) associates the following email with the selected user: "),r(3,"strong"),p(4),l()(),r(5,"p"),p(6," If they are having issues with receiving emails, ensure that this matches what we have in CRM. "),l()()),e&2){let n=c(4);s(4),D("",n.cognitoEmail," ")}}function Pe(e,o){if(e&1&&(r(0,"p-message",13),p(1,"It looks like our authentication provider has a different email to our contact database."),l(),r(2,"div",16)(3,"span"),p(4,"Cognito: "),r(5,"strong"),p(6),l()(),v(7,"p-div
1ider"),r(8,"span"),p(9,"Contact database: "),r(10,"strong"),p(11),l()()()),e&2){let n=c(4);s(6),w(n.cognitoEmail),s(5),w(n.selectedContact.email)}}function Be(e,o){if(e&1&&(r(0,"p"),p(1," Below is a list of emails that we have successfully sent to the user over the last "),r(2,"strong"),p(3,"7 days"),l()(),v(4,"app-information-display",17)),e&2){let n=c(2).$implicit;s(4),m("data",n.dataToDisplay)}}function Le(e,o){if(e&1&&(r(0,"p-message",13),p(1),l()),e&2){let n=c(4);s(),D("No emails have be sent from MyAAT to ",n.cognitoEmail," in the last 7 days")}}function Re(e,o){if(e&1&&(r(0,"p-card"),u(1,Ae,2,0,"p")(2,Ee,7,1,"div",14),u(3,Pe,12,2),r(4,"div",15),u(5,Be,5,1)(6,Le,2,1,"p-message",13),l()()),e&2){let n=c().$implicit,t=c(2);s(),g(t.cognitoEmail?2:1),s(2),g(t.cognitoEmail!==t.selectedContact.email?3:-1),s(2),g(n.dataToDisplay?5:6)}}function Ue(e,o){if(e&1&&(r(0,"pre"),p(1),j(2,"json"),l()),e&2){let n=c(2).$implicit;s(),w(H(2,1,n.dataToDisplay))}}function Ne(e,o){if(e&1&&v(0,"app-information-display",17),e&2){let n=c(2).$implicit;m("data",n.dataToDisplay)}}function ke(e,o){if(e&1&&u(0,Ue,3,3,"pre")(1,Ne,1,1,"app-information-display",17),e&2){let n=c(3);g(n.contactJsonDisplay?0:1)}}function Fe(e,o){if(e&1&&(r(0,"p-message",13),p(1),l()),e&2){let n=c().$implicit;s(),D("No ",n.header==null?null:n.header.toLowerCase()," found")}}function $e(e,o){if(e&1&&(r(0,"p-tabpanel",12),u(1,Re,7,3,"p-card")(2,ke,2,1)(3,Fe,2,1,"p-message",13),l()),e&2){let n=o.$implicit,t=o.$index,i=c(2);m("value",t),s(),g(n.id===i.tabIdentifiers.EMAILS?1:n.dataToDisplay?2:3)}}function je(e,o){if(e&1){let n=B();r(0,"section")(1,"p-card",3)(2,"div",4)(3,"p-button",5),M("onClick",function(){f(n);let i=c();return b(i.resendButton.action())}),l(),r(4,"p-button",6),M("onClick",function(){f(n);let i=c();return b(i.createUserButton.action())}),l(),r(5,"p-button",5),M("onClick",function(){f(n);let i=c();return b(i.lpQueueButton.action())}),l()(),u(6,we,3,6,"div",4),u(7,De,2,3,"p-message",7),r(8,"div",8)(9,"p-toggleswitch",9),U("ngModelChange",function(i){f(n);let a=c();return R(a.contactJsonDisplay,i)||(a.contactJsonDisplay=i),b(i)}),l(),r(10,"label",10),p(11,"Display as raw JSON"),l()(),r(12,"p-tabs",11)(13,"p-tablist"),E(14,Oe,2,3,"p-tab",12,A),l(),r(16,"p-tabpanels"),E(17,$e,4,2,"p-tabpanel",12,A),l()()()()}if(e&2){let n=c();s(),m("header",n.selectedContact.name.givenName+" "+n.selectedContact.name.familyName),s(2),m("label",n.resendButton.label)("loading",n.resendButton.loading),x("data-auto",n.resendButton.label.toLowerCase()),s(),m("label",n.createUserButton.label)("loading",n.createUserButton.loading),x("data-auto",n.createUserButton.label.toLowerCase()),s(),m("label",n.lpQueueButton.label)("loading",n.lpQueueButton.loading),x("data-auto",n.lpQueueButton.label.toLowerCase()),s(),g(n.isAdmin?6:-1),s(),g(n.messages.active?7:-1),s(2),L("ngModel",n.contactJsonDisplay),s(3),m("value",0),s(2),P(n.tabsData),s(3),P(n.tabsData)}}var Tt=(()=>{let o=class o{constructor(){this._contactService=_(Z),this._cognitoService=_(ce),this._reqeueService=_(de),this._contactDataService=_(Se),this._cacheService=_(Y),this._membershipService=_(ee),this._adminToolsService=_(Me),this.placeHolder="Accepts contact Ids, Drupal Ids and emails",this.tabIdentifiers=d,this.isLoadingEmails=!1,this.subscriptions=[],this.contactJsonDisplay=!1,this.tabsData=ye,this.suggestions=[],this.resendButton={label:"Resend temporary password",action:()=>this._tempPassword(),loading:!1},this.createUserButton={label:"Create user in Cognito",action:()=>this._createInCognito(),loading:!1},this.lpQueueButton={label:"Push user through LP queue",action:()=>this._sendThroughLPQueue(),loading:!1},this.deleteUserButton={label:"Delete contact, contact relationship and Cognito records",action:()=>this._deleteUserFromContactAndContactRel(),loading:!1},this.logOutButton={label:"Log user out of MyAAT",action:()=>this._globalSignout(),loading:!1},this.messages={active:!1,type:"success",message:""}}ngOnInit(){this.isAdmin=this._contactService.contactGroups().includes("admin")}ngOnDestroy(){this.subscriptions.forEach(t=>t.unsubscribe())}filterMethod(t){this._contactDataService.contactSearch(t.query).pipe(k(1)).subscribe({next:i=>{this.suggestions=i},error:()=>{this.suggestions=[]}})}contactSelected(t){t?.value?.id&&(this._cacheService.clear(),this.hasSearched=!0,this.isLoading=!0,this._removeMessages(),this._getAllUserData(t.value.data))}_updateTabData(t,i){let a=this.tabsData.find(S=>S.id===t);a&&(a.dataToDisplay=i)}_formatContactRelationship(t){return t?.subscriptions&&(t.subscriptions=t.subscriptions.sort((i,a)=>new Date(a.startDate).valueOf()-new Date(i.startDate).valueOf())),t?.programmeRegistrations&&(t.programmeRegistrations=t.programmeRegistrations.sort((i,a)=>new Date(a.registrationDate).valueOf()-new Date(i.registrationDate).valueOf())),t}_getAllUserData(t){this._resetAllContent();let i={contact:this._contactService.getContact(t.contactId),relationship:this._contactService.getContactRelationship(t.contactId),cognito:this._cognitoService.getCognitoUser(t.contactId),registrations:this._contactDataService.getAllRegistrations(t.contactId),emails:this._adminToolsService.getEmailsSentToUser(t.email),membershipApplications:this._membershipService.getMembershipApplications(t.contactId).pipe(a=>a,C(()=>I({error:!0})))};this.subscriptions.push(O(i).subscribe({next:a=>{if(this.selectedContact=a.contact,this._updateTabData(d.CONTACT,this.selectedContact),!a.relationship.error){let S=this._formatContactRelationship(a.relationship
1);this._updateTabData(d.RELATIONSHIP,S)}a.cognito.error||(this._updateTabData(d.COGNITO,a.cognito),this.cognitoEmail=a.cognito.email),a.registrations.error||this._updateTabData(d.REGISTRATIONS,a.registrations),a.membershipApplications.error||this._updateTabData(d.APPLICATIONS,a.membershipApplications),a.emails?.length>0&&this._updateTabData(d.EMAILS,a.emails)},complete:()=>{this.isLoading=!1}}))}_tempPassword(){this._removeMessages(),this.resendButton.loading=!0,this.subscriptions.push(this._cognitoService.resendTemporaryPassword(this.selectedContact.contactId).subscribe({next:t=>{this.resendButton.loading=!1,t.error?this._addMessage("error",t.error.message):this._addMessage("success","password has been resent")},error:()=>{this.resendButton.loading=!1,this._addMessage("error","an error has occurred")}}))}_globalSignout(){this.logOutButton.loading=!0,this._removeMessages(),this.subscriptions.push(this._cognitoService.globalSignout(this.selectedContact.contactId).subscribe({next:()=>{this.logOutButton.loading=!1,this._addMessage("success","User has been logged out of MyAAT")},error:()=>{this.logOutButton.loading=!1,this._addMessage("error","an error has occurred")}}))}_createInCognito(){this.createUserButton.loading=!0,this._removeMessages(),this.subscriptions.push(this._reqeueService.queueItem("CreateCognitoUser",this.selectedContact.contactId,"contact").subscribe({next:t=>{this.createUserButton.loading=!1,this._addMessage("success",t.statusMessage)},error:()=>{this.createUserButton.loading=!1,this._addMessage("error","an error has occurred")}}))}_deleteUserFromContactAndContactRel(){this.deleteUserButton.loading=!0,this._removeMessages();let t={contact:this._contactDataService.deleteUserFromContact(this.selectedContact.contactId),relationship:this._contactDataService.deleteUserFromContactRel(this.selectedContact.contactId)};this.subscriptions.push(O(t).subscribe({next:()=>{this.deleteUserButton.loading=!1,this._addMessage("success","User has been deleted")},error:()=>{this.deleteUserButton.loading=!1,this._addMessage("error","an error has occurred")}}))}_sendThroughLPQueue(){this.lpQueueButton.loading=!0,this._removeMessages(),this.subscriptions.push(this._reqeueService.addUserToNonWorkerQueue(this.selectedContact.contactId,"LearningPool").subscribe({next:t=>{this.lpQueueButton.loading=!1,t.error?this._addMessage("error","User has not been added to Learning Portal queue"):this._addMessage("success","User has been added to Learning Portal queue")},error:()=>{this.lpQueueButton.loading=!1,this._addMessage("error","User has not been added to Learning Portal queue")}}))}_resetAllContent(){this._removeMessages(),this.selectedContact=null,this.cognitoEmail=null;for(let t in d)this._updateTabData(d[t],null)}_removeMessages(){this.messages.active=!1}_addMessage(t,i){this.messages.active=!0,this.messages.type=t,this.messages.message=i}};o.\u0275fac=function(i){return new(i||o)},o.\u0275cmp=$({type:o,selectors:[["app-contact-management"]],decls:8,vars:8,consts:[["optionLabel","name","delay","300","autoHighlight","true","data-auto","contact-search","name","contact-search",3,"ngModelChange","completeMethod","onSelect","ngModel","suggestions","fluid","placeholder","showClear"],[1,"flex","justify-center"],["ariaLabel","loading",1,"flex"],[1,"mt-2","mb-2",3,"header"],[1,"mb-5","flex","justify-between","flex-wrap","gap-2"],[3,"onClick","label","loading"],["variant","outlined","severity","contrast",",","",3,"onClick","label","loading"],[3,"severity"],[1,"flex","justify-end-safe","mt-3","mb-3"],["inputId","contactJsonToggle","data-auto","contactJsonToggle'",3,"ngModelChange","ngModel"],["for","contactJsonToggle",1,"ml-3"],[1,"mt-5",3,"value"],[3,"value"],["severity","warn"],[1,"flex","flex-col","gap-2"],[1,"mt-5"],[1,"flex","flex-col","gap-3"],[3,"data"]],template:function(i,a){i&1&&(r(0,"section")(1,"h4"),p(2,"Search for a contact"),l(),v(3,"br"),r(4,"p-autocomplete",0),U("ngModelChange",function(h){return R(a.selection,h)||(a.selection=h),h}),M("completeMethod",function(h){return a.filterMethod(h)})("onSelect",function(h){return a.contactSelected(h)}),l(),v(5,"br"),l(),u(6,Ie,2,0,"div",1),u(7,je,19,14,"section")),i&2&&(s(4),m("placeholder",N(a.placeHolder)),L("ngModel",a.selection),m("suggestions",a.suggestions)("fluid",!0)("showClear",!0),s(2),g(a.isLoading?6:-1),s(),g(!a.isLoading&&a.hasSearched?7:-1))}
1,dependencies:[J,he,ge,me,pe,z,G,W,ue,_e,le,se,re,oe,ie,ae,ne,te,ve,X,K,fe,Ce,xe,be,V],styles:["[_ngcontent-%COMP%]:root{--aat-ui-grey-25: #bfbfbf;--aat-ui-grey-55: #737373;--aat-slate: #3a5066;--aat-ui-grey-05: #f2f2f2}.main[_ngcontent-%COMP%]{display:flex}.main__content[_ngcontent-%COMP%]{flex-basis:85%;max-width:80%;margin:auto}.data-container[_ngcontent-%COMP%]{background-color:#eee;display:flex;flex-direction:column}.data-container__beside[_ngcontent-%COMP%]{flex-direction:row}.data-container__beside--content[_ngcontent-%COMP%]{flex-grow:1;margin:10px}.data-container__content[_ngcontent-%COMP%]{background-color:#fff;max-width:90%;min-width:85%;margin:15px auto;padding:15px;font-size:smaller}.data-container__content--json-toggle[_ngcontent-%COMP%]{margin:10px 0;display:flex;justify-content:flex-end}.data-container__content--json-display[_ngcontent-%COMP%]{border:thin solid rgb(238.425,238.425,238.425);padding:5px}.data-container__content--box[_ngcontent-%COMP%]{padding:15px;border-bottom:thin solid rgb(238.425,238.425,238.425)}.data-container__double-panel[_ngcontent-%COMP%]{display:grid;grid-template-columns:48% 48%}.data-container__loader[_ngcontent-%COMP%]{background-color:#fff}.button-container[_ngcontent-%COMP%]{display:flex;justify-content:space-between;padding:10px}.button-container--single[_ngcontent-%COMP%]{justify-content:flex-end}"]});let e=o;return e})();export{Tt as ContactManagementComponent};
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.