appNotification.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { AppNotification, AppNotificationSeverity, AppNotificationTimeout } from 'app/types';
  2. const defaultSuccessNotification: AppNotification = {
  3. title: '',
  4. text: '',
  5. severity: AppNotificationSeverity.Success,
  6. icon: 'fa fa-check',
  7. timeout: AppNotificationTimeout.Success,
  8. };
  9. const defaultWarningNotification: AppNotification = {
  10. title: '',
  11. text: '',
  12. severity: AppNotificationSeverity.Warning,
  13. icon: 'fa fa-exclamation',
  14. timeout: AppNotificationTimeout.Warning,
  15. };
  16. const defaultErrorNotification: AppNotification = {
  17. title: '',
  18. text: '',
  19. severity: AppNotificationSeverity.Error,
  20. icon: 'fa fa-exclamation-triangle',
  21. timeout: AppNotificationTimeout.Error,
  22. };
  23. export const createSuccessNotification = (title: string, text?: string): AppNotification => ({
  24. ...defaultSuccessNotification,
  25. title: title,
  26. text: text,
  27. id: Date.now(),
  28. });
  29. export const createErrorNotification = (title: string, text?: string): AppNotification => ({
  30. ...defaultErrorNotification,
  31. title: title,
  32. text: text,
  33. id: Date.now(),
  34. });
  35. export const createWarningNotification = (title: string, text?: string): AppNotification => ({
  36. ...defaultWarningNotification,
  37. title: title,
  38. text: text,
  39. id: Date.now(),
  40. });