diff --git a/client/pnpm-lock.yaml b/client/pnpm-lock.yaml index f48c98745..9bb539ad1 100644 --- a/client/pnpm-lock.yaml +++ b/client/pnpm-lock.yaml @@ -143,7 +143,7 @@ dependencies: resolve: 1.12.0 resolve-url-loader: 3.1.0 socicon: 3.0.5 - tachi-common: github.com/zkldi/tachi-common/353c7dcee5ca01dc25324cbb0e8404e5bf80ce1d_typescript@4.3.5 + tachi-common: github.com/zkldi/tachi-common/3cf854daeeec2a40f96db1c31a27d5c03c658a55_typescript@4.3.5 devDependencies: '@types/humanize-duration': 3.25.1 @@ -215,14 +215,14 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@babel/code-frame': 7.14.5 - '@babel/generator': 7.14.8 + '@babel/generator': 7.14.9 '@babel/helper-compilation-targets': 7.14.5_@babel+core@7.14.8 '@babel/helper-module-transforms': 7.14.8 '@babel/helpers': 7.14.8 - '@babel/parser': 7.14.8 + '@babel/parser': 7.14.9 '@babel/template': 7.14.5 - '@babel/traverse': 7.14.8 - '@babel/types': 7.14.8 + '@babel/traverse': 7.14.9 + '@babel/types': 7.14.9 convert-source-map: 1.8.0 debug: 4.3.2 gensync: 1.0.0-beta.2 @@ -297,6 +297,15 @@ packages: source-map: 0.5.7 dev: false + /@babel/generator/7.14.9: + resolution: {integrity: sha512-4yoHbhDYzFa0GLfCzLp5GxH7vPPMAHdZjyE7M/OajM9037zhx0rf+iNsJwp4PT0MSFpwjG7BsHEbPkBQpZ6cYA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.14.9 + jsesc: 2.5.2 + source-map: 0.5.7 + dev: false + /@babel/helper-annotate-as-pure/7.14.5: resolution: {integrity: sha512-EivH9EgBIb+G8ij1B2jAwSH36WnGvkQSEC6CkX/6v6ZFlw5fVOHvsgGF4uiEHO2GzMvunZb6tDLQEQSdrdocrA==} engines: {node: '>=6.9.0'} @@ -493,10 +502,10 @@ packages: '@babel/helper-replace-supers': 7.14.5 '@babel/helper-simple-access': 7.14.8 '@babel/helper-split-export-declaration': 7.14.5 - '@babel/helper-validator-identifier': 7.14.8 + '@babel/helper-validator-identifier': 7.14.9 '@babel/template': 7.14.5 - '@babel/traverse': 7.14.8 - '@babel/types': 7.14.8 + '@babel/traverse': 7.14.9 + '@babel/types': 7.14.9 transitivePeerDependencies: - supports-color dev: false @@ -547,7 +556,7 @@ packages: resolution: {integrity: sha512-TrFN4RHh9gnWEU+s7JloIho2T76GPwRHhdzOWLqTrMnlas8T9O7ec+oEDNsRXndOmru9ymH9DFrEOxpzPoSbdg==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.14.8 + '@babel/types': 7.14.9 dev: false /@babel/helper-skip-transparent-expression-wrappers/7.14.5: @@ -573,6 +582,11 @@ packages: resolution: {integrity: sha512-ZGy6/XQjllhYQrNw/3zfWRwZCTVSiBLZ9DHVZxn9n2gip/7ab8mv2TWlKPIBk26RwedCBoWdjLmn+t9na2Gcow==} engines: {node: '>=6.9.0'} + /@babel/helper-validator-identifier/7.14.9: + resolution: {integrity: sha512-pQYxPY0UP6IHISRitNe8bsijHex4TWZXi2HwKVsjPiltzlhse2znVcm9Ace510VT1kxIHjGJCZZQBX2gJDbo0g==} + engines: {node: '>=6.9.0'} + dev: false + /@babel/helper-validator-option/7.14.5: resolution: {integrity: sha512-OX8D5eeX4XwcroVW45NMvoYaIuFI+GQpA2a8Gi+X/U/cDUIRsV37qQfF905F0htTRCREQIB4KqPeaveRJUl3Ow==} engines: {node: '>=6.9.0'} @@ -606,8 +620,8 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@babel/template': 7.14.5 - '@babel/traverse': 7.14.8 - '@babel/types': 7.14.8 + '@babel/traverse': 7.14.9 + '@babel/types': 7.14.9 transitivePeerDependencies: - supports-color dev: false @@ -632,6 +646,12 @@ packages: hasBin: true dev: false + /@babel/parser/7.14.9: + resolution: {integrity: sha512-RdUTOseXJ8POjjOeEBEvNMIZU/nm4yu2rufRkcibzkkg7DmQvXU8v3M4Xk9G7uuI86CDGkKcuDWgioqZm+mScQ==} + engines: {node: '>=6.0.0'} + hasBin: true + dev: false + /@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/7.14.5_@babel+core@7.6.0: resolution: {integrity: sha512-ZoJS2XCKPBfTmL122iP6NM9dOg+d4lc9fFk3zxc8iDjvt8Pk4+TlsHSKhIPf6X+L5ORCdBzqMZDjL/WHj7WknQ==} engines: {node: '>=6.9.0'} @@ -1879,20 +1899,6 @@ packages: '@babel/helper-plugin-utils': 7.14.5 dev: false - /@babel/plugin-transform-react-jsx/7.14.5_@babel+core@7.14.8: - resolution: {integrity: sha512-7RylxNeDnxc1OleDm0F5Q/BSL+whYRbOAR+bwgCxIr0L32v7UFh/pz1DLMZideAUxKT6eMoS2zQH6fyODLEi8Q==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0-0 - dependencies: - '@babel/core': 7.14.8 - '@babel/helper-annotate-as-pure': 7.14.5 - '@babel/helper-module-imports': 7.14.5 - '@babel/helper-plugin-utils': 7.14.5 - '@babel/plugin-syntax-jsx': 7.14.5_@babel+core@7.14.8 - '@babel/types': 7.14.8 - dev: false - /@babel/plugin-transform-react-jsx/7.14.5_@babel+core@7.6.0: resolution: {integrity: sha512-7RylxNeDnxc1OleDm0F5Q/BSL+whYRbOAR+bwgCxIr0L32v7UFh/pz1DLMZideAUxKT6eMoS2zQH6fyODLEi8Q==} engines: {node: '>=6.9.0'} @@ -1921,6 +1927,20 @@ packages: '@babel/types': 7.14.8 dev: false + /@babel/plugin-transform-react-jsx/7.14.9_@babel+core@7.14.8: + resolution: {integrity: sha512-30PeETvS+AeD1f58i1OVyoDlVYQhap/K20ZrMjLmmzmC2AYR/G43D4sdJAaDAqCD3MYpSWbmrz3kES158QSLjw==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + dependencies: + '@babel/core': 7.14.8 + '@babel/helper-annotate-as-pure': 7.14.5 + '@babel/helper-module-imports': 7.14.5 + '@babel/helper-plugin-utils': 7.14.5 + '@babel/plugin-syntax-jsx': 7.14.5_@babel+core@7.14.8 + '@babel/types': 7.14.9 + dev: false + /@babel/plugin-transform-react-pure-annotations/7.14.5_@babel+core@7.6.0: resolution: {integrity: sha512-3X4HpBJimNxW4rhUy/SONPyNQHp5YRr0HhJdT2OH1BRp0of7u3Dkirc7x9FRJMKMqTBI079VZ1hzv7Ouuz///g==} engines: {node: '>=6.9.0'} @@ -2408,6 +2428,23 @@ packages: - supports-color dev: false + /@babel/traverse/7.14.9: + resolution: {integrity: sha512-bldh6dtB49L8q9bUyB7bC20UKgU+EFDwKJylwl234Kv+ySZeMD31Xeht6URyueQ6LrRRpF2tmkfcZooZR9/e8g==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/code-frame': 7.14.5 + '@babel/generator': 7.14.9 + '@babel/helper-function-name': 7.14.5 + '@babel/helper-hoist-variables': 7.14.5 + '@babel/helper-split-export-declaration': 7.14.5 + '@babel/parser': 7.14.9 + '@babel/types': 7.14.9 + debug: 4.3.2 + globals: 11.12.0 + transitivePeerDependencies: + - supports-color + dev: false + /@babel/types/7.14.5: resolution: {integrity: sha512-M/NzBpEL95I5Hh4dwhin5JlE7EzO5PHMAuzjxss3tiOBD46KfQvVedN/3jEPZvdRvtsK2222XfdHogNIttFgcg==} engines: {node: '>=6.9.0'} @@ -2424,6 +2461,14 @@ packages: to-fast-properties: 2.0.0 dev: false + /@babel/types/7.14.9: + resolution: {integrity: sha512-u0bLTnv3DFHeaQLYzb7oRJ1JHr1sv/SYDM7JSqHFFLwXG1wTZRughxFI5NCP8qBEo1rVVsn7Yg2Lvw49nne/Ow==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-validator-identifier': 7.14.9 + to-fast-properties: 2.0.0 + dev: false + /@csstools/convert-colors/1.4.0: resolution: {integrity: sha512-5a6wqoJV/xEdbRNKVo6I4hO3VjyDq//8q2f9I6PBAvMesJHFauXDorcNCsr9RzvsZnaWi5NYCcfyqP1QeFHFbw==} engines: {node: '>=4.0.0'} @@ -7162,7 +7207,7 @@ packages: '@babel/core': 7.14.8 '@babel/plugin-proposal-object-rest-spread': 7.14.7_@babel+core@7.14.8 '@babel/plugin-transform-destructuring': 7.14.7_@babel+core@7.14.8 - '@babel/plugin-transform-react-jsx': 7.14.5_@babel+core@7.14.8 + '@babel/plugin-transform-react-jsx': 7.14.9_@babel+core@7.14.8 caller-path: 2.0.0 find-cache-dir: 3.3.1 make-dir: 3.1.0 @@ -12799,9 +12844,9 @@ packages: yargs-parser: 18.1.3 dev: false - github.com/zkldi/tachi-common/353c7dcee5ca01dc25324cbb0e8404e5bf80ce1d_typescript@4.3.5: - resolution: {tarball: https://codeload.github.com/zkldi/tachi-common/tar.gz/353c7dcee5ca01dc25324cbb0e8404e5bf80ce1d} - id: github.com/zkldi/tachi-common/353c7dcee5ca01dc25324cbb0e8404e5bf80ce1d + github.com/zkldi/tachi-common/3cf854daeeec2a40f96db1c31a27d5c03c658a55_typescript@4.3.5: + resolution: {tarball: https://codeload.github.com/zkldi/tachi-common/tar.gz/3cf854daeeec2a40f96db1c31a27d5c03c658a55} + id: github.com/zkldi/tachi-common/3cf854daeeec2a40f96db1c31a27d5c03c658a55 name: tachi-common version: 0.1.0 dependencies: diff --git a/client/src/app/pages/LoginPage.tsx b/client/src/app/pages/LoginPage.tsx index 712da96fb..4c0168508 100644 --- a/client/src/app/pages/LoginPage.tsx +++ b/client/src/app/pages/LoginPage.tsx @@ -57,6 +57,7 @@ export default function LoginPage() { setTimeout(() => { setUser(userRJ.body); + localStorage.setItem("isLoggedIn", "true"); history.goBack(); }, 500); diff --git a/client/src/app/pages/RegisterPage.tsx b/client/src/app/pages/RegisterPage.tsx index 71302441b..0e3a231d3 100644 --- a/client/src/app/pages/RegisterPage.tsx +++ b/client/src/app/pages/RegisterPage.tsx @@ -77,6 +77,7 @@ export default function RegisterPage() { setTimeout(() => { setUser(rj.body); + localStorage.setItem("isLoggedIn", "true"); history.goBack(); }, 500); diff --git a/client/src/components/charts/IIDXLampChart.tsx b/client/src/components/charts/IIDXLampChart.tsx new file mode 100644 index 000000000..613443a26 --- /dev/null +++ b/client/src/components/charts/IIDXLampChart.tsx @@ -0,0 +1,63 @@ +import React from "react"; +import { ResponsiveLine, Serie } from "@nivo/line"; +import { TACHI_CHART_THEME } from "util/constants/chart-theme"; +import { ColourConfig } from "lib/config"; + +export default function IIDXLampChart({ + width = "100%", + height = "100%", + mobileHeight = "100%", + mobileWidth = width, + data, + axisBottom, + axisLeft, + curve, + ...props +}: { + mobileHeight?: number | string; + mobileWidth?: number | string; + width?: number | string; + height?: number | string; + data: Serie[]; +} & ResponsiveLine["props"]) { + return ( + <> +
+ +
+
+ +
+ + ); +} diff --git a/client/src/components/layout/header/UserProfileDropdown.tsx b/client/src/components/layout/header/UserProfileDropdown.tsx index eeefedd62..5511b30e3 100644 --- a/client/src/components/layout/header/UserProfileDropdown.tsx +++ b/client/src/components/layout/header/UserProfileDropdown.tsx @@ -89,6 +89,7 @@ export function UserProfileDropdown({ user }: { user: PublicUserDocument }) { toast.success("Logged out."); setTimeout(() => { setUser(null); + localStorage.removeItem("isLoggedIn"); }, 500); } }} diff --git a/client/src/components/layout/screens/LoadingScreen.tsx b/client/src/components/layout/screens/LoadingScreen.tsx index 468adbb22..459d169c4 100644 --- a/client/src/components/layout/screens/LoadingScreen.tsx +++ b/client/src/components/layout/screens/LoadingScreen.tsx @@ -14,6 +14,11 @@ export function LoadingScreen({ children }: JustChildren) { const { setUser } = useContext(UserContext); useEffect(() => { + if (!localStorage.getItem("isLoggedIn")) { + setLoading(false); + return; + } + const timeout = setTimeout( () => setBroke( diff --git a/client/src/components/tables/components/DropdownRow.tsx b/client/src/components/tables/components/DropdownRow.tsx index 722da5884..ab9bf73a0 100644 --- a/client/src/components/tables/components/DropdownRow.tsx +++ b/client/src/components/tables/components/DropdownRow.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useEffect, useMemo, useState } from "react"; import { Collapse } from "react-bootstrap"; import { JustChildren } from "types/react"; @@ -7,13 +7,32 @@ export default function DropdownRow({ dropdown, }: { dropdown: React.ReactNode } & JustChildren) { const [showDropdown, setShowDropdown] = useState(false); + + const [renderDropdown, setRenderDropdown] = useState(false); + + useEffect(() => { + if (!renderDropdown && showDropdown) { + setRenderDropdown(true); + } else if (renderDropdown && !showDropdown) { + setTimeout(() => { + if (renderDropdown && !showDropdown) { + setRenderDropdown(false); + } + }, 300); + } + }, [showDropdown]); + return ( <> setShowDropdown(!showDropdown)}>{children} -
{dropdown}
+ {renderDropdown ? ( +
{dropdown}
+ ) : ( +
+ )}
diff --git a/client/src/components/tables/pbs/IIDXPBTable.tsx b/client/src/components/tables/pbs/IIDXPBTable.tsx index 2cfa4c477..52f99d650 100644 --- a/client/src/components/tables/pbs/IIDXPBTable.tsx +++ b/client/src/components/tables/pbs/IIDXPBTable.tsx @@ -16,6 +16,7 @@ import DeltaCell from "../cells/DeltaCell"; import { HumanFriendlyStrToGradeIndex, HumanFriendlyStrToLampIndex } from "util/str-to-num"; import { nanoid } from "nanoid"; import DropdownRow from "../components/DropdownRow"; +import IIDXPBDropdown from "./dropdowns/IIDXPBDropdown"; export default function IIDXPBTable({ dataset, @@ -83,7 +84,7 @@ export default function IIDXPBTable({ defaultSortMode={indexCol ? "#" : undefined} rowFunction={pb => ( {pb.chartID}} + dropdown={} key={pb.chartID} > {indexCol && } diff --git a/client/src/components/tables/pbs/dropdowns/IIDXPBDropdown.tsx b/client/src/components/tables/pbs/dropdowns/IIDXPBDropdown.tsx new file mode 100644 index 000000000..c35b1f9b5 --- /dev/null +++ b/client/src/components/tables/pbs/dropdowns/IIDXPBDropdown.tsx @@ -0,0 +1,174 @@ +import IIDXLampChart from "components/charts/IIDXLampChart"; +import MiniTable from "components/tables/components/MiniTable"; +import Icon from "components/util/Icon"; +import SelectButton from "components/util/SelectButton"; +import { nanoid } from "nanoid"; +import React, { useMemo, useState } from "react"; +import { Nav, Tab, Tabs } from "react-bootstrap"; +import { GetGamePTConfig, Lamps, PBScoreDocument } from "tachi-common"; +import { GamePT } from "types/react"; +import JudgementTable from "./components/JudgementTable"; + +export default function IIDXPBDropdown({ + pb, + game, + playtype, +}: { pb: PBScoreDocument<"iidx:SP" | "iidx:DP"> } & GamePT) { + const [view, setView] = useState<"pb" | "scorePB" | "lampPB" | "bpPB" | "history">("pb"); + + const currentDoc = useMemo(() => { + if (view === "pb") { + return pb; + } + + return pb; + }, [view]); + + let gaugeStatus: "none" | "single" | "gsm" = "none"; + + if (currentDoc.scoreData.hitMeta.gsm) { + gaugeStatus = "gsm"; + } else if (currentDoc.scoreData.hitMeta.gaugeHistory) { + gaugeStatus = "single"; + } + + return ( +
+
+
+
+ + + PB Info + + + + Best Score + + + + Best Lamp + + + + Play History + +
+
+ +
+
+
+ {gaugeStatus === "none" ? ( +
+ No gauge data :( +
+ ) : ( +
+ +
+ + +
+
+
+ )} +
+
+ +
+
+
+
+
+ ); +} + +function GraphComponent({ type, values }: { type: LampTypes; values: (number | null)[] }) { + console.log(values); + + return ( + ({ x: i, y: e ?? 0 })), + }, + ]} + /> + ); +} + +type LampTypes = "normal" | "easy" | "hard" | "exhard"; + +function LampToKey(lamp: Lamps["iidx:SP"]): LampTypes { + if (lamp === "CLEAR") { + return "normal"; + } else if (lamp === "EASY CLEAR") { + return "easy"; + } else if (lamp === "HARD CLEAR") { + return "hard"; + } else if (lamp === "EX HARD CLEAR") { + return "exhard"; + } + + return "normal"; +} + +function LampToName(lamp: Lamps["iidx:SP"]) { + if (lamp === "CLEAR") { + return "Normal"; + } else if (lamp === "EASY CLEAR") { + return "Easy"; + } else if (lamp === "HARD CLEAR") { + return "Hard"; + } else if (lamp === "EX HARD CLEAR") { + return "Ex Hard"; + } + + return "Normal"; +} diff --git a/client/src/components/tables/pbs/dropdowns/components/JudgementTable.tsx b/client/src/components/tables/pbs/dropdowns/components/JudgementTable.tsx new file mode 100644 index 000000000..ea36f5e2a --- /dev/null +++ b/client/src/components/tables/pbs/dropdowns/components/JudgementTable.tsx @@ -0,0 +1,23 @@ +import MiniTable from "components/tables/components/MiniTable"; +import React from "react"; +import { GetGamePTConfig, ScoreDocument } from "tachi-common"; +import { GamePT } from "types/react"; + +export default function JudgementTable({ + game, + playtype, + judgements, +}: { judgements: ScoreDocument["scoreData"]["judgements"] } & GamePT) { + const gptConfig = GetGamePTConfig(game, playtype); + + return ( + + {gptConfig.judgements.map(j => ( + + {j.toUpperCase()} + {judgements[j] ?? "No Data."} + + ))} + + ); +}