// @flow import * as React from 'react'; import compose from 'recompose/compose'; import FullscreenView from 'src/components/fullscreenView'; import LoginButtonSet from 'src/components/loginButtonSet'; import { CommunityAvatar } from 'src/components/avatar'; import { CLIENT_URL } from 'src/api/constants'; import { Title, Subtitle, LoginImageContainer, FullscreenContent, CodeOfConduct, } from './style'; import viewNetworkHandler, { type ViewNetworkHandlerType, } from 'src/components/viewNetworkHandler'; import { getCommunityByMatch, type GetCommunityType, } from 'shared/graphql/queries/community/getCommunity'; import queryString from 'query-string'; import { LoadingView, ErrorView } from 'src/views/viewHelpers'; import { OutlineButton } from 'src/components/button'; type Props = { data: { community: GetCommunityType, }, ...$Exact, history: Object, location: Object, match: Object, redirectPath: ?string, }; type State = { redirectPath: ?string, }; export class Login extends React.Component { constructor(props: Props) { super(props); this.state = { redirectPath: props.redirectPath, }; } escape = () => { this.props.history.push(`/${this.props.match.params.communitySlug}`); }; componentDidMount() { const { location, redirectPath } = this.props; if (redirectPath) { this.setState({ redirectPath }); } if (location && !redirectPath) { const searchObj = queryString.parse(this.props.location.search); this.setState({ redirectPath: searchObj.r }); } } render() { const { data: { community }, isLoading, match, } = this.props; const { redirectPath } = this.state; if (community && community.id) { return ( Log in Spectrum is a place where communities can share, discuss, and grow together. Sign in below to get in on the conversation. Existing user? Click here to log in By using Spectrum, you agree to our{' '} Code of Conduct ); } if (isLoading) return ; return ; } } export default compose( getCommunityByMatch, viewNetworkHandler )(Login);