added generation function for generate pdf
This commit is contained in:
@@ -10,6 +10,8 @@ import {DeliverynotesService, GetDeliveryNoteDto} from "../../services/api";
|
||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||
import {firstValueFrom} from "rxjs";
|
||||
import {format} from "date-fns";
|
||||
import {HttpResponse} from "@angular/common/http";
|
||||
import {FileService} from "../../services/file.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-deliverery-note-table',
|
||||
@@ -27,7 +29,8 @@ import {format} from "date-fns";
|
||||
})
|
||||
export class DelivereryNoteTable implements OnInit {
|
||||
private deliveryNotesService = inject(DeliverynotesService);
|
||||
private notificationService = inject(NzNotificationService)
|
||||
private notificationService = inject(NzNotificationService);
|
||||
private fileService = inject(FileService);
|
||||
deliveryNotes = signal<GetDeliveryNoteDto[]>([]);
|
||||
deliveryNotesLoading = signal<boolean>(false);
|
||||
|
||||
@@ -95,7 +98,19 @@ export class DelivereryNoteTable implements OnInit {
|
||||
await this.fetchDeliveryNotes()
|
||||
}
|
||||
|
||||
export(deliveryNote: number) {
|
||||
return
|
||||
async export(deliveryNoteId: number) {
|
||||
try {
|
||||
const pdf = await firstValueFrom(
|
||||
this.deliveryNotesService.getDeliveryNotePdfEndpoint(deliveryNoteId, "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