Files
kapp/2087.ff55140849383e8f.js
T
2026-05-21 11:19:10 -03:00

1 line
9.6 KiB
JavaScript

(self.webpackChunkapp=self.webpackChunkapp||[]).push([[2087],{12087:(F,I,o)=>{o.r(I),o.d(I,{ForeignDocumentPageModule:()=>x});var S=o(90944),l=o(24006),E=o(61380),d=o(90603),s=o(72986),e=o(45449),t=o(47898),T=o(37763),v=o(45944),D=o(33159),N=o(2569),b=o(99826);const A=function(u){return{"min-height":u,position:"relative"}};let _=(()=>{class u{constructor(i,r,h,y,O,G,j,B,L,H,V,U,K,Y){this.formBuilder=i,this.api=r,this.notificatorService=h,this.activatedRoute=y,this.loadingService=O,this.keyboardService=G,this.deviceInfoService=j,this.navigationService=B,this.logService=L,this.translateConfigService=H,this.focusService=V,this.utilsService=U,this.showToastModalErroCodeZero=K,this.initRegisterHasCompanyStorageService=Y,this.onSubmit=()=>{const n=this.clearInput(this.foreignDocumentForm.controls.document.value),a=this.validateInput(n),m=this.utilsService.convertToUppercase(n);if(a){let c=null;const f=m.replace(/[^\w]/g,""),g=()=>{if(c&&c.unsubscribe(),this.loadingService.show(this.translateConfigService.translate("LOADING_PROCESSING_DATA"),"identity-validator-document"),this.validateCpfType(f)){const p=this.utilsService.cleanedInput(f);this.initRegisterHasCompanyStorageService.set({document:p,context:this.context}),this.verifyDocument(p)}else this.initRegisterHasCompanyStorageService.set({document:m,context:this.context,foreign:"true"}),this.api.verifyForeignDocument(m).subscribe(p=>{this.onSubmitSuccessResponse(p,!0)},p=>this.onSubmitErrorResponse(p,!0))};c=this.keyboardService.onHideObservable?.subscribe(g),this.keyboardService.isVisible()?this.keyboardService.hide():g()}else{this.logService.logError("user::register-document");const c={title:this.translateConfigService.translate("PG_IDENTIFY_FOREIGN_TOAST_INVALID_DATA_TITLE"),message:this.translateConfigService.translate("PG_IDENTIFY_FOREIGN_TOAST_INVALID_DATA_MESSAGE"),type:"error"};this.notificatorService.notify(c)}},this.clearInput=n=>n.trim(),this.onSubmitSuccessResponse=(n,a)=>{n||a?(a=!0,this.loadingService.hide(null,"identity-validator-document").then(()=>{this.goToNextStep(a)})):this.loadingService.hide(null,"identity-validator-document").then(()=>{this.goToNextStep(a)})},this.onSubmitErrorResponse=(n,a)=>{console.log("onSubmitErrorResponse:",JSON.stringify(n)),this.logService.logError("http::register-document",`${n?.error?.detail??""}`,JSON.stringify(n)),this.loadingService.hide(null,"identity-validator-document").then(()=>{if(0===n?.status)return this.logService.logError("http::register-document","Unknown error",n),void this.showToastModalErroCodeZero.showToast();if(400===n.status){this.logService.logError("http::register-document");const m={title:this.translateConfigService.translate("PG_IDENTIFY_FOREIGN_TOAST_ERROR_REQUEST_TITLE"),message:`${this.translateConfigService.translate("PG_IDENTIFY_FOREIGN_TOAST_ERROR_REQUEST_MESSAGE")} (cod. 400)`,type:"error"};this.notificatorService.notify(m)}else if(404===n.status)this.goToNextStep(a);else{const{title:m,message:c}=this.getTitleAndMessage(n);this.toastNotificationError(m,c,0===n?.status?1e4:5e3)}})},this.goToNextStep=n=>{const a=this.context,m=n,c=this.foreignDocumentForm.controls.document.value,f=m?this.clearInput(c):this.utilsService.cleanedInput(c),g=this.utilsService.convertToUppercase(f);this.navigationService.forward(["/identity-validator-full-name"],{queryParams:{context:a,document:g,foreign:m}})},this.goOneStepBack=()=>{this.navigationService.back(["/identity-validator"])},this.validateCpfType=n=>{const a=n.replace(/[^\w]/g,"");if(11!==a.toString().length||/^(\d)\1{10}$/.test(a))return!1;let m=!0;return[9,10].forEach(c=>{let g,f=0;a.split(/(?=)/).splice(0,c).forEach((C,p)=>{f+=parseInt(C,10)*(c+2-(p+1))}),g=f%11,g=g<2?0:11-g,g!==parseInt(a.substring(c,c+1),10)&&(m=!1)}),m}}ionViewWillEnter(){this.focusService.applyFocusQuerySelector("documentforeign",100);const i=this.initRegisterHasCompanyStorageService.get();i&&(console.log(i),this.context=i?.context)}ngOnInit(){this.foreignDocumentForm=this.formBuilder.group({document:[""]})}validateInput(i){return!!this.validateCpfType(i)||this.validateDocumentLettersAndNumbers(i)}validateDocumentLettersAndNumbers(i){return new RegExp("^[A-Za-z0-9]{4,}$").test(i)}verifyDocument(i){this.api.verifyDocument(i).pipe((0,s.q)(1)).subscribe(r=>{this.onSubmitSuccessResponse(r,!1)},r=>this.onSubmitErrorResponse(r,!0))}getTitleAndMessage(i){let r="",h="";const y=i?.status?`(cod. ${i.status})`:"";return r=this.translateConfigService.translate("PG_IDENTIFY_FOREIGN_TOAST_SERVICE_ERROR_TITLE"),h=`${this.translateConfigService.translate("TOAST_SERVICE_TEMPORARILY_UNAVAILABLE_MESSAGE")} ${y}`,{title:r,message:h}}toastNotificationError(i,r,h){this.notificatorService.notify({title:i,message:r,type:"error",timeout:h})}}return u.\u0275fac=function(i){return new(i||u)(e.\u0275\u0275directiveInject(l.UntypedFormBuilder),e.\u0275\u0275directiveInject(t.sM),e.\u0275\u0275directiveInject(t.V6),e.\u0275\u0275directiveInject(E.ActivatedRoute),e.\u0275\u0275directiveInject(t.bz),e.\u0275\u0275directiveInject(t.i8),e.\u0275\u0275directiveInject(t.Hc),e.\u0275\u0275directiveInject(t.f5),e.\u0275\u0275directiveInject(t.$V),e.\u0275\u0275directiveInject(t.wK),e.\u0275\u0275directiveInject(T.i),e.\u0275\u0275directiveInject(t.FW),e.\u0275\u0275directiveInject(t.ME),e.\u0275\u0275directiveInject(v.K))},u.\u0275cmp=e.\u0275\u0275defineComponent({type:u,selectors:[["app-foreign-document"]],decls:24,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"],["for","document"],["id","documentforeign","tabindex","1"],["tabindex","2","id","document","appAutoFocus","","type","text","formControlName","document",3,"placeholder"],[1,"button-holder"],["tabindex","3","type","button",1,"back",3,"click"],["role","button","type","submit"],["tabindex","4"]],template:function(i,r){1&i&&(e.\u0275\u0275element(0,"ion-header",0),e.\u0275\u0275elementStart(1,"ion-content")(2,"ion-grid",1)(3,"ion-row")(4,"ion-col",2),e.\u0275\u0275element(5,"app-full-logo"),e.\u0275\u0275elementEnd()(),e.\u0275\u0275elementStart(6,"ion-row",3)(7,"ion-col",4)(8,"form",5),e.\u0275\u0275listener("ngSubmit",function(){return r.onSubmit()}),e.\u0275\u0275elementStart(9,"div",6)(10,"ion-label",7)(11,"span",8),e.\u0275\u0275text(12),e.\u0275\u0275pipe(13,"translate"),e.\u0275\u0275elementEnd()(),e.\u0275\u0275element(14,"input",9),e.\u0275\u0275pipe(15,"translate"),e.\u0275\u0275elementEnd(),e.\u0275\u0275elementStart(16,"div",10)(17,"button",11),e.\u0275\u0275listener("click",function(){return r.goOneStepBack()}),e.\u0275\u0275text(18),e.\u0275\u0275pipe(19,"translate"),e.\u0275\u0275elementEnd(),e.\u0275\u0275elementStart(20,"button",12)(21,"span",13),e.\u0275\u0275text(22),e.\u0275\u0275pipe(23,"translate"),e.\u0275\u0275elementEnd()()()()()()()()),2&i&&(e.\u0275\u0275advance(2),e.\u0275\u0275property("ngStyle",e.\u0275\u0275pureFunction1(14,A,r.deviceInfoService.getDeviceHeight()+"px")),e.\u0275\u0275advance(6),e.\u0275\u0275property("formGroup",r.foreignDocumentForm),e.\u0275\u0275advance(4),e.\u0275\u0275textInterpolate1(" ",e.\u0275\u0275pipeBind1(13,6,"PG_IDENTIFY_FOREIGN_TEXT")," "),e.\u0275\u0275advance(2),e.\u0275\u0275property("placeholder",e.\u0275\u0275pipeBind1(15,8,"PG_IDENTIFY_FOREIGN_INPUT")),e.\u0275\u0275advance(4),e.\u0275\u0275textInterpolate1(" ",e.\u0275\u0275pipeBind1(19,10,"BTN_BACK")," "),e.\u0275\u0275advance(4),e.\u0275\u0275textInterpolate1(" ",e.\u0275\u0275pipeBind1(23,12,"BTN_NEXT"),""))},dependencies:[S.NgStyle,d.IonCol,d.IonContent,d.IonGrid,d.IonHeader,d.IonLabel,d.IonRow,l.\u0275NgNoValidate,l.DefaultValueAccessor,l.NgControlStatus,l.NgControlStatusGroup,l.FormGroupDirective,l.FormControlName,D.R,N.hT,b.X$],styles:["ion-label[_ngcontent-%COMP%]{color:#656768;font-weight:500}input[_ngcontent-%COMP%]{text-transform:uppercase}[_ngcontent-%COMP%]::-webkit-input-placeholder{text-transform:none}"]}),u})();var P=o(69270);const M=[{path:"",component:_}];let x=(()=>{class u{}return u.\u0275fac=function(i){return new(i||u)},u.\u0275mod=e.\u0275\u0275defineNgModule({type:u}),u.\u0275inj=e.\u0275\u0275defineInjector({imports:[P.I,S.CommonModule,l.FormsModule,l.ReactiveFormsModule,d.IonicModule,E.RouterModule.forChild(M)]}),u})()},37763:(F,I,o)=>{o.d(I,{i:()=>e});var S=o(61380),E=o(92198),d=o(45449);let e=(()=>{class t{constructor(v){this.router=v}focusInRouterNavigate(){this.router.events.pipe((0,E.h)(v=>v instanceof S.NavigationEnd)).subscribe(()=>{const v=document.querySelector("#focusHeader");v&&v?.focus()})}applyFocusQuerySelector(v,D){setTimeout(()=>{document.querySelector(`#${v}`)?.focus()},D)}}return t.\u0275fac=function(v){return new(v||t)(d.\u0275\u0275inject(S.Router))},t.\u0275prov=d.\u0275\u0275defineInjectable({token:t,factory:t.\u0275fac,providedIn:"root"}),t})()},45944:(F,I,o)=>{o.d(I,{K:()=>d});var S=o(15861),l=o(45449);let E=(()=>{class s{constructor(){}set(t,T){localStorage.setItem(t,JSON.stringify(T))}get(t){return JSON.parse(localStorage.getItem(t))??null}remove(t){localStorage.removeItem(t)}clear(){localStorage.clear()}}return s.\u0275fac=function(t){return new(t||s)},s.\u0275prov=l.\u0275\u0275defineInjectable({token:s,factory:s.\u0275fac,providedIn:"root"}),s})(),d=(()=>{class s{constructor(t){this.simpleStorageService=t,this.KEY="REGISTER_HAS_COMPANY",this.cache=null}set(t){this.simpleStorageService.set(this.KEY,t),this.cache=t}get(){const t=this.simpleStorageService.get(this.KEY);return this.cache=t,t}remove(){var t=this;return(0,S.Z)(function*(){t.simpleStorageService.remove(t.KEY),t.cache=null})()}}return s.\u0275fac=function(t){return new(t||s)(l.\u0275\u0275inject(E))},s.\u0275prov=l.\u0275\u0275defineInjectable({token:s,factory:s.\u0275fac,providedIn:"root"}),s})()}}]);