Files
workavia-drive/twake/frontend/src/app/features/global/services/alert-manager-service.ts
T
Montassar Ghanmy d91a13e2cc 🔄 Rename all "twake" instances to "tdrive"
🔄 Rename all "twake" instances to "tdrive"
2023-04-10 14:12:00 +01:00

36 lines
1.0 KiB
TypeScript
Executable File

/* eslint-disable @typescript-eslint/no-empty-function */
import { Modal } from 'antd';
import Languages from 'app/features/global/services/languages-service';
import { TdriveService } from '../framework/registry-decorator-service';
const { confirm, info } = Modal;
type Options = {
title?: string;
text?: string;
};
@TdriveService('Alert')
class AlertServiceService {
alert(onClose: () => void, options?: Options) {
info({
title: options?.title || options?.text || '',
content: options?.text || '',
onCancel: onClose,
});
}
confirm(onConfirm: () => void, onClose: (() => void) | false = () => {}, options?: Options) {
confirm({
title: options?.title || Languages.t('components.alert.confirm'),
content: options?.text || Languages.t('components.alert.confirm_click'),
onOk: onConfirm,
onCancel: onClose || undefined,
cancelButtonProps: onClose ? {} : { style: { display: 'none' } },
});
}
}
const AlertManager = new AlertServiceService();
export default AlertManager;