You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.9 KiB

  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { Helmet } from 'react-helmet';
  4. import { FormattedMessage, FormattedDate, injectIntl, defineMessages } from 'react-intl';
  5. import Column from 'mastodon/components/column';
  6. import api from 'mastodon/api';
  7. import Skeleton from 'mastodon/components/skeleton';
  8. const messages = defineMessages({
  9. title: { id: 'privacy_policy.title', defaultMessage: 'Privacy Policy' },
  10. });
  11. class PrivacyPolicy extends React.PureComponent {
  12. static propTypes = {
  13. intl: PropTypes.object,
  14. multiColumn: PropTypes.bool,
  15. };
  16. state = {
  17. content: null,
  18. lastUpdated: null,
  19. isLoading: true,
  20. };
  21. componentDidMount () {
  22. api().get('/api/v1/instance/privacy_policy').then(({ data }) => {
  23. this.setState({ content: data.content, lastUpdated: data.updated_at, isLoading: false });
  24. }).catch(() => {
  25. this.setState({ isLoading: false });
  26. });
  27. }
  28. render () {
  29. const { intl, multiColumn } = this.props;
  30. const { isLoading, content, lastUpdated } = this.state;
  31. return (
  32. <Column bindToDocument={!multiColumn} label={intl.formatMessage(messages.title)}>
  33. <div className='scrollable privacy-policy'>
  34. <div className='column-title'>
  35. <h3><FormattedMessage id='privacy_policy.title' defaultMessage='Privacy Policy' /></h3>
  36. <p><FormattedMessage id='privacy_policy.last_updated' defaultMessage='Last updated {date}' values={{ date: isLoading ? <Skeleton width='10ch' /> : <FormattedDate value={lastUpdated} year='numeric' month='short' day='2-digit' /> }} /></p>
  37. </div>
  38. <div
  39. className='privacy-policy__body prose'
  40. dangerouslySetInnerHTML={{ __html: content }}
  41. />
  42. </div>
  43. <Helmet>
  44. <title>{intl.formatMessage(messages.title)}</title>
  45. <meta name='robots' content='all' />
  46. </Helmet>
  47. </Column>
  48. );
  49. }
  50. }
  51. export default injectIntl(PrivacyPolicy);