diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 026138097..a3ed43cc7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,7 +10,7 @@ ## Opening a Pull Request 🌟 -If you have a fix for a bug or a feature request, follow the flow below to purpose your change +If you have a fix for a bug or a feature request, follow the flow below to propose your change > If you are new to creating pull requests from a repository fork, check out this [guide](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) diff --git a/src/pages/ammo/index.js b/src/pages/ammo/index.js index 30960f59e..1e4cf8462 100644 --- a/src/pages/ammo/index.js +++ b/src/pages/ammo/index.js @@ -21,6 +21,8 @@ import { formatCaliber } from '../../modules/format-ammo.mjs'; import symbols from '../../symbols.json'; import './index.css'; +import { useSelector } from 'react-redux'; +import { selectAllTraders } from '../../features/settings/settingsSlice.js'; const MAX_DAMAGE = 170; const MAX_PENETRATION = 70; @@ -34,6 +36,7 @@ const skipTypes = [ ]; function Ammo() { + const allTraders = useSelector(selectAllTraders); const { currentAmmo } = useParams(); let currentAmmoList = useMemo(() => [], []); let redirect = false; @@ -54,7 +57,8 @@ function Ammo() { navigate(`/ammo/${currentAmmoList.join(',')}`); } }, [redirect, currentAmmoList, navigate]); - + + const [showOnlyTraderAmmo, setShowOnlyTraderAmmo] = useState(false); const [selectedLegendName, setSelectedLegendName] = useState(currentAmmoList); const [showAllTraderPrices, setShowAllTraderPrices] = useState(false); const [useAllProjectileDamage, setUseAllProjectileDamage] = useState(false); @@ -158,6 +162,16 @@ function Ammo() { !selectedLegendName || selectedLegendName.length === 0 || selectedLegendName.includes(ammo.type), + ).filter(ammo => { + if (showOnlyTraderAmmo) { + if (!ammo.buyFor.some(buyForEntry => + buyForEntry.vendor.normalizedName !== 'flea-market' && + buyForEntry.vendor.minTraderLevel <= allTraders[buyForEntry.vendor.normalizedName]) + ) + return false; + } + return true; + } ).filter(ammo => { if (minPen === 0 && maxPen === 60) { return true; @@ -194,9 +208,8 @@ function Ammo() { chartName: `${ammo.chartName} (${ammo.fragmentationChance})`, }; }); - return returnData; - }, [selectedLegendName, shiftPress, ammoData, minPen, maxPen]); + }, [selectedLegendName, shiftPress, ammoData, minPen, maxPen, showOnlyTraderAmmo, allTraders]); const handleLegendClick = useCallback( (event, { datum: { name } }) => { @@ -269,6 +282,18 @@ function Ammo() { } /> + + setShowOnlyTraderAmmo(!showOnlyTraderAmmo) + } + tooltipContent={ + <> + {t('Only show ammo available from traders on your settings')} + + } + />