import { Link } from "../routes"; import Head from "../components/head"; import Nav from "../components/nav"; import withRedux from "next-redux-wrapper"; import Header from "../components/Header"; import Button from "../components/Button"; import cookies from "next-cookies"; import Text from "../components/Text"; import _ from "lodash"; import { updateEntities, setCurrentUser, initStore } from "../redux/store"; import { getFeaturedProfiles, getCurrentUser } from "../api"; import { bindActionCreators } from "redux"; import { Router } from "../routes"; import PageFooter from "../components/PageFooter"; import withLogin from "../lib/withLogin"; import qs from "qs"; import LazyLoad from "react-lazyload"; import { buildImgSrcSet } from "../lib/imgUri"; import { buildProfileURL } from "../lib/routeHelpers"; import LoginGate, { LOGIN_STATUSES } from "../components/LoginGate"; import Divider from "../components/Divider"; import { SPACING } from "../helpers/styles"; const FeaturedProfile = ({ profile }) => { return (
{profile.name}
{(profile.tagline || "").substr(0, 100)}
); }; class SignupForm extends React.Component { constructor(props) { super(props); this.state = { email: this.props.email || "", }; } setEmail = (evt) => this.setState({ email: evt.target.value }); componentDidMount() { Router.prefetchRoute(`/sign-up/verify`); } handleSubmit = (evt) => { evt.preventDefault(); Router.pushRoute( `/sign-up/verify?${qs.stringify({ email: this.state.email })}`, ); }; render() { return (
); } } class Homepage extends React.Component { constructor(props) { super(props); this.state = { isLoadingProfiles: true, profiles: [], }; } static async getInitialProps(ctx) { if (ctx.isServer && ctx.req.path === "/") { const { currentUserId } = cookies(ctx); if (currentUserId) { ctx.res.writeHead(302, { Location: `${process.env.DOMAIN}/welcome`, }); ctx.res.end(); ctx.res.finished = true; } } } async componentDidMount() { const profileResponse = await getFeaturedProfiles(); this.props.updateEntities(profileResponse.body); this.setState({ isLoadingProfiles: false, profiles: profileResponse.body.data, }); Router.prefetchRoute(`/lucy`); } render() { return (
Your own game of The Bachelor(ette)
Create a page where people apply to go on a date with you. You pick the winners.
{!this.props.currentUserId && }
Featured pages
{this.state.isLoadingProfiles &&
}
{!_.isEmpty(this.state.profiles) && this.state.profiles.map((profile) => ( ))}
); } } const HomepageWithStore = withRedux(initStore, null, (dispatch) => bindActionCreators({ updateEntities, setCurrentUser }, dispatch), )(LoginGate(Homepage)); export default HomepageWithStore;