var injectIntl = require('react-intl').injectIntl; var omit = require('lodash.omit'); 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 Banner = require('../../components/banner/banner.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 Modal = require('../../components/modal/modal.jsx'); var News = require('../../components/news/news.jsx'); var Welcome = require('../../components/welcome/welcome.jsx'); require('./splash.scss'); var Splash = injectIntl(React.createClass({ type: 'Splash', mixins: [ Api, Session ], getInitialState: function () { return { projectCount: 10569070, activity: [], news: [], featuredCustom: {}, featuredGlobal: {}, showEmailConfirmationModal: false }; }, componentDidUpdate: function (prevProps, prevState) { if (this.state.session.user != prevState.session.user) { if (this.state.session.user) { this.getActivity(); this.getFeaturedCustom(); this.getNews(); } else { this.setState({featuredCustom: []}); this.getProjectCount(); } } }, componentDidMount: function () { this.getFeaturedGlobal(); if (this.state.session.user) { this.getActivity(); this.getFeaturedCustom(); this.getNews(); } else { this.getProjectCount(); } }, 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)); }, getFeaturedGlobal: function () { this.api({ uri: '/proxy/featured' }, function (err, body) { if (!err) this.setState({featuredGlobal: body}); }.bind(this)); }, getFeaturedCustom: function () { this.api({ uri: '/proxy/users/' + this.state.session.user.id + '/featured' }, function (err, body) { if (!err) this.setState({featuredCustom: body}); }.bind(this)); }, getNews: function () { this.api({ uri: '/news?limit=3' }, function (err, body) { if (!err) this.setState({'news': body}); }.bind(this)); }, getProjectCount: function () { this.api({ uri: '/projects/count/all' }, function (err, body) { if (!err) this.setState({projectCount: body.count}); }.bind(this)); }, showEmailConfirmationModal: function () { this.setState({showEmailConfirmationModal: true}); }, hideEmailConfirmationModal: function () { this.setState({showEmailConfirmationModal: false}); }, handleDismiss: function (cue) { this.api({ host: '', uri: '/site-api/users/set-template-cue/', method: 'post', useCsrf: true, json: {cue: cue, value: false} }, function (err) { if (!err) window.refreshSession(); }); }, renderHomepageRows: function () { var formatMessage = this.props.intl.formatMessage; var rows = [ , ]; if (this.state.featuredGlobal.curator_top_projects && this.state.featuredGlobal.curator_top_projects.length > 4) { rows.push( ); } if (this.state.featuredGlobal.scratch_design_studio && this.state.featuredGlobal.scratch_design_studio.length > 4) { rows.push( ); } if (this.state.session.user && this.state.featuredGlobal.community_newest_projects && this.state.featuredGlobal.community_newest_projects.length > 0) { rows.push( ); } if (this.state.featuredCustom.custom_projects_by_following && this.state.featuredCustom.custom_projects_by_following.length > 0) { rows.push( ); } if (this.state.featuredCustom.custom_projects_loved_by_following && this.state.featuredCustom.custom_projects_loved_by_following.length > 0) { rows.push( ); } if (this.state.featuredCustom.custom_projects_in_studios_following && this.state.featuredCustom.custom_projects_in_studios_following.length > 0) { rows.push( ); } rows.push( , ); return rows; }, render: function () { var featured = this.renderHomepageRows(); var showEmailConfirmation = true;( this.state.session.user && this.state.session.flags.has_outstanding_email_confirmation && this.state.session.flags.confirm_email_banner); return (
{showEmailConfirmation ? [ Confirm your email to enable sharing.{' '} Having trouble? ,