1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
(self.webpackChunkapp=self.webpackChunkapp||[]).push([[5235],{95235:(D,F,m)=>{m.r(F),m.d(F,{IdentityValidatorFullNamePageModule:()=>w});var R=m(90944),f=m(24006),C=m(61380),N=m(90603),l=m(15861),i=m(45449),a=m(47898),_=m(45944),b=m(33159),O=m(2569),G=m(99826);const P=function(g){return{"min-height":g,position:"relative"}};let V=(()=>{class g{constructor(c,u,h,y,A,H,Y,k,K,B,Z,W,$,X,Q,z,J,q,ee,te,ie){var t=this;this.formBuilder=c,this.api=u,this.activatedRoute=h,this.notificatorService=y,this.loadingService=A,this.keyboardService=H,this.sendVerificationEmailModalService=Y,this.warnConflictModalService=k,this.ngZoneService=K,this.deviceInfoService=B,this.navigationService=Z,this.logService=W,this.translateConfigService=$,this.authService=X,this.storageService=Q,this.deviceUuidService=z,this.platform=J,this.saveFlowStorageResetKeyService=q,this.utilsService=ee,this.showToastModalErroCodeZero=te,this.initRegisterHasCompanyStorageService=ie,this.onSendVerificationEmailModalStateChange=function(){var e=(0,l.Z)(function*(o){yield t.ngZoneService.run(()=>{t.showSendVerificationEmailModal=o.show,t.emailSendVerificationEmailModal=o.email})});return function(o){return e.apply(this,arguments)}}(),this.onWarnConflictModalStateChange=function(){var e=(0,l.Z)(function*(o){yield t.ngZoneService.run(()=>{t.showWarnConflictModal=o.show,t.emailWarnConflictModal=o.email})});return function(o){return e.apply(this,arguments)}}(),this.onSubmit=(0,l.Z)(function*(){let e=null;if(e=yield t.getUniqueDeviceId(),t.uuid=e??"",!t.uuid||null==t.uuid||t.uuid.length<=0)t.logService.logEvent("UUIID::in_Submit","Null UUID - Methodo Submit");else if(t.validateForm(t.fullNameForm)){let n=null;const r=()=>{n&&n.unsubscribe(),t.loadingService.show(t.translateConfigService.translate("LOADING_PROCESSING_DATA"),"identity-validator-full-name");const s=t.getFirstName(),d=t.getLastName();if(t.initRegisterHasCompanyStorageService.set({document:t.document,firstName:s,lastName:d,uuid:t.uuid,context:t.context,foreign:t.foreign}),t.foreign){const v=t.utilsService.convertToUppercase(t.document);t.api.verifyForeignFullName(v,s,d,t.foreign).subscribe(t.verifyFullNameSuccessResponse,t.verifyFullNameErrorResponse)}else t.api.verifyFullName(t.document,s,d,t.foreign).subscribe(t.verifyFullNameSuccessResponse,t.verifyFullNameErrorResponse)};n=t.keyboardService.onHideObservable?.subscribe(r),t.keyboardService.isVisible()?t.keyboardService.hide():r()}else{t.logService.logError("user::register-full-name");const n={title:t.translateConfigService.translate("PG_IDENTIFY_FULLNAME_TOAST_INVALID_DATA_TITLE"),message:t.translateConfigService.translate("PG_IDENTIFY_FULLNAME_TOAST_INVALID_DATA_MESSAGE"),type:"error"};t.notificatorService.notify(n)}}),this.getFirstName=()=>{let e=this.fullNameForm.controls.fullName.value;return e=e.trim(),e=e.split(" "),e[0]?e[0]:""},this.getLastName=()=>{let e=this.fullNameForm.controls.fullName.value;return e=e.trim(),e=e.split(" "),e=e.filter((o,n)=>0!==n),e.join(" ")},this.validateForm=e=>{const o=this.getFirstName(),n=this.getLastName();if(o&&n){const r=o.length,s=n.length;return r+s>2&&r+s<255}return!1},this.verifyFullNameForeignSuccessResponse=e=>{this.checkAccount()},this.verifyFullNameSuccessResponse=e=>{this.verifyIfMatch(e)?this.checkAccount():(this.logService.logEvent("user::register-full-name-no-match"),this.showErroNoMatchNameDocument(e))},this.verifyFullNameErrorResponse=e=>{if(this.logService.logError("http::register-full-name","",e),e&&e?.error&&e?.error?.errorKey&&400===e?.error.status){if(!this.verifyIfMatch({matched:"notmatched"!==e?.error?.errorKey}))return void this.showErroNoMatchNameDocument(e);this.checkAccount()}this.loadingService.hide(null,"identity-validator-full-name").then(()=>{if(0===e?.status)return this.showToastModalErroCodeZero.showToast(),void this.logService.logError("http::register-full-name","Unknown error",e);if(400===e.status){const o={title:this.translateConfigService.translate("PG_IDENTIFY_FULLNAME_TOAST_ERROR_REQUEST_TITLE"),message:`${this.translateConfigService.translate("PG_IDENTIFY_FULLNAME_TOAST_ERROR_REQUEST_MESSAGE")} (cod. 400)`,type:"error"};return this.notificatorService.notify(o)}if(404===e.status)this.checkAccount();else{let o;this.foreign&&(o=this.translateConfigService.translate("PG_IDENTIFY_FULLNAME_TOAST_NOT_FOUND_MESSAGE"));const n={title:this.translateConfigService.translate("PG_IDENTIFY_FULLNAME_TOAST_SERVICE_ERROR_TITLE"),message:o,type:"error"};this.notificatorService.notify(n)}})},this.checkAccount=()=>{const e=this.uuid,o=this.document,n=this.foreign,r=n?this.utilsService.convertToUppercase(o):o;this.api.accountCheck(e,r,n).subscribe(this.accountCheckSuccessResponse,this.accountCheckErrorResponse)},this.accountCheckSuccessResponse=e=>{const r=e&&e.obfuscatedEmail?e.obfuscatedEmail:"";!this.context&&e&&e.hasAnyCompany&&e&&e.activated&&(this.context="has-company"),this.loadingService.hide(null,"identity-validator-full-name").then(()=>{"forgot-pin"===this.context||"has-company"===this.context?this.onSendVerificationEmail(r,e):this.goToCompanyCodeStep(e)})},this.goToCompanyCodeStep=e=>{const o=!!e.activated&&e.activated,n=e.obfuscatedEmail?e.obfuscatedEmail:"",r=this.uuid,s=this.document,d=this.getFirstName(),v=this.getLastName(),p=this.foreign,I=p?this.utilsService.convertToUppercase(s):s;this.navigationService.forward(["/identity-validator-company-code"],{queryParams:{uuid:r,document:I,firstName:d,lastName:v,email:n,conflict:!1,activated:o,foreign:p}})},this.accountCheckErrorResponse=e=>{this.loadingService.hide(null,"identity-validator-full-name").then(()=>{if(404===e.status){const o=this.uuid,n=this.document,r=this.getFirstName(),s=this.getLastName();this.navigationService.forward(["/identity-validator-company-code"],{queryParams:{uuid:o,document:n,firstName:r,lastName:s,foreign:this.foreign}})}else if(409===e.status){if("notFound"===e.error.conflictType){const o=this.uuid,n=this.document,r=this.getFirstName(),s=this.getLastName();this.navigationService.forward(["/identity-validator-company-code"],{queryParams:{uuid:o,document:n,firstName:r,lastName:s,conflict:"notFound",foreign:this.foreign}})}else if("found"===e.error.conflictType){const o=e&&e.error.hasAnyCompany,n=e&&e.error.activated;if(!this.context&&o&&n&&(this.context="has-company"),"has-company"===this.context){const r=e.error.params,s=this.uuid,v=this.getFirstName(),S=this.getLastName(),p="found",I=this.foreign,T=this.initRegisterHasCompanyStorageService.get();this.initRegisterHasCompanyStorageService.set({document:T?.document??this.document??"",context:this.context??T?.context??"",hasAnyCompany:o,activated:n,uuid:s,firstName:v,lastName:S,email:r,conflict:p,foreign:I,obfuscatedEmail:e.error.params}),this.navigationService.forward(["has-company/identity-email-confirmation"])}else{const r=e.error.params,s=this.uuid,d=this.document,v=this.getFirstName(),S=this.getLastName();this.navigationService.forward(["/identity-validator-company-code"],{queryParams:{uuid:s,document:d,firstName:v,lastName:S,email:r,conflict:"found",foreign:this.foreign}})}}}else{this.logService.logError("http::account-check","",e);const o={title:this.translateConfigService.translate("PG_IDENTIFY_FULLNAME_TOAST_SERVICE_ERROR_TITLE"),message:`${this.translateConfigService.translate("PG_IDENTIFY_FULLNAME_CHECKING_DATA_ERROR_MESSAGE")} (cod. ${e.status})`,type:"error"};this.notificatorService.notify(o)}})},this.stepBack=()=>{const e=this.document,o=this.uuid,n=this.foreign,r=this.context;if(n){const d={queryParams:{document:this.utilsService.convertToUppercase(e),uuid:o,foreign:n,context:r}};this.navigationService.back(["/foreign-document"],d)}else this.navigationService.back(["/identity-validator"],{queryParams:{document:e,uuid:o,foreign:n,context:r}})},this.onSendVerificationEmailModalBack=()=>{this.sendVerificationEmailModalService.hideModal()},this.onSendVerificationEmail=(0,l.Z)(function*(e=null,o){const n=t.uuid,r=t.document,s=t.foreign,d=t.getFirstName(),S=(t.getLastName(),s?t.utilsService.convertToUppercase(r):r);t.loadingService.show(t.translateConfigService.translate("PG_IDENTIFY_FULLNAME_LOADING_SEND_MAIL"),"send-email-verification");const p=yield t.saveFlowStorageResetKeyService.getInitForgot();if(o&&p&&p?.isInitiatedForgotten||"forgot-pin"===t.context){const I="pt"===t.translateConfigService.getCurrentLang()?"pt-Br":t.translateConfigService.getCurrentLang(),E=o?.email??"",T=I,U=(yield t.authService.getRefId())??null,L="";t.saveFlowStorageResetKeyService.setDataResetKeyInit({refId:U,firstName:d,email:E,obfuscatedEmail:e,langKey:T,document:r,resetKey:L});const oe=s?t.utilsService.convertToUppercase(r):r;t.api.accountDeviceResetInit(n,oe,s,{refId:U,firstName:d,email:E,langKey:T,resetKey:L}).subscribe(()=>t.accountDeviceResetInitSuccessResponse(e),ne=>t.accountDeviceResetInitErrorResponse(ne))}else t.api.accountDeviceResetInit(n,S,s,null).subscribe(()=>t.accountDeviceResetInitSuccessResponse(e),I=>t.accountDeviceResetInitErrorResponse(I))}),this.onWarnConflictModalBack=()=>{this.warnConflictModalService.hideModal()},this.onWarnConflictModalAccept=()=>{const e=this.email;this.warnConflictModalService.hideModal(),this.sendVerificationEmailModalService.showModal(e)},this.accountDeviceResetInitSuccessResponse=(0,l.Z)(function*(e=null){yield t.loadingService.hide(null,"send-email-verification");const o=t.uuid,n=t.document,r=t.getFirstName(),s=t.getLastName(),d=t.email,v=t.context,S=t.foreign,I={queryParams:{uuid:o,document:S?t.utilsService.convertToUppercase(n):n,firstName:r,lastName:s,email:d,context:v,foreign:S,obfuscatedEmail:e}};t.sendVerificationEmailModalService.hideModal(),t.navigationService.forward("forgot-pin"===t.context?["/identity-insert-password"]:["/identity-validator-code"],I)}),this.accountDeviceResetInitErrorResponse=function(){var e=(0,l.Z)(function*(o){if(console.log("accountCheckErrorResponse"),console.log("response:",o),t.logService.logError("http::account-device-reset-init","",o),yield t.loadingService.hide(null,"send-email-verification"),0===o?.status)return t.showToastModalErroCodeZero.showToast(),void t.logService.logError("http::account-device-reset-init","Unknown error",o);const{title:n,message:r}=t.getTitleAndMessage(o);t.toastNotificationError(n,r,1e3)});return function(o){return e.apply(this,arguments)}}(),this.getUniqueDeviceId=(0,l.Z)(function*(){let e="";return(yield t.storageService.ready())&&(e=yield t.authService.getUUID()),e&&null!=e?(t.uuid=e,t.uuid):t.deviceUuidService.getUUID().then(t.onGetUniqueDeviceIdSuccessResponse).catch(t.onGetUniqueDeviceIdErrorResponse)}),this.onGetUniqueDeviceIdSuccessResponse=function(){var e=(0,l.Z)(function*(o){try{const n=yield t.saveUUIDStorage(o);return t.uuid=n.uuid,n.uuid}catch(n){return n}});return function(o){return e.apply(this,arguments)}}(),this.onGetUniqueDeviceIdErrorResponse=e=>{const o=this.translateConfigService.translate("PG_START_TOAST_AUTHORIZE"),r={title:this.translateConfigService.translate("PG_START_TOAST_NOTICE_TITLE"),message:o,type:"error"};this.notificatorService.notify(r)}}ionViewWillEnter(){const c=this.initRegisterHasCompanyStorageService.get();c&&(this.document=c?.document??"",this.context=c?.context??"",this.foreign="true"===c?.foreign||!0===c?.foreign)}ngOnInit(){this.fullNameForm=this.formBuilder.group({fullName:["",[f.Validators.required,f.Validators.minLength(3),f.Validators.maxLength(5)]]}),this.sendVerificationEmailModalService.observable.subscribe(this.onSendVerificationEmailModalStateChange),this.warnConflictModalService.observable.subscribe(this.onWarnConflictModalStateChange)}verifyIfMatch(c){return c.matched}getTitleAndMessage(c){return{title:this.translateConfigService.translate("PG_IDENTIFY_FULLNAME_TOAST_SERVICE_ERROR_TITLE"),message:`${this.translateConfigService.translate("TOAST_SERVICE_TEMPORARILY_UNAVAILABLE_MESSAGE")} (cod. ${c.status})`}}toastNotificationError(c,u,h){this.notificatorService.notify({title:c,message:u,type:"error",timeout:h})}saveUUIDStorage(c){var u=this;return(0,l.Z)(function*(){let h={uuid:"",success:!1};try{yield u.platform.ready();try{if(yield u.storageService.ready())try{return yield u.authService.setUUID(c),h={uuid:c,success:!0},u.logService.logEvent("setUUIDIdentityValidadeFullName::","Success save UUID in storage",h),h}catch(A){throw h={...A,uuid:null,success:!1},u.logService.logError("ErrorSetUUIDIdentityValidadeFullName::","erro save UUID in storage",h),h}}catch(y){throw u.logService.logError("ErrorstorageIdentityValidadeFullName::","not avaliable storage ready",y),y}}catch(y){u.logService.logError("platformReadyStartPage::","not avaliable platform ready",y)}})()}showErroNoMatchNameDocument(c){this.logService.logError("NoMatchNameDocument","",{data:c}),this.loadingService.hide(null,"identity-validator-full-name").then(()=>{let u,h;this.foreign?(h=this.translateConfigService.translate("PG_IDENTIFY_FULLNAME_TOAST_NO_MATCH_FOREIGN_TITLE"),u=this.translateConfigService.translate("PG_IDENTIFY_FULLNAME_TOAST_NO_MATCH_FOREIGN_MESSAGE")):(h=this.translateConfigService.translate("PG_IDENTIFY_FULLNAME_TOAST_NO_MATCH_TITLE"),u=this.translateConfigService.translate("PG_IDENTIFY_FULLNAME_TOAST_NO_MATCH_MESSAGE")),this.notificatorService.notify({title:h,message:u,type:"error",timeout:8e3})})}}return g.\u0275fac=function(c){return new(c||g)(i.\u0275\u0275directiveInject(f.UntypedFormBuilder),i.\u0275\u0275directiveInject(a.sM),i.\u0275\u0275directiveInject(C.ActivatedRoute),i.\u0275\u0275directiveInject(a.V6),i.\u0275\u0275directiveInject(a.bz),i.\u0275\u0275directiveInject(a.i8),i.\u0275\u0275directiveInject(a.H0),i.\u0275\u0275directiveInject(a.fj),i.\u0275\u0275directiveInject(a.zf),i.\u0275\u0275directiveInject(a.Hc),i.\u0275\u0275directiveInject(a.f5),i.\u0275\u0275directiveInject(a.$V),i.\u0275\u0275directiveInject(a.wK),i.\u0275\u0275directiveInject(a.e8),i.\u0275\u0275directiveInject(a.V1),i.\u0275\u0275directiveInject(a.hX),i.\u0275\u0275directiveInject(N.Platform),i.\u0275\u0275directiveInject(a.RQ),i.\u0275\u0275directiveInject(a.FW),i.\u0275\u0275directiveInject(a.ME),i.\u0275\u0275directiveInject(_.K))},g.\u0275cmp=i.\u0275\u0275defineComponent({type:g,selectors:[["app-identity-validator-full-name"]],decls:22,vars:16,consts:[[1,"ion-no-border",2,"height","0"],[3,"ngStyle"],["tabindex","-1",1,"ion-margin-vertical"],[1,"flex-auto"],[1,"ion-margin-vertical"],[3,"formGroup","ngSubmit"],[1,"input-holder"],["tabindex","-2","for","fullName"],["tabindex","0","id","fullName","type","text","formControlName","fullName","appFullName","",3,"placeholder"],[1,"button-holder"],["type","button",1,"back",3,"click"],["type","submit","tabindex","3"]],template:function(c,u){1&c&&(i.\u0275\u0275element(0,"ion-header",0),i.\u0275\u0275elementStart(1,"ion-content")(2,"ion-grid",1)(3,"ion-row")(4,"ion-col",2),i.\u0275\u0275element(5,"app-full-logo"),i.\u0275\u0275elementEnd()(),i.\u0275\u0275elementStart(6,"ion-row",3)(7,"ion-col",4)(8,"form",5),i.\u0275\u0275listener("ngSubmit",function(){return u.onSubmit()}),i.\u0275\u0275elementStart(9,"div",6)(10,"label",7),i.\u0275\u0275text(11),i.\u0275\u0275pipe(12,"translate"),i.\u0275\u0275elementEnd(),i.\u0275\u0275element(13,"input",8),i.\u0275\u0275pipe(14,"translate"),i.\u0275\u0275elementEnd(),i.\u0275\u0275elementStart(15,"div",9)(16,"button",10),i.\u0275\u0275listener("click",function(){return u.stepBack()}),i.\u0275\u0275text(17),i.\u0275\u0275pipe(18,"translate"),i.\u0275\u0275elementEnd(),i.\u0275\u0275elementStart(19,"button",11),i.\u0275\u0275text(20),i.\u0275\u0275pipe(21,"translate"),i.\u0275\u0275elementEnd()()()()()()()),2&c&&(i.\u0275\u0275advance(2),i.\u0275\u0275property("ngStyle",i.\u0275\u0275pureFunction1(14,P,u.deviceInfoService.getDeviceHeight()+"px")),i.\u0275\u0275advance(6),i.\u0275\u0275property("formGroup",u.fullNameForm),i.\u0275\u0275advance(3),i.\u0275\u0275textInterpolate1(" ",i.\u0275\u0275pipeBind1(12,6,"PG_IDENTIFY_FULLNAME_TEXT")," "),i.\u0275\u0275advance(2),i.\u0275\u0275property("placeholder",i.\u0275\u0275pipeBind1(14,8,"PG_IDENTIFY_FULLNAME_INPUT")),i.\u0275\u0275advance(4),i.\u0275\u0275textInterpolate1(" ",i.\u0275\u0275pipeBind1(18,10,"BTN_BACK")," "),i.\u0275\u0275advance(3),i.\u0275\u0275textInterpolate(i.\u0275\u0275pipeBind1(21,12,"BTN_NEXT")))},dependencies:[R.NgStyle,N.IonCol,N.IonContent,N.IonGrid,N.IonHeader,N.IonRow,f.\u0275NgNoValidate,f.DefaultValueAccessor,f.NgControlStatus,f.NgControlStatusGroup,f.FormGroupDirective,f.FormControlName,b.R,O.RB,G.X$]}),g})();var x=m(69270);const j=[{path:"",component:V}];let w=(()=>{class g{}return g.\u0275fac=function(c){return new(c||g)},g.\u0275mod=i.\u0275\u0275defineNgModule({type:g}),g.\u0275inj=i.\u0275\u0275defineInjector({imports:[x.I,R.CommonModule,f.FormsModule,f.ReactiveFormsModule,N.IonicModule,C.RouterModule.forChild(j)]}),g})()},45944:(D,F,m)=>{m.d(F,{K:()=>N});var R=m(15861),f=m(45449);let C=(()=>{class l{constructor(){}set(a,_){localStorage.setItem(a,JSON.stringify(_))}get(a){return JSON.parse(localStorage.getItem(a))??null}remove(a){localStorage.removeItem(a)}clear(){localStorage.clear()}}return l.\u0275fac=function(a){return new(a||l)},l.\u0275prov=f.\u0275\u0275defineInjectable({token:l,factory:l.\u0275fac,providedIn:"root"}),l})(),N=(()=>{class l{constructor(a){this.simpleStorageService=a,this.KEY="REGISTER_HAS_COMPANY",this.cache=null}set(a){this.simpleStorageService.set(this.KEY,a),this.cache=a}get(){const a=this.simpleStorageService.get(this.KEY);return this.cache=a,a}remove(){var a=this;return(0,R.Z)(function*(){a.simpleStorageService.remove(a.KEY),a.cache=null})()}}return l.\u0275fac=function(a){return new(a||l)(f.\u0275\u0275inject(C))},l.\u0275prov=f.\u0275\u0275defineInjectable({token:l,factory:l.\u0275fac,providedIn:"root"}),l})()}}]); |