project-notifications-setting.tsx 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import { useTranslation } from 'react-i18next'
  2. import RadioButtonSetting, { RadioOption } from '../radio-button-setting'
  3. import {
  4. SettableNotificationLevel,
  5. useProjectNotificationPreferences,
  6. } from '../../hooks/use-project-notification-preferences'
  7. import BetaBadgeIcon from '@/shared/components/beta-badge-icon'
  8. import LoadingSpinner from '@/shared/components/loading-spinner'
  9. export default function ProjectNotificationsSetting() {
  10. const { t } = useTranslation()
  11. const { notificationLevel, setNotificationLevel, isLoading } =
  12. useProjectNotificationPreferences()
  13. if (isLoading) {
  14. return <LoadingSpinner loadingText={t('loading')} />
  15. }
  16. const options: Array<RadioOption<SettableNotificationLevel>> = [
  17. {
  18. value: 'all',
  19. label: t('all_project_activity'),
  20. description: t('all_project_activity_description'),
  21. },
  22. {
  23. value: 'replies',
  24. label: t('replies_to_your_activity_only'),
  25. description: t('replies_to_your_activity_only_description'),
  26. },
  27. {
  28. value: 'off',
  29. label: t('off'),
  30. description: t('no_project_notifications_description'),
  31. },
  32. ]
  33. return (
  34. <>
  35. {notificationLevel === 'global-off' ? (
  36. <div className="ide-setting-description">
  37. {t('project_notifications_muted_description')}{' '}
  38. <a
  39. href="/user/notification-preferences"
  40. target="_blank"
  41. rel="noopener noreferrer"
  42. >
  43. {t('change_settings')}
  44. </a>
  45. </div>
  46. ) : (
  47. <>
  48. <RadioButtonSetting
  49. id="projectNotifications"
  50. options={options}
  51. value={notificationLevel}
  52. onChange={setNotificationLevel}
  53. />
  54. <div className="global-notifications-link">
  55. <a
  56. href="/user/notification-preferences"
  57. target="_blank"
  58. rel="noopener noreferrer"
  59. >
  60. {t('manage_overleaf_email_preferences')}
  61. </a>
  62. </div>
  63. <div className="project-notifications-beta-note">
  64. <BetaBadgeIcon />
  65. <div>
  66. <span className="ide-setting-description">
  67. {t('email_notifications_are_currently_in_beta')}{' '}
  68. {t('these_settings_might_change_in_the_future')}{' '}
  69. </span>
  70. <a
  71. target="_blank"
  72. rel="noopener noreferrer"
  73. href="https://forms.gle/unCNQedYXChTn2Qo6"
  74. >
  75. {t('give_feedback')}
  76. </a>
  77. </div>
  78. </div>
  79. </>
  80. )}
  81. </>
  82. )
  83. }