Files
psp_panel/src/app/shared/components/confirmationDialog/confirmation-dialog.service.ts
T
2026-05-30 19:05:23 +03:30

33 lines
820 B
TypeScript

import { Injectable, inject } from '@angular/core';
import { Confirmation, ConfirmationService } from 'primeng/api';
export interface AppConfirmOptions {
header: string;
message: string;
acceptLabel?: string;
rejectLabel?: string;
accept?: () => void;
reject?: () => void;
}
@Injectable({
providedIn: 'root',
})
export class AppConfirmationService {
private confirmationService = inject(ConfirmationService);
ask(options: Confirmation): Promise<boolean> {
return new Promise((resolve) => {
this.confirmationService.confirm({
position: 'bottom',
acceptLabel: 'تایید',
rejectLabel: 'لغو',
...options,
closeOnEscape: true,
accept: () => options.accept?.() || resolve(true),
reject: () => resolve(false),
});
});
}
}