|
@@ -1,4 +1,5 @@
|
|
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
|
|
|
|
+import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
|
|
|
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
|
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
|
|
import { CommonModule } from '@angular/common';
|
|
import { CommonModule } from '@angular/common';
|
|
|
import { Router, RouterModule } from '@angular/router';
|
|
import { Router, RouterModule } from '@angular/router';
|
|
@@ -19,6 +20,8 @@ export class ClaimFormComponent implements OnInit, OnDestroy {
|
|
|
claimForm: FormGroup;
|
|
claimForm: FormGroup;
|
|
|
currentUser: User | null = null;
|
|
currentUser: User | null = null;
|
|
|
previewUrl: string | null = null;
|
|
previewUrl: string | null = null;
|
|
|
|
|
+ safePdfUrl: SafeResourceUrl | null = null;
|
|
|
|
|
+ isPdf = false;
|
|
|
selectedFile: File | null = null;
|
|
selectedFile: File | null = null;
|
|
|
extractionResponse: ExtractionResponse | null = null;
|
|
extractionResponse: ExtractionResponse | null = null;
|
|
|
v2Response: V2TemplateResponse | null = null;
|
|
v2Response: V2TemplateResponse | null = null;
|
|
@@ -51,7 +54,8 @@ export class ClaimFormComponent implements OnInit, OnDestroy {
|
|
|
private fb: FormBuilder,
|
|
private fb: FormBuilder,
|
|
|
private extractionService: ExtractionService,
|
|
private extractionService: ExtractionService,
|
|
|
private sessionService: SessionService,
|
|
private sessionService: SessionService,
|
|
|
- private router: Router
|
|
|
|
|
|
|
+ private router: Router,
|
|
|
|
|
+ private sanitizer: DomSanitizer
|
|
|
) {
|
|
) {
|
|
|
this.claimForm = this.fb.group({
|
|
this.claimForm = this.fb.group({
|
|
|
provider_name: ['', Validators.required],
|
|
provider_name: ['', Validators.required],
|
|
@@ -131,8 +135,17 @@ export class ClaimFormComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
|
|
private handleFileSelection(file: File): void {
|
|
private handleFileSelection(file: File): void {
|
|
|
if (!this.currentUser) return;
|
|
if (!this.currentUser) return;
|
|
|
|
|
+ this.isPdf = file.type === 'application/pdf';
|
|
|
this.selectedFile = file;
|
|
this.selectedFile = file;
|
|
|
- this.previewUrl = URL.createObjectURL(file);
|
|
|
|
|
|
|
+ const url = URL.createObjectURL(file);
|
|
|
|
|
+ this.previewUrl = url;
|
|
|
|
|
+
|
|
|
|
|
+ if (this.isPdf) {
|
|
|
|
|
+ this.safePdfUrl = this.sanitizer.bypassSecurityTrustResourceUrl(url);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.safePdfUrl = null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
this.extractionResponse = null;
|
|
this.extractionResponse = null;
|
|
|
this.errorMessage = null;
|
|
this.errorMessage = null;
|
|
|
this.autoFilledFields.clear();
|
|
this.autoFilledFields.clear();
|