From c1479ca43ae14cdf68f12860afdcdb6a2a03f019 Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Sun, 24 Apr 2022 10:56:03 +0100 Subject: [PATCH] fix: update goals such that the app compiles again --- .../games/_game/_playtype/GPTMainPage.tsx | 10 ++++----- .../{UserGoalTable.tsx => GoalSubTable.tsx} | 21 ++++++++++++------- client/src/types/api-returns.ts | 6 +++--- 3 files changed, 21 insertions(+), 16 deletions(-) rename client/src/components/tables/goals/{UserGoalTable.tsx => GoalSubTable.tsx} (79%) diff --git a/client/src/app/pages/dashboard/games/_game/_playtype/GPTMainPage.tsx b/client/src/app/pages/dashboard/games/_game/_playtype/GPTMainPage.tsx index bf8cf5b94..974e4370c 100644 --- a/client/src/app/pages/dashboard/games/_game/_playtype/GPTMainPage.tsx +++ b/client/src/app/pages/dashboard/games/_game/_playtype/GPTMainPage.tsx @@ -8,7 +8,7 @@ import { BarChartTooltip } from "components/charts/ChartTooltip"; import ClassBadge from "components/game/ClassBadge"; import useSetSubheader from "components/layout/header/useSetSubheader"; import Card from "components/layout/page/Card"; -import UserGoalTable from "components/tables/goals/UserGoalTable"; +import GoalSubTable from "components/tables/goals/GoalSubTable"; import ScoreTable from "components/tables/scores/ScoreTable"; import ApiError from "components/util/ApiError"; import AsyncLoader from "components/util/AsyncLoader"; @@ -33,7 +33,7 @@ import { PublicUserDocument, ScoreDocument, SongDocument, - UserGoalDocument, + GoalSubscriptionDocument, } from "tachi-common"; import { RecentClassesReturn } from "types/api-returns"; import { GamePT } from "types/react"; @@ -77,7 +77,7 @@ function RecentAchievedGoalsComponent({ game, playtype }: GamePT) { const { data, isLoading, error } = useApiQuery<{ users: PublicUserDocument[]; goals: GoalDocument[]; - userGoals: UserGoalDocument[]; + goalSubs: GoalSubscriptionDocument[]; }>(`/games/${game}/${playtype}/goals/recently-achieved`); if (error) { @@ -93,7 +93,7 @@ function RecentAchievedGoalsComponent({ game, playtype }: GamePT) { const userMap = CreateUserMap(data.users); const goalMap = CreateGoalMap(data.goals); - for (const userGoal of data.userGoals) { + for (const userGoal of data.goalSubs) { const user = userMap.get(userGoal.userID); const goal = goalMap.get(userGoal.goalID); @@ -122,7 +122,7 @@ function RecentAchievedGoalsComponent({ game, playtype }: GamePT) { - + ); diff --git a/client/src/components/tables/goals/UserGoalTable.tsx b/client/src/components/tables/goals/GoalSubTable.tsx similarity index 79% rename from client/src/components/tables/goals/UserGoalTable.tsx rename to client/src/components/tables/goals/GoalSubTable.tsx index d4cc59d86..e0ce9d8aa 100644 --- a/client/src/components/tables/goals/UserGoalTable.tsx +++ b/client/src/components/tables/goals/GoalSubTable.tsx @@ -2,27 +2,32 @@ import { ChangeOpacity } from "util/color-opacity"; import { NumericSOV, StrSOV } from "util/sorts"; import GentleLink from "components/util/GentleLink"; import React from "react"; -import { COLOUR_SET, GoalDocument, PublicUserDocument, UserGoalDocument } from "tachi-common"; +import { + COLOUR_SET, + GoalDocument, + PublicUserDocument, + GoalSubscriptionDocument, +} from "tachi-common"; import { GamePT } from "types/react"; import TimestampCell from "../cells/TimestampCell"; import UserCell from "../cells/UserCell"; import TachiTable, { Header } from "../components/TachiTable"; -export type UserGoalDataset = (UserGoalDocument & { +export type GoalSubDataset = (GoalSubscriptionDocument & { __related: { user: PublicUserDocument; goal: GoalDocument; }; })[]; -export default function UserGoalTable({ +export default function GoalSubTable({ game, playtype, dataset, -}: GamePT & { dataset: UserGoalDataset }) { - const headers: Header[] = [ +}: GamePT & { dataset: GoalSubDataset }) { + const headers: Header[] = [ ["User", "User", StrSOV(x => x.__related.user.username)], - ["Goal", "Goal", StrSOV(x => x.__related.goal.title)], + ["Goal", "Goal", StrSOV(x => x.__related.goal.name)], [ "Progress", "Progress", @@ -38,7 +43,7 @@ export default function UserGoalTable({ entryName="Goals" searchFunctions={{ user: k => k.__related.user.username, - goal: k => k.__related.goal.title, + goal: k => k.__related.goal.name, timestamp: k => k.timeAchieved, }} rowFunction={d => ( @@ -48,7 +53,7 @@ export default function UserGoalTable({ - {d.__related.goal.title} + {d.__related.goal.name} { @@ -166,8 +166,8 @@ export interface UserRecentSummary { recentFolders: FolderDocument[]; recentFolderStats: FolderStatsInfo[]; recentGoals: GoalDocument[]; - recentImprovedGoals: UserGoalDocument[]; - recentAchievedGoals: UserGoalDocument[]; + recentImprovedGoals: GoalSubscriptionDocument[]; + recentAchievedGoals: GoalSubscriptionDocument[]; } export interface ServerStatus {