added generation function for generate pdf
This commit is contained in:
@@ -8,6 +8,7 @@ import {QuotationForm} from "../quotation-form/quotation-form";
|
||||
import {GetQuotationDto, QuotationsService} from "../../services/api";
|
||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||
import {firstValueFrom} from "rxjs";
|
||||
import {FileService} from "../../services/file.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-quotation-table',
|
||||
@@ -25,7 +26,8 @@ import {firstValueFrom} from "rxjs";
|
||||
|
||||
export class QuotationTable implements OnInit {
|
||||
private quotationsService = inject(QuotationsService);
|
||||
private notificationService = inject(NzNotificationService)
|
||||
private notificationService = inject(NzNotificationService);
|
||||
private fileService = inject(FileService);
|
||||
quotations = signal<GetQuotationDto[]>([]);
|
||||
quotationsLoading = signal<boolean>(false);
|
||||
|
||||
@@ -63,5 +65,20 @@ export class QuotationTable implements OnInit {
|
||||
}
|
||||
await this.fetchQuotations();
|
||||
}
|
||||
|
||||
async export(quotationId: number){
|
||||
try {
|
||||
const pdf = await firstValueFrom(
|
||||
this.quotationsService.getQuotationPdfEndpoint(quotationId, "response")
|
||||
);
|
||||
this.fileService.downloadBlob(pdf)
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
this.notificationService.error(
|
||||
'Erreur',
|
||||
'Impossible de générer un PDF'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user