diff --git a/components/common/GearSelector.tsx b/components/common/GearSelector.tsx index 22bf0973f..d6b140566 100644 --- a/components/common/GearSelector.tsx +++ b/components/common/GearSelector.tsx @@ -19,7 +19,7 @@ const GearSelector: React.FC = ({ const { i18n } = useLingui(); const singleOption = (props: any) => ( - + diff --git a/components/common/UserAvatar.tsx b/components/common/UserAvatar.tsx index c282612af..217091eb3 100644 --- a/components/common/UserAvatar.tsx +++ b/components/common/UserAvatar.tsx @@ -11,18 +11,15 @@ const UserAvatar: React.FC = ({ user, isSmall, ...props -}) => { - console.log({ user }); - return ( - - ); -}; +}) => ( + +); export default UserAvatar; diff --git a/components/common/UserSelector.tsx b/components/common/UserSelector.tsx index acee13533..bed975fb6 100644 --- a/components/common/UserSelector.tsx +++ b/components/common/UserSelector.tsx @@ -75,7 +75,6 @@ const UserSelector: React.FC = ({ ); function getUsersArray() { - console.log({ value, maxMultiCount }); if (!data) return []; if (isTooManyItems()) { return []; diff --git a/components/common/WeaponSelector.tsx b/components/common/WeaponSelector.tsx index 54ef4d0f2..dd4bc16dc 100644 --- a/components/common/WeaponSelector.tsx +++ b/components/common/WeaponSelector.tsx @@ -20,8 +20,7 @@ interface SelectorProps { interface SingleSelectorProps extends SelectorProps { value?: string; setValue: (value: string) => void; - isMulti: false | undefined; - maxMultiCount: undefined; + isMulti: false; } interface MultiSelectorProps extends SelectorProps { @@ -31,17 +30,9 @@ interface MultiSelectorProps extends SelectorProps { maxMultiCount: number; } -const WeaponSelector: React.FC = ({ - value, - setValue, - isClearable = false, - autoFocus, - isMulti, - maxMultiCount, - menuIsOpen, - isDisabled, - pool, -}) => { +const WeaponSelector: React.FC = ( + props +) => { const { i18n } = useLingui(); const singleOption = (props: any) => ( @@ -54,6 +45,8 @@ const WeaponSelector: React.FC = ({ ); + const maxMultiCount = props.isMulti ? props.maxMultiCount : Infinity; + return ( ({ @@ -64,36 +57,36 @@ const WeaponSelector: React.FC = ({ })), }))} value={getValue()} - setValue={setValue} - isClearable={isClearable} + setValue={props.setValue} + isClearable={!!props.isClearable} isSearchable - isMulti={isMulti} - menuIsOpen={menuIsOpen} + isMulti={props.isMulti} + menuIsOpen={!!props.menuIsOpen} components={{ IndicatorSeparator: () => null, Option: singleOption, NoOptionsMessage: () => (
{isTooManyItems() ? ( - Only {maxMultiCount} weapons allowed + Only {props} weapons allowed ) : ( No results with this filter )}
), }} - autoFocus={autoFocus} - isDisabled={isDisabled} + autoFocus={!!props.autoFocus} + isDisabled={!!props.isDisabled} /> ); function getValue() { - if (typeof value === "string") { - return { value, label: i18n._(value) }; + if (typeof props.value === "string") { + return { value: props.value, label: i18n._(props.value) }; } - if (Array.isArray(value)) { - return value.map((singleValue) => ({ + if (Array.isArray(props.value)) { + return props.value.map((singleValue) => ({ value: singleValue, label: i18n._(singleValue), })); @@ -104,8 +97,8 @@ const WeaponSelector: React.FC = ({ function getWeaponArray() { if (isTooManyItems()) return []; - if (pool === "WITH_ALTS") return weaponsWithHeroCategorized; - if (pool === "SALMON_RUN") + if (props.pool === "WITH_ALTS") return weaponsWithHeroCategorized; + if (props.pool === "SALMON_RUN") return weaponsWithHeroCategorized.map((category) => ({ ...category, weapons: category.weapons.filter((wpn) => salmonRunWeapons.has(wpn)), @@ -120,7 +113,7 @@ const WeaponSelector: React.FC = ({ } function isTooManyItems() { - return maxMultiCount && maxMultiCount <= (value ?? []).length; + return maxMultiCount && maxMultiCount <= (props.value ?? []).length; } }; diff --git a/components/u/BuildModal.tsx b/components/u/BuildModal.tsx index 2b8f6b76f..addaf623c 100644 --- a/components/u/BuildModal.tsx +++ b/components/u/BuildModal.tsx @@ -178,6 +178,7 @@ const BuildModal: React.FC = ({ onClose, build }) => { value={value} setValue={onChange} pool="WITH_ALTS" + isMulti={false} /> )} /> diff --git a/pages/analyzer.tsx b/pages/analyzer.tsx index c41643342..d99231955 100644 --- a/pages/analyzer.tsx +++ b/pages/analyzer.tsx @@ -84,7 +84,7 @@ const BuildAnalyzerPage = () => {
- + diff --git a/pages/builds/[[...slug]].tsx b/pages/builds/[[...slug]].tsx index f1c84e89c..657a3decc 100644 --- a/pages/builds/[[...slug]].tsx +++ b/pages/builds/[[...slug]].tsx @@ -28,53 +28,52 @@ const BuildsPage = () => { setValue={(weapon) => dispatch({ type: "SET_WEAPON", weapon })} menuIsOpen={!state.weapon} autoFocus + isMulti={false} /> - <> - {state.weapon && ( - <> - - - + {state.weapon && ( + <> + + + + - - - {data.length} builds{" "} - {hiddenBuildCount > 0 && ( - <> - (+ {hiddenBuildCount} hidden) - - )} - - + {data.length} builds{" "} + {hiddenBuildCount > 0 && ( + <> + (+ {hiddenBuildCount} hidden) + + )} + - - )} - + + + )} {state.weapon && (