diff --git a/client/src/app/pages/dashboard/import/ImportPage.tsx b/client/src/app/pages/dashboard/import/ImportPage.tsx index c2b5c804f..52725a71f 100644 --- a/client/src/app/pages/dashboard/import/ImportPage.tsx +++ b/client/src/app/pages/dashboard/import/ImportPage.tsx @@ -1,12 +1,25 @@ import useSetSubheader from "components/layout/header/useSetSubheader"; import Card from "components/layout/page/Card"; +import ApiError from "components/util/ApiError"; import DiscordLink from "components/util/DiscordLink"; import Divider from "components/util/Divider"; import ExternalLink from "components/util/ExternalLink"; import LinkButton from "components/util/LinkButton"; +import Loading from "components/util/Loading"; +import Muted from "components/util/Muted"; +import useApiQuery from "components/util/query/useApiQuery"; +import { UserContext } from "context/UserContext"; import { TachiConfig } from "lib/config"; -import React, { useState } from "react"; -import { Game, GetGameConfig } from "tachi-common"; +import React, { useContext, useState } from "react"; +import { + APIImportTypes, + FileUploadImportTypes, + Game, + GetGameConfig, + ImportTypes, + integer, + PublicUserDocument, +} from "tachi-common"; export default function ImportPage() { useSetSubheader(["Import Scores"]); @@ -41,36 +54,56 @@ export default function ImportPage() { ))} - {game && ( - <> - - - - )} + + + {game ? : } ); } +function ShowRecentImports() { + const { user } = useContext(UserContext); + + if (!user) { + return <>You're not signed in.; + } + + return ; +} + +function InnerShowRecentImports({ user }: { user: PublicUserDocument }) { + const { data, error, isLoading } = useApiQuery<{ importType: ImportTypes; count: integer }[]>( + `/users/${user.id}/recent-imports` + ); + + if (error) { + return ; + } + + if (isLoading || !data) { + return ; + } + + return ( + <> +

Recently Used Import Methods

+ + {data + .filter(e => e.importType.startsWith("file/") || e.importType.startsWith("api/")) + .map(e => ( + + ))} + + ); +} + function ImportInfoDisplayer({ game }: { game: Game }) { const gameConfig = GetGameConfig(game); - const Content = [ - - Check{" "} - - the documentation - - . - - } - key="Batch Manual" - />, - ]; + const Content = []; if (game === "iidx") { Content.unshift( @@ -81,55 +114,16 @@ function ImportInfoDisplayer({ game }: { game: Game }) { moreInfo="This is the recommended way to import scores, as it provides quality data in real-time." key="Fervidex" />, - , - , - , - , - // , - , - + , + , + , + // , + , + ); } else if (game === "sdvx") { Content.unshift( @@ -147,41 +141,14 @@ function ImportInfoDisplayer({ game }: { game: Game }) { moreInfo="Yep, it's that simple." key="Konaste Hook" />, - , - , - , - , - + , + , + , + ); } else if (game === "chunithm") { Content.unshift( @@ -263,6 +230,153 @@ function ImportInfoDisplayer({ game }: { game: Game }) { ); } +function ImportTypeInfoCard({ + importType, +}: { + importType: FileUploadImportTypes | APIImportTypes; +}) { + switch (importType) { + case "api/arc-sdvx": + return ( + + ); + case "api/arc-iidx": + return ( + + ); + case "api/eag-iidx": + return ( + + ); + case "api/flo-iidx": + return ( + + ); + case "api/flo-sdvx": + return ( + + ); + case "api/eag-sdvx": + return ( + + ); + case "api/min-sdvx": + return ( + + ); + case "file/eamusement-iidx-csv": + return ( + + ); + case "file/solid-state-squad": + return ( + + ); + case "file/eamusement-sdvx-csv": + return ( + + ); + case "file/batch-manual": + return ( + + Check{" "} + + the documentation + + . + + } + key="Batch Manual" + /> + ); + case "file/mer-iidx": + return ( + + ); + case "file/pli-iidx-csv": + return ( + + ); + } +} + function ImportInfoCard({ name, href,