newsletterConsent.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import {useEffect} from 'react';
  2. import {ApiForm, InputField} from 'sentry/components/forms';
  3. import RadioBoolean from 'sentry/components/forms/controls/radioBoolean';
  4. import FieldWrapper from 'sentry/components/forms/field/fieldWrapper';
  5. import ExternalLink from 'sentry/components/links/externalLink';
  6. import NarrowLayout from 'sentry/components/narrowLayout';
  7. import {t, tct} from 'sentry/locale';
  8. type Props = {
  9. onSubmitSuccess?: () => void;
  10. };
  11. function NewsletterConsent({onSubmitSuccess}: Props) {
  12. useEffect(() => {
  13. document.body.classList.add('auth');
  14. return () => document.body.classList.remove('auth');
  15. }, []);
  16. // NOTE: the text here is duplicated within ``RegisterForm`` on the backend
  17. return (
  18. <NarrowLayout>
  19. <ApiForm
  20. apiMethod="POST"
  21. apiEndpoint="/users/me/subscriptions/"
  22. onSubmitSuccess={onSubmitSuccess}
  23. submitLabel={t('Continue')}
  24. >
  25. <FieldWrapper stacked={false} hasControlState={false}>
  26. {t('Pardon the interruption, we just need to get a quick answer from you.')}
  27. </FieldWrapper>
  28. <InputField
  29. name="subscribed"
  30. key="subscribed"
  31. label={t('Email Updates')}
  32. required
  33. inline={false}
  34. help={tct(
  35. `We'd love to keep you updated via email with product and feature
  36. announcements, promotions, educational materials, and events. Our updates
  37. focus on relevant information, and we'll never sell your data to third
  38. parties. See our [link:Privacy Policy] for more details.
  39. `,
  40. {link: <ExternalLink href="https://sentry.io/privacy/" />}
  41. )}
  42. field={fieldProps => (
  43. <RadioBoolean
  44. {...fieldProps}
  45. label={t('Email Updates')}
  46. yesLabel={t('Yes, I would like to receive updates via email')}
  47. noLabel={t("No, I'd prefer not to receive these updates")}
  48. />
  49. )}
  50. />
  51. </ApiForm>
  52. </NarrowLayout>
  53. );
  54. }
  55. export default NewsletterConsent;