show pages to unauthenticated user
This commit is contained in:
@@ -2,36 +2,29 @@ import type { FC } from "react";
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Switch, Route } from "react-router-dom";
|
import { Switch, Route } from "react-router-dom";
|
||||||
|
|
||||||
import { useCurrentUser } from "./contexts/UserProvider";
|
|
||||||
import { Dashbaord, Home, Orders, Wallet } from "./pages";
|
import { Dashbaord, Home, Orders, Wallet } from "./pages";
|
||||||
|
|
||||||
export const Routes: FC = () => {
|
export const Routes: FC = () => {
|
||||||
const { isAuthenticated } = useCurrentUser();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path="/">
|
<Route exact path="/">
|
||||||
<Home />
|
<Home />
|
||||||
</Route>
|
</Route>
|
||||||
{isAuthenticated && (
|
<Route exact path="/dashboard">
|
||||||
<>
|
<Dashbaord />
|
||||||
<Route exact path="/dashboard">
|
</Route>
|
||||||
<Dashbaord />
|
<Route exact path="/wallet">
|
||||||
</Route>
|
<Wallet />
|
||||||
<Route exact path="/wallet">
|
</Route>
|
||||||
<Wallet />
|
<Route exact path="/orders/exchange">
|
||||||
</Route>
|
<Orders.Exchange />
|
||||||
<Route exact path="/orders/exchange">
|
</Route>
|
||||||
<Orders.Exchange />
|
<Route exact path="/orders/stake">
|
||||||
</Route>
|
<Orders.Stake />
|
||||||
<Route exact path="/orders/stake">
|
</Route>
|
||||||
<Orders.Stake />
|
<Route exact path="/orders/deposit">
|
||||||
</Route>
|
<Orders.Deposit />
|
||||||
<Route exact path="/orders/deposit">
|
</Route>
|
||||||
<Orders.Deposit />
|
|
||||||
</Route>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Switch>
|
</Switch>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,8 +25,7 @@ export const Navbar = () => {
|
|||||||
<nav className="w-full h-16 flex bg-white shadow items-center px-4 space-x-2 z-50">
|
<nav className="w-full h-16 flex bg-white shadow items-center px-4 space-x-2 z-50">
|
||||||
<button
|
<button
|
||||||
className={cs(
|
className={cs(
|
||||||
"w-12 mr-2 md:w-10 h-12 md:h-10 xl:hidden fixed md:relative bottom-8 md:bottom-auto right-8 md:right-auto bg-white rounded-full p-3 md:p-0 shadow md:shadow-none",
|
"w-12 mr-2 md:w-10 h-12 md:h-10 xl:hidden fixed md:relative bottom-8 md:bottom-auto right-8 md:right-auto bg-white rounded-full p-3 md:p-0 shadow md:shadow-none"
|
||||||
isAuthenticated ? "" : "hidden"
|
|
||||||
)}
|
)}
|
||||||
onClick={() => handleExpandSideNav()}
|
onClick={() => handleExpandSideNav()}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { Transition } from "@headlessui/react";
|
|||||||
import cs from "classnames";
|
import cs from "classnames";
|
||||||
|
|
||||||
import { useApp } from "../../contexts/AppProvider";
|
import { useApp } from "../../contexts/AppProvider";
|
||||||
import { useCurrentUser } from "../../contexts/UserProvider";
|
|
||||||
|
|
||||||
type MenuItem = {
|
type MenuItem = {
|
||||||
label: string;
|
label: string;
|
||||||
@@ -39,7 +38,6 @@ const MenuItems: MenuItem[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export const SideNav = () => {
|
export const SideNav = () => {
|
||||||
const { isAuthenticated } = useCurrentUser();
|
|
||||||
const { sideNavExpanded, setSideNavExpanded } = useApp();
|
const { sideNavExpanded, setSideNavExpanded } = useApp();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
@@ -53,8 +51,6 @@ export const SideNav = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!isAuthenticated) return null;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Transition
|
<Transition
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import type { YieldwatchResponse } from "../../types/yieldwatch";
|
|||||||
import { VaultCard } from "./VaultCard";
|
import { VaultCard } from "./VaultCard";
|
||||||
|
|
||||||
export const Dashbaord: FC = () => {
|
export const Dashbaord: FC = () => {
|
||||||
const { user } = useCurrentUser();
|
const { user, isAuthenticated } = useCurrentUser();
|
||||||
const { data } = useSWR<YieldwatchResponse>(
|
const { data } = useSWR<YieldwatchResponse>(
|
||||||
`https://www.yieldwatch.net/api/all/${user?.walletAddress}?platforms=pancake`
|
`https://www.yieldwatch.net/api/all/${user?.walletAddress}?platforms=pancake`
|
||||||
);
|
);
|
||||||
@@ -17,6 +17,8 @@ export const Dashbaord: FC = () => {
|
|||||||
const isLoading = !data;
|
const isLoading = !data;
|
||||||
const vaults = data?.result?.PancakeSwap?.staking?.vaults;
|
const vaults = data?.result?.PancakeSwap?.staking?.vaults;
|
||||||
|
|
||||||
|
if (!isAuthenticated) return <Messages.Unauthenticated />;
|
||||||
|
|
||||||
if (isLoading)
|
if (isLoading)
|
||||||
return (
|
return (
|
||||||
<div className="w-full grid place-items-center">
|
<div className="w-full grid place-items-center">
|
||||||
|
|||||||
@@ -9,8 +9,10 @@ import { History } from "./History";
|
|||||||
import { Create } from "./Create";
|
import { Create } from "./Create";
|
||||||
import { DepositProvider, useDepositContext } from "./DepositProvider";
|
import { DepositProvider, useDepositContext } from "./DepositProvider";
|
||||||
import { Show } from "./Show";
|
import { Show } from "./Show";
|
||||||
|
import { useCurrentUser } from "../../../contexts/UserProvider";
|
||||||
|
|
||||||
const Component: FC = () => {
|
const Component: FC = () => {
|
||||||
|
const { isAuthenticated } = useCurrentUser();
|
||||||
const { fetchKey } = useDepositContext();
|
const { fetchKey } = useDepositContext();
|
||||||
|
|
||||||
const { depositOrders } = useLazyLoadQuery<DepositQuery>(
|
const { depositOrders } = useLazyLoadQuery<DepositQuery>(
|
||||||
@@ -29,6 +31,8 @@ const Component: FC = () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!isAuthenticated) return <Messages.Unauthenticated />;
|
||||||
|
|
||||||
if (!depositOrders.totalCount)
|
if (!depositOrders.totalCount)
|
||||||
return (
|
return (
|
||||||
<Messages.NoHistory historyName="depósito">
|
<Messages.NoHistory historyName="depósito">
|
||||||
|
|||||||
@@ -6,8 +6,11 @@ import { useLazyLoadQuery } from "react-relay";
|
|||||||
import { ExchangePanel } from "./ExchangePanel";
|
import { ExchangePanel } from "./ExchangePanel";
|
||||||
import { ExchangeHistory } from "./ExchangeHistory";
|
import { ExchangeHistory } from "./ExchangeHistory";
|
||||||
import type { ExchangeQuery } from "./__generated__/ExchangeQuery.graphql";
|
import type { ExchangeQuery } from "./__generated__/ExchangeQuery.graphql";
|
||||||
|
import { Messages } from "../../../messages";
|
||||||
|
import { useCurrentUser } from "../../../contexts/UserProvider";
|
||||||
|
|
||||||
export const Exchange = () => {
|
export const Exchange = () => {
|
||||||
|
const { isAuthenticated } = useCurrentUser();
|
||||||
const data = useLazyLoadQuery<ExchangeQuery>(
|
const data = useLazyLoadQuery<ExchangeQuery>(
|
||||||
graphql`
|
graphql`
|
||||||
query ExchangeQuery {
|
query ExchangeQuery {
|
||||||
@@ -25,6 +28,8 @@ export const Exchange = () => {
|
|||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!isAuthenticated) return <Messages.Unauthenticated />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<ExchangePanel userRef={data.currentUser} />
|
<ExchangePanel userRef={data.currentUser} />
|
||||||
|
|||||||
@@ -8,8 +8,10 @@ import { getStatusTextAndColors } from "../utils/processStatus";
|
|||||||
import type { StakeQuery } from "./__generated__/StakeQuery.graphql";
|
import type { StakeQuery } from "./__generated__/StakeQuery.graphql";
|
||||||
import { Messages } from "../../../messages";
|
import { Messages } from "../../../messages";
|
||||||
import { Table, TableRow } from "../../../components";
|
import { Table, TableRow } from "../../../components";
|
||||||
|
import { useCurrentUser } from "../../../contexts/UserProvider";
|
||||||
|
|
||||||
export const Stake: FC = () => {
|
export const Stake: FC = () => {
|
||||||
|
const { isAuthenticated } = useCurrentUser();
|
||||||
const { stakeOrders } = useLazyLoadQuery<StakeQuery>(
|
const { stakeOrders } = useLazyLoadQuery<StakeQuery>(
|
||||||
graphql`
|
graphql`
|
||||||
query StakeQuery {
|
query StakeQuery {
|
||||||
@@ -29,6 +31,8 @@ export const Stake: FC = () => {
|
|||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!isAuthenticated) return <Messages.Unauthenticated />;
|
||||||
|
|
||||||
if (!stakeOrders.edges.length)
|
if (!stakeOrders.edges.length)
|
||||||
return <Messages.NoHistory historyName="Stake" />;
|
return <Messages.NoHistory historyName="Stake" />;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user