From 4560ca150e6fff1635daca1fc6fdfd5622d6a96b Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Fri, 23 Dec 2022 02:08:38 +0000 Subject: [PATCH] fix: don't show personal activity if no scores allow other stuff tho --- .../src/app/pages/dashboard/DashboardPage.tsx | 42 ++++--------------- .../dashboard/DashboardActivity.tsx | 10 ++++- .../dashboard/DashboardLoggedInNoScores.tsx | 25 +++++++++++ 3 files changed, 41 insertions(+), 36 deletions(-) create mode 100644 client/src/components/dashboard/DashboardLoggedInNoScores.tsx diff --git a/client/src/app/pages/dashboard/DashboardPage.tsx b/client/src/app/pages/dashboard/DashboardPage.tsx index 20241b24b..4ccb3b85f 100644 --- a/client/src/app/pages/dashboard/DashboardPage.tsx +++ b/client/src/app/pages/dashboard/DashboardPage.tsx @@ -1,20 +1,22 @@ import { APIFetchV1 } from "util/api"; +import { ChangeOpacity } from "util/color-opacity"; +import { CreateGoalMap } from "util/data"; import { RFA } from "util/misc"; import { NumericSOV } from "util/sorts"; import { heySplashes } from "util/splashes"; -import { ChangeOpacity } from "util/color-opacity"; -import { CreateGoalMap } from "util/data"; +import Activity from "components/activity/Activity"; +import DashboardActivity from "components/dashboard/DashboardActivity"; +import { DashboardHeader } from "components/dashboard/DashboardHeader"; import useSetSubheader from "components/layout/header/useSetSubheader"; import SessionCard from "components/sessions/SessionCard"; import ApiError from "components/util/ApiError"; import AsyncLoader from "components/util/AsyncLoader"; import Divider from "components/util/Divider"; -import GentleLink from "components/util/GentleLink"; +import GoalLink from "components/util/GoalLink"; import LinkButton from "components/util/LinkButton"; import Loading from "components/util/Loading"; import useApiQuery from "components/util/query/useApiQuery"; import { UserContext } from "context/UserContext"; -import { AllLUGPTStatsContext } from "context/AllLUGPTStatsContext"; import { UserSettingsContext } from "context/UserSettingsContext"; import { ColourConfig, TachiConfig } from "lib/config"; import React, { useContext, useMemo } from "react"; @@ -22,29 +24,19 @@ import { Alert } from "react-bootstrap"; import { Link, Route, Switch } from "react-router-dom"; import { COLOUR_SET, GetGameConfig, UserDocument } from "tachi-common"; import { UGSWithRankingData, UserRecentSummary } from "types/api-returns"; -import { DashboardHeader } from "components/dashboard/DashboardHeader"; -import DashboardActivity from "components/dashboard/DashboardActivity"; -import GoalLink from "components/util/GoalLink"; -import Activity from "components/activity/Activity"; -import { FolderInfoComponent } from "./users/games/_game/_playtype/folders/FolderSelectPage"; import { GameStatContainer } from "./users/UserGamesPage"; export function DashboardPage() { const { settings } = useContext(UserSettingsContext); - useSetSubheader("Dashboard", [settings]); + useSetSubheader("Home", [settings]); const { user } = useContext(UserContext); - const { ugs } = useContext(AllLUGPTStatsContext); if (!user) { return ; } - if (ugs?.length === 0) { - return ; - } - return ; } @@ -277,23 +269,3 @@ function FeatureContainer({ tagline, description }: { tagline: string; descripti ); } - -function DashboardLoggedInNoScores({ user }: { user: UserDocument }) { - return ( -
- - Welcome to {TachiConfig.name}, {user.username}! - -

It looks like you have no scores. Let's get you set up!

- -

- Once you've got some scores imported, we'll analyse your scores. -
- You'll get a profile for that game, and a position on the leaderboards! -

- - Import some scores! - -
- ); -} diff --git a/client/src/components/dashboard/DashboardActivity.tsx b/client/src/components/dashboard/DashboardActivity.tsx index cdcf136f8..b1b33ec8c 100644 --- a/client/src/components/dashboard/DashboardActivity.tsx +++ b/client/src/components/dashboard/DashboardActivity.tsx @@ -1,8 +1,16 @@ import Activity from "components/activity/Activity"; -import React from "react"; +import { AllLUGPTStatsContext } from "context/AllLUGPTStatsContext"; +import React, { useContext } from "react"; import { UserDocument } from "tachi-common"; +import { DashboardLoggedInNoScores } from "./DashboardLoggedInNoScores"; export default function DashboardActivity({ user }: { user: UserDocument }) { + const { ugs } = useContext(AllLUGPTStatsContext); + + if (ugs?.length === 0) { + return ; + } + return ( <>
Here's what's been happening.
diff --git a/client/src/components/dashboard/DashboardLoggedInNoScores.tsx b/client/src/components/dashboard/DashboardLoggedInNoScores.tsx new file mode 100644 index 000000000..a532e2697 --- /dev/null +++ b/client/src/components/dashboard/DashboardLoggedInNoScores.tsx @@ -0,0 +1,25 @@ +import Divider from "components/util/Divider"; +import LinkButton from "components/util/LinkButton"; +import { TachiConfig } from "lib/config"; +import React from "react"; +import { UserDocument } from "tachi-common"; + +export function DashboardLoggedInNoScores({ user }: { user: UserDocument }) { + return ( +
+ + Welcome to {TachiConfig.name}, {user.username}! + +

It looks like you have no scores. Let's get you set up!

+ +

+ Once you've got some scores imported, we'll analyse your scores. +
+ You'll get a profile for that game, and a position on the leaderboards! +

+ + Import some scores! + +
+ ); +}