Files
pyrofetes/src/app/pages/providers/providers-card-form/providers-card-form.ts
2025-11-27 16:42:20 +01:00

57 lines
1.8 KiB
TypeScript

import { Component } from '@angular/core';
import {NzModalComponent, NzModalModule} from "ng-zorro-antd/modal";
import {NzButtonComponent, NzButtonModule} from "ng-zorro-antd/button";
import {NzMessageService} from "ng-zorro-antd/message";
import {ProvidersAddForm} from "../providers-add-form/providers-add-form";
@Component({
selector: 'app-providers-card-form',
imports: [NzButtonModule, NzModalModule, ProvidersAddForm],
template: `
<button nz-button nzType="primary" (click)="showModal()">
<span style="font-weight: bold">+</span>
</button>
<nz-modal
[(nzVisible)]="isVisible"
[nzTitle]="modalTitle"
[nzContent]="modalContent"
[nzFooter]="modalFooter"
(nzOnCancel)="handleCancel()"
>
<ng-template #modalTitle>Création de prestataires</ng-template>
<ng-template #modalContent>
<app-providers-add-form/>
</ng-template>
<ng-template #modalFooter>
<button nz-button nzType="default" (click)="handleCancel()">Annuler</button>
<button nz-button nzType="primary" (click)="handleOk()" [nzLoading]="isConfirmLoading">Confirmer</button>
</ng-template>
</nz-modal>
`,
styleUrl: './providers-card-form.css',
})
export class ProvidersCardForm {
constructor(private message: NzMessageService) {}
isVisible = false;
isConfirmLoading = false;
showModal(): void {
this.isVisible = true;
}
handleOk(): void {
this.isConfirmLoading = true;
this.message.success('Prestataire créé !');
setTimeout(() => {
this.isVisible = false;
this.isConfirmLoading = false;
}, 1000);
}
handleCancel(): void {
this.isVisible = false;
}
}