From 7a123b68db5051c4f956eacb42f4d5a2aa067750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sun, 18 Feb 2024 16:26:26 -0600 Subject: [PATCH] fix: disable crew on non-tech trees --- .../components/Miscellaneous.tsx | 86 ++++++++++--------- .../[id]/components/Characteristics/index.tsx | 2 +- 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/src/app/tools/tankopedia/[id]/components/Characteristics/components/Miscellaneous.tsx b/src/app/tools/tankopedia/[id]/components/Characteristics/components/Miscellaneous.tsx index b2d107132..68b10978a 100644 --- a/src/app/tools/tankopedia/[id]/components/Characteristics/components/Miscellaneous.tsx +++ b/src/app/tools/tankopedia/[id]/components/Characteristics/components/Miscellaneous.tsx @@ -3,6 +3,7 @@ import { clamp, debounce } from 'lodash'; import { useEffect, useMemo, useRef, useState } from 'react'; import { GenericTankComponentButton } from '../../../../../../../components/ModuleButtons/GenericTankComponentButton'; import { asset } from '../../../../../../../core/blitzkrieg/asset'; +import { useDuel } from '../../../../../../../stores/duel'; import { mutateTankopediaTemporary, useTankopediaTemporary, @@ -17,6 +18,7 @@ export function Miscellaneous() { const crewMastery = useTankopediaTemporary((state) => state.crewMastery); const crewInput = useRef(null); const [crewMasteryDraft, setCrewMasteryDraft] = useState(crewMastery); + const { tank } = useDuel((state) => state.protagonist!); const debouncedApplyDraft = useMemo( () => @@ -80,51 +82,53 @@ export function Miscellaneous() { }} /> - - - Crew - { - const newValue = Number(crewInput.current!.value) / 100; + {tank.treeType === 'researchable' && ( + + + Crew + { + const newValue = Number(crewInput.current!.value) / 100; - if (isNaN(newValue)) { - crewInput.current!.value = `${Math.round(crewMastery * 100)}`; - return; - } + if (isNaN(newValue)) { + crewInput.current!.value = `${Math.round(crewMastery * 100)}`; + return; + } - mutateTankopediaTemporary((draft) => { - draft.crewMastery = clamp(newValue / 100, 0.5, 1); - }); - }} - onKeyUp={(event) => { - if (event.key === 'Enter') { - crewInput.current?.blur(); - } + mutateTankopediaTemporary((draft) => { + draft.crewMastery = clamp(newValue / 100, 0.5, 1); + }); + }} + onKeyUp={(event) => { + if (event.key === 'Enter') { + crewInput.current?.blur(); + } + }} + /> + % + + + { + setCrewMasteryDraft(value / 100); + debouncedApplyDraft(value / 100); }} /> - % - - - { - setCrewMasteryDraft(value / 100); - debouncedApplyDraft(value / 100); - }} - /> - + + )} ); diff --git a/src/app/tools/tankopedia/[id]/components/Characteristics/index.tsx b/src/app/tools/tankopedia/[id]/components/Characteristics/index.tsx index 1437febfb..e975042f4 100644 --- a/src/app/tools/tankopedia/[id]/components/Characteristics/index.tsx +++ b/src/app/tools/tankopedia/[id]/components/Characteristics/index.tsx @@ -582,7 +582,7 @@ export function Characteristics() { - Crew + Crew training {tank.crew.map((member) => { const count = member.count ?? 1;