Showing
1 changed file
with
21 additions
and
1 deletions
| ... | @@ -2,11 +2,31 @@ import React from "react"; | ... | @@ -2,11 +2,31 @@ import React from "react"; |
| 2 | import Header from "../Components/Header"; | 2 | import Header from "../Components/Header"; |
| 3 | import Main from "../Components/Main"; | 3 | import Main from "../Components/Main"; |
| 4 | import Footer from "../Components/Footer"; | 4 | import Footer from "../Components/Footer"; |
| 5 | +import { gql } from "@apollo/client"; | ||
| 6 | +import { useQuery } from "@apollo/react-hooks"; | ||
| 7 | + | ||
| 8 | +const checkLogin = gql` | ||
| 9 | + { | ||
| 10 | + isLoggedIn @client | ||
| 11 | + } | ||
| 12 | +`; | ||
| 5 | 13 | ||
| 6 | export default () => { | 14 | export default () => { |
| 15 | + const { | ||
| 16 | + data: { isLoggedIn }, | ||
| 17 | + } = useQuery(checkLogin); | ||
| 18 | + | ||
| 19 | + let btnState; | ||
| 20 | + | ||
| 21 | + if (isLoggedIn) { | ||
| 22 | + btnState = "roomlist"; | ||
| 23 | + } else { | ||
| 24 | + btnState = "main"; | ||
| 25 | + } | ||
| 26 | + | ||
| 7 | return ( | 27 | return ( |
| 8 | <> | 28 | <> |
| 9 | - <Header /> | 29 | + <Header btnStateProp={btnState} /> |
| 10 | <Main /> | 30 | <Main /> |
| 11 | <Footer /> | 31 | <Footer /> |
| 12 | </> | 32 | </> | ... | ... |
-
Please register or login to post a comment