index.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. export default @injectIntl
  12. class PrivacyPolicy extends React.PureComponent {
  13. static propTypes = {
  14. intl: PropTypes.object,
  15. multiColumn: PropTypes.bool,
  16. };
  17. state = {
  18. content: null,
  19. lastUpdated: null,
  20. isLoading: true,
  21. };
  22. componentDidMount () {
  23. api().get('/api/v1/instance/privacy_policy').then(({ data }) => {
  24. this.setState({ content: data.content, lastUpdated: data.updated_at, isLoading: false });
  25. }).catch(() => {
  26. this.setState({ isLoading: false });
  27. });
  28. }
  29. render () {
  30. const { intl, multiColumn } = this.props;
  31. const { isLoading, content, lastUpdated } = this.state;
  32. return (
  33. <Column bindToDocument={!multiColumn} label={intl.formatMessage(messages.title)}>
  34. <div className='scrollable privacy-policy'>
  35. <div className='column-title'>
  36. <h3><FormattedMessage id='privacy_policy.title' defaultMessage='Privacy Policy' /></h3>
  37. <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>
  38. </div>
  39. <div
  40. className='privacy-policy__body prose'
  41. dangerouslySetInnerHTML={{ __html: content }}
  42. />
  43. </div>
  44. <Helmet>
  45. <title>{intl.formatMessage(messages.title)}</title>
  46. <meta name='robots' content='all' />
  47. </Helmet>
  48. </Column>
  49. );
  50. }
  51. }