From bc2b83373ff323f41165d55e32a3638ffc9fc1fb Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sat, 10 Sep 2022 21:16:29 +0300 Subject: [PATCH] Handle changing weapon in analyzer --- app/modules/analyzer/useAnalyzeBuild.ts | 4 ++-- app/routes/analyzer.tsx | 14 ++++++++++++-- public/locales/en/analyzer.json | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/modules/analyzer/useAnalyzeBuild.ts b/app/modules/analyzer/useAnalyzeBuild.ts index 6f9109d49..df829a29d 100644 --- a/app/modules/analyzer/useAnalyzeBuild.ts +++ b/app/modules/analyzer/useAnalyzeBuild.ts @@ -14,8 +14,8 @@ export function useAnalyzeBuild() { const [weaponId, setWeaponId] = React.useState(0); const analyzed = React.useMemo( - () => buildStats({ build, weaponSplId: 0 }), - [build] + () => buildStats({ build, weaponSplId: weaponId }), + [build, weaponId] ); return { diff --git a/app/routes/analyzer.tsx b/app/routes/analyzer.tsx index b5ba3ba14..b420d8447 100644 --- a/app/routes/analyzer.tsx +++ b/app/routes/analyzer.tsx @@ -6,6 +6,7 @@ import { WeaponCombobox } from "~/components/Combobox"; import { Main } from "~/components/Main"; import type { Stat } from "~/modules/analyzer"; import { useAnalyzeBuild } from "~/modules/analyzer"; +import type { MainWeaponId } from "~/modules/in-game-lists"; import styles from "~/styles/analyzer.css"; export const links: LinksFunction = () => { @@ -18,7 +19,8 @@ export const handle = { export default function BuildAnalyzerPage() { const { t } = useTranslation("analyzer"); - const { build, setBuild, weaponId, analyzed } = useAnalyzeBuild(); + const { build, setBuild, weaponId, setWeaponId, analyzed } = + useAnalyzeBuild(); if (process.env.NODE_ENV === "production") return
Coming soon :)
; @@ -26,7 +28,15 @@ export default function BuildAnalyzerPage() {
- +
+ + opt && setWeaponId(Number(opt.value) as MainWeaponId) + } + /> +
diff --git a/public/locales/en/analyzer.json b/public/locales/en/analyzer.json index 356268b8e..5e7f0d31a 100644 --- a/public/locales/en/analyzer.json +++ b/public/locales/en/analyzer.json @@ -1,3 +1,3 @@ { - "stat.specialPoints": "Special points" + "stat.specialPoints": "Points to special" }