useActionAndMsg.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import type { HasObjectId } from '@growi/core';
  2. import { SupportedAction } from '~/interfaces/activity';
  3. import type { IInAppNotification } from '~/interfaces/in-app-notification';
  4. export type ActionMsgAndIconType = {
  5. actionMsg: string
  6. actionIcon: string
  7. }
  8. export const useActionMsgAndIconForModelNotification = (notification: IInAppNotification & HasObjectId): ActionMsgAndIconType => {
  9. const actionType: string = notification.action;
  10. let actionMsg: string;
  11. let actionIcon: string;
  12. switch (actionType) {
  13. case SupportedAction.ACTION_PAGE_LIKE:
  14. actionMsg = 'liked';
  15. actionIcon = 'icon-like';
  16. break;
  17. case SupportedAction.ACTION_PAGE_BOOKMARK:
  18. actionMsg = 'bookmarked on';
  19. actionIcon = 'icon-star';
  20. break;
  21. case SupportedAction.ACTION_PAGE_UPDATE:
  22. actionMsg = 'updated on';
  23. actionIcon = 'ti ti-agenda';
  24. break;
  25. case SupportedAction.ACTION_PAGE_RENAME:
  26. actionMsg = 'renamed';
  27. actionIcon = 'icon-action-redo';
  28. break;
  29. case SupportedAction.ACTION_PAGE_DUPLICATE:
  30. actionMsg = 'duplicated';
  31. actionIcon = 'icon-docs';
  32. break;
  33. case SupportedAction.ACTION_PAGE_DELETE:
  34. actionMsg = 'deleted';
  35. actionIcon = 'icon-trash';
  36. break;
  37. case SupportedAction.ACTION_PAGE_DELETE_COMPLETELY:
  38. actionMsg = 'completely deleted';
  39. actionIcon = 'icon-fire';
  40. break;
  41. case SupportedAction.ACTION_PAGE_REVERT:
  42. actionMsg = 'reverted';
  43. actionIcon = 'icon-action-undo';
  44. break;
  45. case SupportedAction.ACTION_PAGE_RECURSIVELY_RENAME:
  46. actionMsg = 'renamed under';
  47. actionIcon = 'icon-action-redo';
  48. break;
  49. case SupportedAction.ACTION_PAGE_RECURSIVELY_DELETE:
  50. actionMsg = 'deleted under';
  51. actionIcon = 'icon-trash';
  52. break;
  53. case SupportedAction.ACTION_PAGE_RECURSIVELY_DELETE_COMPLETELY:
  54. actionMsg = 'deleted completely under';
  55. actionIcon = 'icon-fire';
  56. break;
  57. case SupportedAction.ACTION_PAGE_RECURSIVELY_REVERT:
  58. actionMsg = 'reverted under';
  59. actionIcon = 'icon-action-undo';
  60. break;
  61. case SupportedAction.ACTION_COMMENT_CREATE:
  62. actionMsg = 'commented on';
  63. actionIcon = 'icon-bubble';
  64. break;
  65. case SupportedAction.ACTION_USER_REGISTRATION_APPROVAL_REQUEST:
  66. actionMsg = 'requested registration approval';
  67. actionIcon = 'icon-bubble';
  68. break;
  69. default:
  70. actionMsg = '';
  71. actionIcon = '';
  72. }
  73. return {
  74. actionMsg,
  75. actionIcon,
  76. };
  77. };