import PropTypes from 'prop-types'; import { PureComponent } from 'react'; import { FormattedMessage } from 'react-intl'; import classNames from 'classnames'; import api from 'flavours/glitch/api'; import { Hashtag } from 'flavours/glitch/components/hashtag'; export default class Trends extends PureComponent { static propTypes = { limit: PropTypes.number.isRequired, }; state = { loading: true, data: null, }; componentDidMount () { const { limit } = this.props; api().get('/api/v1/admin/trends/tags', { params: { limit } }).then(res => { this.setState({ loading: false, data: res.data, }); }).catch(err => { console.error(err); }); } render () { const { limit } = this.props; const { loading, data } = this.state; let content; if (loading) { content = (
{Array.from(Array(limit)).map((_, i) => ( ))}
); } else { content = (
{data.map(hashtag => ( day.uses)} className={classNames(hashtag.requires_review && 'trends__item--requires-review', !hashtag.trendable && !hashtag.requires_review && 'trends__item--disabled')} /> ))}
); } return (

{content}
); } }