var injectIntl = require('react-intl').injectIntl;
var React = require('react');
var render = require('../../lib/render.jsx');
var Api = require('../../mixins/api.jsx');
var Session = require('../../mixins/session.jsx');
var Activity = require('../../components/activity/activity.jsx');
var AdminPanel = require('../../components/adminpanel/adminpanel.jsx');
var Box = require('../../components/box/box.jsx');
var Button = require('../../components/forms/button.jsx');
var Carousel = require('../../components/carousel/carousel.jsx');
var Intro = require('../../components/intro/intro.jsx');
var News = require('../../components/news/news.jsx');
require('./splash.scss');
var Splash = injectIntl(React.createClass({
type: 'Splash',
mixins: [
Api,
Session
],
getInitialState: function () {
return {
projectCount: 10569070,
activity: [],
news: [],
featuredCustom: {},
featuredGlobal: {}
};
},
getGlobalHomepageRows: function () {
this.api({
uri: '/proxy/featured'
}, function (err, body) {
if (!err) this.setState({featuredGlobal: body});
}.bind(this));
},
getCustomHomepageRows: function () {
this.api({
uri: '/proxy/users/' + this.state.session.user.id + '/featured'
}, function (err, body) {
if (!err) this.setState({featuredCustom: body});
}.bind(this));
},
componentDidUpdate: function (prevProps, prevState) {
if (this.state.session.user != prevState.session.user) {
if (this.state.session.user) {
this.getActivity();
this.getCustomHomepageRows();
this.getNews();
} else {
this.setState({featuredCustom: []});
}
}
},
componentDidMount: function () {
this.getGlobalHomepageRows();
if (this.state.session.user) {
this.getActivity();
this.getCustomHomepageRows();
this.getNews();
}
},
getNews: function () {
this.api({
uri: '/news?limit=3'
}, function (err, body) {
if (!err) this.setState({'news': body});
}.bind(this));
},
getActivity: function () {
this.api({
uri: '/proxy/users/' + this.state.session.user.username + '/activity?limit=5'
}, function (err, body) {
if (!err) this.setState({'activity': body});
}.bind(this));
},
renderHomepageRows: function () {
var formatMessage = this.props.intl.formatMessage;
var rows = [