diff --git a/client/src/app/pages/dashboard/users/games/_game/_playtype/LeaderboardsPage.tsx b/client/src/app/pages/dashboard/users/games/_game/_playtype/LeaderboardsPage.tsx index 1f80b68ec..1c233415d 100644 --- a/client/src/app/pages/dashboard/users/games/_game/_playtype/LeaderboardsPage.tsx +++ b/client/src/app/pages/dashboard/users/games/_game/_playtype/LeaderboardsPage.tsx @@ -24,18 +24,14 @@ import { } from "tachi-common"; import { GameClassSets } from "tachi-common/game-classes"; import { GPTLeaderboard, UGPTLeaderboardAdjacent } from "types/api-returns"; -import { GamePT, SetState } from "types/react"; +import { GamePT, SetState, UGPT } from "types/react"; interface LeaderboardsData { stats: UGPTLeaderboardAdjacent; leaderboard: GPTLeaderboard; } -export default function LeaderboardsPage({ - reqUser, - game, - playtype, -}: { reqUser: UserDocument } & GamePT) { +export default function LeaderboardsPage({ reqUser, game, playtype }: UGPT) { const gameConfig = GetGameConfig(game); useSetSubheader( ["Users", reqUser.username, "Games", gameConfig.name, playtype, "Leaderboard"], diff --git a/client/src/app/pages/dashboard/users/games/_game/_playtype/OverviewPage.tsx b/client/src/app/pages/dashboard/users/games/_game/_playtype/OverviewPage.tsx index dcf91597c..d36755104 100644 --- a/client/src/app/pages/dashboard/users/games/_game/_playtype/OverviewPage.tsx +++ b/client/src/app/pages/dashboard/users/games/_game/_playtype/OverviewPage.tsx @@ -29,7 +29,7 @@ import { UserGameStats, } from "tachi-common"; import { SessionReturns, UGPTHistory } from "types/api-returns"; -import { GamePT, SetState } from "types/react"; +import { GamePT, SetState, UGPT } from "types/react"; import { ScoreDataset } from "types/tables"; import SessionRaiseBreakdown from "components/sessions/SessionRaiseBreakdown"; import useApiQuery from "components/util/query/useApiQuery"; @@ -37,11 +37,7 @@ import ApiError from "components/util/ApiError"; import Loading from "components/util/Loading"; import Select from "components/util/Select"; -export default function OverviewPage({ - reqUser, - game, - playtype, -}: { reqUser: UserDocument } & GamePT) { +export default function OverviewPage({ reqUser, game, playtype }: UGPT) { const gameConfig = GetGameConfig(game); useSetSubheader( ["Users", reqUser.username, "Games", gameConfig.name, playtype], @@ -58,7 +54,7 @@ export default function OverviewPage({ ); } -function LastSession({ reqUser, game, playtype }: { reqUser: UserDocument } & GamePT) { +function LastSession({ reqUser, game, playtype }: UGPT) { return ( { @@ -255,7 +251,7 @@ function RecentSessionScoreInfo({ type RankingDurations = "3mo" | "year"; -function RankingInfo({ reqUser, game, playtype }: { reqUser: UserDocument } & GamePT) { +function RankingInfo({ reqUser, game, playtype }: UGPT) { const [duration, setDuration] = useState("3mo"); const { data, error } = useApiQuery( diff --git a/client/src/app/pages/dashboard/users/games/_game/_playtype/ScoresPage.tsx b/client/src/app/pages/dashboard/users/games/_game/_playtype/ScoresPage.tsx index 1d3e15c08..e20aff3de 100644 --- a/client/src/app/pages/dashboard/users/games/_game/_playtype/ScoresPage.tsx +++ b/client/src/app/pages/dashboard/users/games/_game/_playtype/ScoresPage.tsx @@ -26,7 +26,7 @@ import { SongDocument, UnsuccessfulAPIResponse, } from "tachi-common"; -import { GamePT, SetState } from "types/react"; +import { GamePT, SetState, UGPT } from "types/react"; import usePreferredRanking from "components/util/usePreferredRanking"; export default function ScoresPage({ @@ -286,7 +286,7 @@ function PBsSearch({ ); } -function ScoresOverview({ reqUser, game, playtype }: { reqUser: UserDocument } & GamePT) { +function ScoresOverview({ reqUser, game, playtype }: UGPT) { const [search, setSearch] = useState(""); const { data, error } = useFetchScores( diff --git a/client/src/app/pages/dashboard/users/games/_game/_playtype/SpecificSessionPage.tsx b/client/src/app/pages/dashboard/users/games/_game/_playtype/SpecificSessionPage.tsx index d767e68a1..9da1ccea3 100644 --- a/client/src/app/pages/dashboard/users/games/_game/_playtype/SpecificSessionPage.tsx +++ b/client/src/app/pages/dashboard/users/games/_game/_playtype/SpecificSessionPage.tsx @@ -15,13 +15,11 @@ import { UserContext } from "context/UserContext"; import React, { useContext, useMemo, useState } from "react"; import { Badge, Button, Col, Form, Modal, Row } from "react-bootstrap"; import { Redirect, useParams } from "react-router-dom"; -import { GetGameConfig, UserDocument, SessionDocument } from "tachi-common"; +import { GetGameConfig, SessionDocument } from "tachi-common"; import { SessionReturns } from "types/api-returns"; -import { GamePT, SetState } from "types/react"; +import { SetState, UGPT } from "types/react"; -type Props = { reqUser: UserDocument } & GamePT; - -export default function SpecificSessionPage({ reqUser, game, playtype }: Props) { +export default function SpecificSessionPage({ reqUser, game, playtype }: UGPT) { const { sessionID } = useParams<{ sessionID: string }>(); const { data, error } = useApiQuery(`/sessions/${sessionID}`); @@ -49,7 +47,7 @@ export default function SpecificSessionPage({ reqUser, game, playtype }: Props) return ; } -function SessionPage({ data, game, playtype }: Props & { data: SessionReturns }) { +function SessionPage({ data, game, playtype }: UGPT & { data: SessionReturns }) { const [sessionData, setSessionData] = useState(data); const { session, user, charts, scores, songs } = sessionData; diff --git a/client/src/app/pages/dashboard/users/games/_game/_playtype/UGPTSettingsPage.tsx b/client/src/app/pages/dashboard/users/games/_game/_playtype/UGPTSettingsPage.tsx index dbdcd437a..80fc52971 100644 --- a/client/src/app/pages/dashboard/users/games/_game/_playtype/UGPTSettingsPage.tsx +++ b/client/src/app/pages/dashboard/users/games/_game/_playtype/UGPTSettingsPage.tsx @@ -1,4 +1,5 @@ import { APIFetchV1 } from "util/api"; +import { ErrorPage } from "app/pages/ErrorPage"; import ClassBadge from "components/game/ClassBadge"; import useSetSubheader from "components/layout/header/useSetSubheader"; import Card from "components/layout/page/Card"; @@ -12,8 +13,9 @@ import Muted from "components/util/Muted"; import useApiQuery from "components/util/query/useApiQuery"; import SelectButton from "components/util/SelectButton"; import useQueryString from "components/util/useQueryString"; +import { UGPTContext } from "context/UGPTContext"; import deepmerge from "deepmerge"; -import { FieldArray, useFormik } from "formik"; +import { useFormik } from "formik"; import { TachiConfig } from "lib/config"; import React, { useContext, useEffect, useState } from "react"; import { Button, Col, Form, Row } from "react-bootstrap"; @@ -22,18 +24,14 @@ import { FormatGame, GetGameConfig, GetGamePTConfig, - UserDocument, ShowcaseStatDetails, TableDocument, UGPTSettings, + UserDocument, } from "tachi-common"; -import { GamePT, SetState } from "types/react"; -import { UGPTContext } from "context/UGPTContext"; -import { ErrorPage } from "app/pages/ErrorPage"; +import { SetState, UGPT } from "types/react"; -type Props = { reqUser: UserDocument } & GamePT; - -export default function UGPTSettingsPage({ reqUser, game, playtype }: Props) { +export default function UGPTSettingsPage({ reqUser, game, playtype }: UGPT) { const query = useQueryString(); const [page, setPage] = useState<"preferences" | "showcase">( @@ -47,7 +45,7 @@ export default function UGPTSettingsPage({ reqUser, game, playtype }: Props) { `${reqUser.username}'s ${FormatGame(game, playtype)} Settings` ); - const props = { reqUser, game, playtype }; + const UGPT = { reqUser, game, playtype }; return ( @@ -67,9 +65,9 @@ export default function UGPTSettingsPage({ reqUser, game, playtype }: Props) {
{page === "preferences" ? ( - + ) : ( - + )}
@@ -77,7 +75,7 @@ export default function UGPTSettingsPage({ reqUser, game, playtype }: Props) { ); } -function PreferencesForm({ reqUser, game, playtype }: Props) { +function PreferencesForm({ reqUser, game, playtype }: UGPT) { const { loggedInData, setLoggedInData } = useContext(UGPTContext); if (!loggedInData) { @@ -386,7 +384,7 @@ function PreferencesForm({ reqUser, game, playtype }: Props) { ); } -function ShowcaseForm({ reqUser, game, playtype }: Props) { +function ShowcaseForm({ reqUser, game, playtype }: UGPT) { const { loggedInData, setLoggedInData } = useContext(UGPTContext); if (!loggedInData) { @@ -468,7 +466,7 @@ function RenderCurrentStats({ }: { stats: ShowcaseStatDetails[]; setStats: SetState; -} & Props) { +} & UGPT) { function RemoveStatAtIndex(index: number) { setStats(stats.filter((e, i) => i !== index)); } diff --git a/client/src/app/pages/dashboard/users/games/_game/_playtype/folders/FolderSelectPage.tsx b/client/src/app/pages/dashboard/users/games/_game/_playtype/folders/FolderSelectPage.tsx index eefa93033..6edea59df 100644 --- a/client/src/app/pages/dashboard/users/games/_game/_playtype/folders/FolderSelectPage.tsx +++ b/client/src/app/pages/dashboard/users/games/_game/_playtype/folders/FolderSelectPage.tsx @@ -15,11 +15,9 @@ import { UserContext } from "context/UserContext"; import React, { useContext, useMemo, useState } from "react"; import { FolderDocument, GetGamePTConfig, UserDocument } from "tachi-common"; import { FolderStatsInfo, UGPTFolderSearch } from "types/api-returns"; -import { GamePT } from "types/react"; +import { GamePT, UGPT } from "types/react"; -type Props = { reqUser: UserDocument } & GamePT; - -export default function FoldersSearch({ reqUser, game, playtype }: Props) { +export default function FoldersSearch({ reqUser, game, playtype }: UGPT) { const [search, setSearch] = useState(""); const params = useMemo(() => new URLSearchParams({ search }), [search]); @@ -82,7 +80,7 @@ export function FolderInfoComponent({ playtype, folderStats, folder, -}: Props & { folder: FolderDocument; folderStats: FolderStatsInfo }) { +}: UGPT & { folder: FolderDocument; folderStats: FolderStatsInfo }) { const gptConfig = GetGamePTConfig(game, playtype); const scoreBucket = useBucket(game, playtype); diff --git a/client/src/app/pages/dashboard/users/games/_game/_playtype/folders/FoldersMainPage.tsx b/client/src/app/pages/dashboard/users/games/_game/_playtype/folders/FoldersMainPage.tsx index ec3d8dedd..e9f7318fb 100644 --- a/client/src/app/pages/dashboard/users/games/_game/_playtype/folders/FoldersMainPage.tsx +++ b/client/src/app/pages/dashboard/users/games/_game/_playtype/folders/FoldersMainPage.tsx @@ -3,20 +3,18 @@ import Divider from "components/util/Divider"; import Icon from "components/util/Icon"; import SelectLinkButton from "components/util/SelectLinkButton"; import useUGPTBase from "components/util/useUGPTBase"; -import { UserContext } from "context/UserContext"; import { AllLUGPTStatsContext } from "context/AllLUGPTStatsContext"; +import { UserContext } from "context/UserContext"; import React, { useContext } from "react"; import { Route, Switch } from "react-router-dom"; -import { FormatGame, GetGameConfig, UserDocument } from "tachi-common"; -import { GamePT } from "types/react"; +import { FormatGame, GetGameConfig } from "tachi-common"; +import { UGPT } from "types/react"; import FolderSelectPage from "./FolderSelectPage"; import FolderTablePage from "./FolderTablePage"; import RecentFoldersPage from "./RecentFoldersPage"; import SpecificFolderPage from "./SpecificFolderPage"; -type Props = { reqUser: UserDocument } & GamePT; - -export default function FoldersMainPage({ reqUser, game, playtype }: Props) { +export default function FoldersMainPage({ reqUser, game, playtype }: UGPT) { const gameConfig = GetGameConfig(game); const { user } = useContext(UserContext); diff --git a/client/src/app/pages/dashboard/users/games/_game/_playtype/folders/RecentFoldersPage.tsx b/client/src/app/pages/dashboard/users/games/_game/_playtype/folders/RecentFoldersPage.tsx index 113a95ae8..7d8e9d5f9 100644 --- a/client/src/app/pages/dashboard/users/games/_game/_playtype/folders/RecentFoldersPage.tsx +++ b/client/src/app/pages/dashboard/users/games/_game/_playtype/folders/RecentFoldersPage.tsx @@ -5,16 +5,12 @@ import { UserContext } from "context/UserContext"; import React, { useContext } from "react"; import { Row } from "react-bootstrap"; import { Link } from "react-router-dom"; -import { FolderDocument, UserDocument, RecentlyViewedFolderDocument } from "tachi-common"; +import { FolderDocument, RecentlyViewedFolderDocument } from "tachi-common"; import { FolderStatsInfo } from "types/api-returns"; -import { GamePT } from "types/react"; +import { UGPT } from "types/react"; import { FolderInfoComponent } from "./FolderSelectPage"; -export default function RecentFoldersPage({ - reqUser, - game, - playtype, -}: { reqUser: UserDocument } & GamePT) { +export default function RecentFoldersPage({ reqUser, game, playtype }: UGPT) { const { user } = useContext(UserContext); if (!user) { diff --git a/client/src/app/pages/dashboard/users/games/_game/_playtype/rivals/RivalsActivityPage.tsx b/client/src/app/pages/dashboard/users/games/_game/_playtype/rivals/RivalsActivityPage.tsx new file mode 100644 index 000000000..5dc4403a6 --- /dev/null +++ b/client/src/app/pages/dashboard/users/games/_game/_playtype/rivals/RivalsActivityPage.tsx @@ -0,0 +1,6 @@ +import React from "react"; +import { UGPT } from "types/react"; + +export default function RivalsActivityPage({ reqUser, game, playtype }: UGPT) { + return
RivalsActivityPage
; +} diff --git a/client/src/app/pages/dashboard/users/games/_game/_playtype/rivals/RivalsMainPage.tsx b/client/src/app/pages/dashboard/users/games/_game/_playtype/rivals/RivalsMainPage.tsx index 35eea1a6e..a09328a1d 100644 --- a/client/src/app/pages/dashboard/users/games/_game/_playtype/rivals/RivalsMainPage.tsx +++ b/client/src/app/pages/dashboard/users/games/_game/_playtype/rivals/RivalsMainPage.tsx @@ -9,6 +9,7 @@ import React from "react"; import { Col, Row } from "react-bootstrap"; import { Redirect, Route, Switch } from "react-router-dom"; import { FormatGame, Game, GetGameConfig, Playtype, UserDocument } from "tachi-common"; +import RivalsActivityPage from "./RivalsActivityPage"; import RivalsManagePage from "./RivalsManagePage"; export default function RivalsMainPage({ @@ -63,7 +64,7 @@ export default function RivalsMainPage({ {settings?.rivals.length === 0 && } - NOT WRITTEN YET + `/dashboard/users/${reqUser.username}/games/${game}/${playtype}`, [reqUser, game, playtype] diff --git a/client/src/types/react.ts b/client/src/types/react.ts index 0b8cb330d..4196cc979 100644 --- a/client/src/types/react.ts +++ b/client/src/types/react.ts @@ -9,7 +9,7 @@ import { FormikTouched, } from "formik"; import React, { Dispatch, SetStateAction } from "react"; -import { Game, Playtypes } from "tachi-common"; +import { Game, Playtype, UserDocument } from "tachi-common"; export interface JustChildren { children: React.ReactNode; @@ -87,5 +87,11 @@ export type UseFormik = { export interface GamePT { game: Game; - playtype: Playtypes[Game]; + playtype: Playtype; +} + +export interface UGPT { + reqUser: UserDocument; + game: Game; + playtype: Playtype; }