{"version":3,"sources":["webpack:///src/app/modules/public-document/public-document.component.ts","webpack:///src/app/modules/public-document/public-document.component.html","webpack:///src/app/modules/public-document/public-document.component.scss","webpack:///src/app/modules/public-document/public-document-routing.module.ts","webpack:///src/app/modules/public-document/public-document.module.ts"],"names":["route","fb","prescriptionService","modalService","authService","themeService","isPasswordVisible","loading","this","form","group","secretCode","code","snapshot","params","user","controls","setValidators","required","moment","month","year","value","patient","downloadPrescriptionPdf","womensMonth","sex","success","nzTitle","nzContent","nzOkText","nzOnOk","window","open","nzCancelText","err","modal","console","error","status","warning","message","setTimeout","destroy","getActiveTheme","name","selector","template","routes","path","component","PublicDocumentRoutingModule","imports","forChild","exports","PublicDocumentModule","forRoot","declarations"],"mappings":"oSAea,EAAuB,MAOlC,YACUA,EACAC,EACAC,EACAC,EACAC,EACAC,GALA,KAAAL,QACA,KAAAC,KACA,KAAAC,sBACA,KAAAC,eACA,KAAAC,cACA,KAAAC,eAXV,KAAAC,mBAAoB,EACpB,KAAAC,SAAU,EAaV,WACEC,KAAKC,KAAOD,KAAKP,GAAGS,MAAM,CACxBC,WAAY,CAAC,MAEfH,KAAKI,KAAOJ,KAAKR,MAAMa,SAASC,OAAa,KACxCN,KAAKO,MACRP,KAAKC,KAAKO,SAASL,WAAWM,cAAc,CAAC,IAAWC,WAI5D,WACE,OAAOV,KAAKJ,YAAYW,OAG1B,kBACE,OAA4B,IAArBI,IAASC,SAAqC,OAApBD,IAASE,OAG5C,eACE,MAAM,WAAEV,GAAeH,KAAKC,KAAKa,MAEjC,IACE,GAAIX,GAAcH,KAAKO,KAAM,CAC3BP,KAAKD,SAAU,EACf,MAAM,QAAEgB,SAAkBf,KAAKN,oBAAoBsB,wBACjDhB,KAAKI,KACLD,GAGAH,KAAKiB,cACHjB,KAAKO,MAA0B,MAAlBP,KAAKO,KAAKW,KAAiBH,GAA2B,MAAhBA,EAAQG,KAE7DlB,KAAKL,aAAawB,QAAQ,CACxBC,QAAS,kCACTC,UACE,gKAEFC,SAAU,YACVC,OAAQ,IAAMC,OAAOC,KAAK,kCAAmC,UAC7DC,aAAc,eAGhB1B,KAAKL,aAAawB,QAAQ,CACxBC,QAAS,UACTC,UAAW,oCAIjB,MAAOM,GAEP,IAAIC,EADJC,QAAQC,MAAMH,GAGZC,EADiB,MAAfD,EAAII,OACE/B,KAAKL,aAAaqC,QAAQ,CAAEZ,QAAS,QAASC,UAAW,gCACzC,MAAfM,EAAII,OACL/B,KAAKL,aAAamC,MAAM,CAC9BV,QAAS,QACTC,UAAW,0CAGLrB,KAAKL,aAAaqC,QAAQ,CAAEZ,QAAS,QAASC,UAAWM,EAAIM,UAEvEC,WAAWA,IAAMN,EAAMO,UAAW,KAEpCnC,KAAKD,SAAU,EAGjB,kCAEE,MAAuB,0BADRC,KAAKH,aAAauC,iBACnBC,O,4BAjGT,K,MADA,K,MAOA,K,MAJY,K,MACZ,K,MAEA,MAQI,EAAuB,aALnC,YAAU,CACTC,SAAU,sBACVC,SCZa,i/E,QCAA,6Q,iCFuBI,IACH,IACiB,IACP,IACD,IACC,OAbb,GGXb,MAAMC,EAAiB,CAAC,CAAEC,KAAM,GAAIC,UAAW,I,IAMlCC,EAA2B,QAA3BA,EAA2B,aAJvC,YAAS,CACRC,QAAS,CAAC,IAAaC,SAASL,IAChCM,QAAS,CAAC,QAECH,G,oBCEAI,EAAoB,QAApBA,EAAoB,aAJhC,YAAS,CACRH,QAAS,CAAC,IAAcD,EAA6B,IAAkB,IAAiBK,QAAQ,KAChGC,aAAc,CAAC,MAEJF","file":"x","sourcesContent":["import { Component, OnInit } from '@angular/core';\nimport { FormBuilder, FormGroup, Validators } from '@angular/forms';\nimport { ActivatedRoute } from '@angular/router';\nimport * as moment from 'moment';\nimport { NzModalRef, NzModalService } from 'ng-zorro-antd/modal';\nimport { AuthService } from './../../core/services/auth.service';\nimport { User } from './../../shared/models/decodedLoginToken';\nimport { ThemeService } from './../../theme/theme.service';\nimport { PrescriptionService } from './../document/services/prescription.service';\n\n@Component({\n  selector: 'app-public-document',\n  templateUrl: './public-document.component.html',\n  styleUrls: ['./public-document.component.scss']\n})\nexport class PublicDocumentComponent implements OnInit {\n  form: FormGroup;\n  isPasswordVisible = true;\n  loading = false;\n\n  private code: string;\n\n  constructor(\n    private route: ActivatedRoute,\n    private fb: FormBuilder,\n    private prescriptionService: PrescriptionService,\n    private modalService: NzModalService,\n    private authService: AuthService,\n    private themeService: ThemeService\n  ) {}\n\n  ngOnInit() {\n    this.form = this.fb.group({\n      secretCode: ['']\n    });\n    this.code = this.route.snapshot.params['code'];\n    if (!this.user) {\n      this.form.controls.secretCode.setValidators([Validators.required]);\n    }\n  }\n\n  get user(): User {\n    return this.authService.user();\n  }\n\n  private get womensMonth(): boolean {\n    return moment().month() === 2 && moment().year() === 2022;\n  }\n\n  async submit() {\n    const { secretCode } = this.form.value;\n\n    try {\n      if (secretCode || this.user) {\n        this.loading = true;\n        const { patient } = await this.prescriptionService.downloadPrescriptionPdf(\n          this.code,\n          secretCode\n        );\n        if (\n          this.womensMonth &&\n          ((this.user && this.user.sex === 'F') || (patient && patient.sex === 'F'))\n        ) {\n          this.modalService.success({\n            nzTitle: 'Download realizado com sucesso!',\n            nzContent:\n              '<b>Parabéns, Mulher!</b> Que tal comemorar aproveitando descontos especiais, frete grátis ' +\n              'e kits exclusivos do mês da mulher CR? Clique e aproveite.',\n            nzOkText: 'Quero ver',\n            nzOnOk: () => window.open('https://consultaremedios.com.br', '_blank'),\n            nzCancelText: 'Ver depois'\n          });\n        } else {\n          this.modalService.success({\n            nzTitle: 'Sucesso',\n            nzContent: 'Download realizado com sucesso'\n          });\n        }\n      }\n    } catch (err) {\n      console.error(err);\n      let modal: NzModalRef<string>;\n      if (err.status === 404) {\n        modal = this.modalService.warning({ nzTitle: 'Aviso', nzContent: 'Documento não encontrado' });\n      } else if (err.status === 403) {\n        modal = this.modalService.error({\n          nzTitle: 'Aviso',\n          nzContent: 'Código de segurança inválido'\n        });\n      } else {\n        modal = this.modalService.warning({ nzTitle: 'Aviso', nzContent: err.message });\n      }\n      setTimeout(() => modal.destroy(), 3000);\n    }\n    this.loading = false;\n  }\n\n  get isThemeActiveReceitaDigital() {\n    const active = this.themeService.getActiveTheme();\n    return active.name === 'theme-receita-digital';\n  }\n}\n","export default \"<section class=\\\"section-hero header\\\" theme>\\n  <div class=\\\"container d-flex align-items-center justify-content-center flex-column\\\">\\n    <a routerLink=\\\"/\\\" class=\\\"brand-bg\\\">\\n      <img\\n        [ngStyle]=\\\"\\n          isThemeActiveReceitaDigital\\n            ? {\\n                position: 'relative',\\n                top: '-12px'\\n              }\\n            : { position: 'relative', top: '-48px' }\\n        \\\"\\n        [src]=\\\"\\n          isThemeActiveReceitaDigital ? 'assets/img/logo-01.jpg' : 'assets/img/mrd/logo-com-texto.png'\\n        \\\"\\n        class=\\\"img-fluid\\\"\\n        alt=\\\"Logo Receita Digital\\\"\\n      />\\n    </a>\\n    <h1 class=\\\"mb-5 mt-5\\\" *ngIf=\\\"isThemeActiveReceitaDigital; else mrdTitle\\\">\\n      Receita Digital\\n    </h1>\\n    <ng-template #mrdTitle>\\n      <h1 class=\\\"mb-5 mt-5\\\">\\n        Meu Receituário Digital\\n      </h1>\\n    </ng-template>\\n  </div>\\n</section>\\n<section class=\\\"section container d-flex justify-content-center\\\">\\n  <form nz-form [formGroup]=\\\"form\\\" (ngSubmit)=\\\"submit()\\\" class=\\\"d-flex justify-content-center\\\">\\n    <div class=\\\"w-46 d-flex\\\">\\n      <nz-form-item>\\n        <nz-form-label nzFor=\\\"secretCode\\\">\\n          <div class=\\\"label\\\">\\n            <p>\\n              Para realizar o download, digite os 4 primeiros dígitos do CPF do paciente ou responsável,\\n              caso seja um menor de idade sem CPF ou um Pet. Se você recebeu o documento impresso, digite\\n              o código de segurança de 6 dígitos que pode ser encontrado no canto inferior do documento\\n              ou abaixo do QR code.\\n            </p>\\n          </div>\\n        </nz-form-label>\\n        <nz-form-control nzHasFeedback>\\n          <app-input-password\\n            placeholder=\\\"Digite o código\\\"\\n            formControlName=\\\"secretCode\\\"\\n            [isPasswordVisible]=\\\"isPasswordVisible\\\"\\n          >\\n          </app-input-password>\\n          <nz-form-explain *ngIf=\\\"form.get('secretCode').dirty && form.get('secretCode').errors\\\">\\n            <ng-container *ngIf=\\\"form.get('secretCode').hasError('required')\\\">\\n              Campo obrigatório.\\n            </ng-container>\\n          </nz-form-explain>\\n        </nz-form-control>\\n      </nz-form-item>\\n      <div class=\\\"d-flex button\\\">\\n        <button type=\\\"submit\\\" class=\\\"btn btn-success\\\" theme>\\n          <i class=\\\"fa fa-arrow-right\\\"></i>\\n        </button>\\n      </div>\\n    </div>\\n  </form>\\n</section>\\n<ngx-loading [show]=\\\"loading\\\" [config]=\\\"{ backdropBorderRadius: '3px' }\\\"></ngx-loading>\\n\";","export default \".header {\\n  background-color: var(--background-header);\\n}\\n\\n.button {\\n  flex-direction: column;\\n  justify-content: flex-end;\\n  margin: 10px;\\n}\\n\\n.label {\\n  white-space: normal;\\n}\\n\\n.label p {\\n  text-align: justify;\\n  font-size: 14px;\\n  margin: 0;\\n}\";","import { NgModule } from '@angular/core';\nimport { Routes, RouterModule } from '@angular/router';\nimport { PublicDocumentComponent } from './public-document.component';\n\nconst routes: Routes = [{ path: '', component: PublicDocumentComponent }];\n\n@NgModule({\n  imports: [RouterModule.forChild(routes)],\n  exports: [RouterModule]\n})\nexport class PublicDocumentRoutingModule {}\n","import { NgxLoadingModule } from 'ngx-loading';\nimport { ComponentsModule } from '@app/shared/components/components.module';\nimport { NgModule } from '@angular/core';\n\nimport { PublicDocumentRoutingModule } from './public-document-routing.module';\nimport { PublicDocumentComponent } from './public-document.component';\nimport { SharedModule } from '@app/shared';\n\n@NgModule({\n  imports: [SharedModule, PublicDocumentRoutingModule, ComponentsModule, NgxLoadingModule.forRoot({})],\n  declarations: [PublicDocumentComponent]\n})\nexport class PublicDocumentModule {}\n"]}