From 2fd9c814312de81da2c8777603aa441af3e6f7a9 Mon Sep 17 00:00:00 2001 From: Sendou Date: Fri, 13 Mar 2020 14:46:46 +0200 Subject: [PATCH] access page implemented --- .../src/components/plus/MapVoting.tsx | 13 +++++++++-- frontend-react/src/components/root/Access.tsx | 23 +++++++++++++++++++ frontend-react/src/components/root/Routes.tsx | 2 ++ 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 frontend-react/src/components/root/Access.tsx diff --git a/frontend-react/src/components/plus/MapVoting.tsx b/frontend-react/src/components/plus/MapVoting.tsx index d518fe9ef..aec1f8580 100644 --- a/frontend-react/src/components/plus/MapVoting.tsx +++ b/frontend-react/src/components/plus/MapVoting.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from "react" -import { RouteComponentProps, Link } from "@reach/router" +import { RouteComponentProps, Link, Redirect } from "@reach/router" import { useQuery, useMutation } from "@apollo/react-hooks" import { MAP_VOTES, MapVotesData } from "../../graphql/queries/mapVotes" import Error from "../common/Error" @@ -15,9 +15,15 @@ import { ADD_MAP_VOTES, } from "../../graphql/mutations/addMapVotes" import Alert from "../elements/Alert" +import { USER } from "../../graphql/queries/user" const MapVoting: React.FC = ({}) => { const { data, error, loading } = useQuery(MAP_VOTES) + const { + data: userData, + error: userQueryError, + loading: userQueryLoading, + } = useQuery(USER) const toast = useToast() const [votes, setVotes] = useState< { @@ -70,7 +76,10 @@ const MapVoting: React.FC = ({}) => { }, [data, error, loading]) if (error) return - if (loading) return + if (userQueryError) return + if (loading || userQueryLoading || !userData || !data) return + if (!userData.user) return + if (!data.mapVotes) return return ( <> diff --git a/frontend-react/src/components/root/Access.tsx b/frontend-react/src/components/root/Access.tsx new file mode 100644 index 000000000..b437d2d77 --- /dev/null +++ b/frontend-react/src/components/root/Access.tsx @@ -0,0 +1,23 @@ +import React from "react" +import { RouteComponentProps } from "@reach/router" +import Alert from "../elements/Alert" +import Button from "../elements/Button" +import { FaDiscord } from "react-icons/fa" +import { Box } from "@chakra-ui/core" + +const Access: React.FC = () => { + return ( + <> + + This part of sendou.ink is restricted. Please log in to confirm access. + + + + + + + + ) +} + +export default Access diff --git a/frontend-react/src/components/root/Routes.tsx b/frontend-react/src/components/root/Routes.tsx index 472090ed1..58b72abe4 100644 --- a/frontend-react/src/components/root/Routes.tsx +++ b/frontend-react/src/components/root/Routes.tsx @@ -17,6 +17,7 @@ const FreeAgentsPage = lazy(() => import("../freeagents/FreeAgentsPage")) const TeamPage = lazy(() => import("../team/TeamPage")) const XSearch = lazy(() => import("../xsearch/Top500BrowserPage")) const PlusPage = lazy(() => import("../plus/PlusPage")) +const Access = lazy(() => import("./Access")) const VotingHistoryPage = lazy(() => import("../plus/VotingHistoryPage")) const MapVoting = lazy(() => import("../plus/MapVoting")) const About = lazy(() => import("./About")) @@ -39,6 +40,7 @@ const Routes: React.FC = () => { +