added loading function

This commit is contained in:
2025-12-04 17:45:20 +01:00
parent 41bfc9b8ae
commit f812ce856c
3 changed files with 14 additions and 4 deletions

View File

@@ -10,7 +10,6 @@ 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({
@@ -40,7 +39,6 @@ export class DelivereryNoteTable implements OnInit {
async fetchDeliveryNotes() {
this.deliveryNotesLoading.set(true)
try {
const deliveryNotes = await firstValueFrom(this.deliveryNotesService.getAllDeliveryNoteEndpoint())
this.deliveryNotes.set(deliveryNotes);
@@ -54,6 +52,7 @@ export class DelivereryNoteTable implements OnInit {
}
async delete(deliveryNote:number) {
this.deliveryNotesLoading.set(true)
try {
await firstValueFrom(this.deliveryNotesService.deleteDeliveryNoteEndpoint(deliveryNote));
this.notificationService.success(
@@ -66,10 +65,12 @@ export class DelivereryNoteTable implements OnInit {
'Impossible de supprimer la ligne'
)
}
this.deliveryNotesLoading.set(false)
await this.fetchDeliveryNotes();
}
async validate(deliveryNote:number) {
this.deliveryNotesLoading.set(true)
try {
const PatchRealDate = {
realDeliveryDate: format(new Date(), 'yyyy-MM-dd')
@@ -94,11 +95,12 @@ export class DelivereryNoteTable implements OnInit {
'Erreur d\'actualisation de la date'
)
}
this.deliveryNotesLoading.set(false)
await this.fetchDeliveryNotes()
}
async export(deliveryNoteId: number) {
this.deliveryNotesLoading.set(true)
try {
const pdf = await firstValueFrom(
this.deliveryNotesService.getDeliveryNotePdfEndpoint(deliveryNoteId, "response")
@@ -111,6 +113,6 @@ export class DelivereryNoteTable implements OnInit {
'Impossible de générer un PDF'
);
}
this.deliveryNotesLoading.set(false)
}
}

View File

@@ -50,6 +50,7 @@ export class PurchaseOrderTable implements OnInit {
}
async delete(purchaseOrderId:number) {
this.purchaseOrdersLoading.set(true)
try {
await firstValueFrom(this.purchaseOrdersService.deletePurchaseOrderEndpoint(purchaseOrderId))
this.notificationService.success(
@@ -62,10 +63,12 @@ export class PurchaseOrderTable implements OnInit {
'Impossible de supprimer la ligne'
)
}
this.purchaseOrdersLoading.set(false)
await this.fetchPurchaseOrder();
}
async export(purchaseOrderId: number){
this.purchaseOrdersLoading.set(true)
try {
const pdf = await firstValueFrom(
this.purchaseOrdersService.getPurchaseOrderPdfEndpoint(purchaseOrderId, "response")
@@ -78,6 +81,7 @@ export class PurchaseOrderTable implements OnInit {
'Impossible de générer un PDF'
);
}
this.purchaseOrdersLoading.set(false)
}
transfer() {

View File

@@ -51,6 +51,7 @@ export class QuotationTable implements OnInit {
}
async delete(quotation:number) {
this.quotationsLoading.set(true)
try {
await firstValueFrom(this.quotationsService.deleteQuotationEndpoint(quotation))
this.notificationService.success(
@@ -63,10 +64,12 @@ export class QuotationTable implements OnInit {
'Impossible de supprimer la ligne'
)
}
this.quotationsLoading.set(false)
await this.fetchQuotations();
}
async export(quotationId: number){
this.quotationsLoading.set(true)
try {
const pdf = await firstValueFrom(
this.quotationsService.getQuotationPdfEndpoint(quotationId, "response")
@@ -79,6 +82,7 @@ export class QuotationTable implements OnInit {
'Impossible de générer un PDF'
);
}
this.quotationsLoading.set(false)
}
}