added generation function for generate pdf

This commit is contained in:
2025-12-04 17:13:16 +01:00
parent f76162fa83
commit 41bfc9b8ae
9 changed files with 214 additions and 9 deletions

View File

@@ -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'
);
}
}
}