2018-10-24 14:33:53 +02:00
|
|
|
import { AppNotification, AppNotificationSeverity, AppNotificationTimeout } from 'app/types';
|
2019-02-06 19:42:04 +01:00
|
|
|
import { getMessageFromError } from 'app/core/utils/errors';
|
2018-10-24 14:33:53 +02:00
|
|
|
|
|
|
|
|
const defaultSuccessNotification: AppNotification = {
|
|
|
|
|
title: '',
|
|
|
|
|
text: '',
|
|
|
|
|
severity: AppNotificationSeverity.Success,
|
|
|
|
|
icon: 'fa fa-check',
|
|
|
|
|
timeout: AppNotificationTimeout.Success,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const defaultWarningNotification: AppNotification = {
|
|
|
|
|
title: '',
|
|
|
|
|
text: '',
|
|
|
|
|
severity: AppNotificationSeverity.Warning,
|
|
|
|
|
icon: 'fa fa-exclamation',
|
|
|
|
|
timeout: AppNotificationTimeout.Warning,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const defaultErrorNotification: AppNotification = {
|
|
|
|
|
title: '',
|
|
|
|
|
text: '',
|
|
|
|
|
severity: AppNotificationSeverity.Error,
|
|
|
|
|
icon: 'fa fa-exclamation-triangle',
|
|
|
|
|
timeout: AppNotificationTimeout.Error,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createSuccessNotification = (title: string, text?: string): AppNotification => ({
|
|
|
|
|
...defaultSuccessNotification,
|
|
|
|
|
title: title,
|
|
|
|
|
text: text,
|
|
|
|
|
id: Date.now(),
|
|
|
|
|
});
|
|
|
|
|
|
2019-02-05 14:42:29 +01:00
|
|
|
export const createErrorNotification = (title: string, text?: any): AppNotification => {
|
|
|
|
|
return {
|
|
|
|
|
...defaultErrorNotification,
|
|
|
|
|
title: title,
|
2019-02-06 19:42:04 +01:00
|
|
|
text: getMessageFromError(text),
|
2019-02-05 14:42:29 +01:00
|
|
|
id: Date.now(),
|
|
|
|
|
};
|
|
|
|
|
};
|
2018-10-24 14:33:53 +02:00
|
|
|
|
|
|
|
|
export const createWarningNotification = (title: string, text?: string): AppNotification => ({
|
|
|
|
|
...defaultWarningNotification,
|
|
|
|
|
title: title,
|
|
|
|
|
text: text,
|
|
|
|
|
id: Date.now(),
|
|
|
|
|
});
|