From de1520e4979e394213e126da20a51c06ca1c09e7 Mon Sep 17 00:00:00 2001 From: EmmaRamirez Date: Sat, 4 Mar 2023 22:34:11 -0600 Subject: [PATCH] chore: add no-redeclare lint flag --- src/actions/index.ts | 1 + src/actions/updateExcludedAreas.ts | 13 +++++++++++++ .../PokemonEditor/PokemonLocationChecklist.tsx | 17 ++++++++++------- src/reducers/excludedAreas.ts | 15 +++++++++++++++ src/reducers/index.ts | 2 ++ src/state/index.ts | 1 + 6 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 src/actions/updateExcludedAreas.ts create mode 100644 src/reducers/excludedAreas.ts diff --git a/src/actions/index.ts b/src/actions/index.ts index ec2377b63..33dd91aa2 100644 --- a/src/actions/index.ts +++ b/src/actions/index.ts @@ -34,3 +34,4 @@ export * from './updateEditorHistory'; export * from './triggerDownload'; export * from './toggleDialog'; export * from './setEditorHistoryEnabled'; +export * from './updateExcludedAreas'; \ No newline at end of file diff --git a/src/actions/updateExcludedAreas.ts b/src/actions/updateExcludedAreas.ts new file mode 100644 index 000000000..ea8749e2e --- /dev/null +++ b/src/actions/updateExcludedAreas.ts @@ -0,0 +1,13 @@ +/* eslint-disable @typescript-eslint/no-redeclare */ +import { Action } from 'actions'; + +export type UPDATE_EXCLUDED_AREAS = 'UPDATE_EXCLUDED_AREAS'; +export const UPDATE_EXCLUDED_AREAS: UPDATE_EXCLUDED_AREAS = 'UPDATE_EXCLUDED_AREAS'; + +export type updateExcludedAreas = (excludedAreas: string[]) => Action; +export const updateExcludedAreas = (excludedAreas: string[]): Action => { + return { + type: UPDATE_EXCLUDED_AREAS, + excludedAreas, + }; +}; diff --git a/src/components/PokemonEditor/PokemonLocationChecklist.tsx b/src/components/PokemonEditor/PokemonLocationChecklist.tsx index e17b3dffc..a515ce007 100644 --- a/src/components/PokemonEditor/PokemonLocationChecklist.tsx +++ b/src/components/PokemonEditor/PokemonLocationChecklist.tsx @@ -5,6 +5,8 @@ import { State } from 'state'; import { PokemonIcon } from 'components/PokemonIcon'; import { Callout, Classes, Icon, Intent, TextArea, Tooltip } from '@blueprintjs/core'; import { cx } from 'emotion'; +import { useDispatch, useSelector } from 'react-redux'; +import { updateExcludedAreas } from 'actions'; const LocationIcon = ({ area, currentGame, excludeGifts, pokemon }) => { @@ -65,16 +67,17 @@ export const PokemonLocationChecklist = ({ const [excludeGifts, setExcludeGifts] = React.useState(false); const [currentGame, setCurrentGame] = React.useState('None'); - const [excludedAreas, setExcludedAreas] = React.useState([]); + const excludedAreas = useSelector(state => state.excludedAreas); + const dispatch = useDispatch(); const encounterMap = React.useMemo(() => getEncounterMap(game.name).filter(area => !excludedAreas.includes(area)), [game.name, excludedAreas]); const totals = React.useMemo(() => calcTotals(boxes, pokemon, encounterMap, currentGame), [boxes, JSON.stringify(pokemon), encounterMap, currentGame]); - const hideArea = (area: string) => () => setExcludedAreas(areas => [...areas, area]); + const hideArea = (area: string) => () => dispatch(updateExcludedAreas([...excludedAreas, area])); - const updateExcludedAreas = (event) => { + const updateExcludedAreasFromText = (event) => { const value = event.currentTarget.value; const areas = value.split('\n'); - setExcludedAreas(areas); + updateExcludedAreas(areas); }; const colors = ['#0e1d6b', '#468189', '#77ACA2', '#9DBEBB', '#F4E9CD', '#0DAB76', '#139A43', '#D4AFB9', '#9CADCE']; @@ -83,7 +86,7 @@ export const PokemonLocationChecklist = ({ return {percentages.map((percentage, idx) =>
-
+
{percentage.key}: {percentage.percentage}
)} @@ -153,8 +156,8 @@ export const PokemonLocationChecklist = ({