index.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { title } from 'mastodon/initial_state';
  4. import { Helmet } from 'react-helmet';
  5. import { FormattedMessage, FormattedDate, injectIntl, defineMessages } from 'react-intl';
  6. import Column from 'mastodon/components/column';
  7. import api from 'mastodon/api';
  8. import Skeleton from 'mastodon/components/skeleton';
  9. const messages = defineMessages({
  10. title: { id: 'privacy_policy.title', defaultMessage: 'Privacy Policy' },
  11. });
  12. export default @injectIntl
  13. class PrivacyPolicy extends React.PureComponent {
  14. static propTypes = {
  15. intl: PropTypes.object,
  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 } = this.props;
  31. const { isLoading, content, lastUpdated } = this.state;
  32. return (
  33. <Column>
  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'
  41. dangerouslySetInnerHTML={{ __html: content }}
  42. />
  43. </div>
  44. <Helmet>
  45. <title>{intl.formatMessage(messages.title)} - {title}</title>
  46. </Helmet>
  47. </Column>
  48. );
  49. }
  50. }