project-notifications-setting.tsx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. {/* TODO: update forms link */}
  71. <a
  72. target="_blank"
  73. rel="noopener noreferrer"
  74. href="https://forms.gle/"
  75. >
  76. {t('give_feedback')}
  77. </a>
  78. </div>
  79. </div>
  80. </>
  81. )}
  82. </>
  83. )
  84. }