diff --git a/client/src/ui/components/trading/MarketOrderPanel.tsx b/client/src/ui/components/trading/MarketOrderPanel.tsx index 031e46a29..749af7cc3 100644 --- a/client/src/ui/components/trading/MarketOrderPanel.tsx +++ b/client/src/ui/components/trading/MarketOrderPanel.tsx @@ -451,7 +451,7 @@ const OrderRow = memo( donkeyBalance || donkeyBalance === 0} + disabled={!isBuy && donkeysNeeded > donkeyBalance} onCancel={() => { setConfirmOrderModal(false); }} @@ -600,7 +600,7 @@ const OrderCreation = memo( const enoughDonkeys = useMemo(() => { if (resourceId === ResourcesIds.Donkey) return true; - return donkeyBalance > donkeysNeeded; + return donkeyBalance >= donkeysNeeded; }, [donkeyBalance, donkeysNeeded, resourceId]); return ( diff --git a/client/src/ui/components/trading/SelectResources.tsx b/client/src/ui/components/trading/SelectResources.tsx index f5abae5e9..cdfdf1c16 100644 --- a/client/src/ui/components/trading/SelectResources.tsx +++ b/client/src/ui/components/trading/SelectResources.tsx @@ -5,7 +5,7 @@ import ListSelect from "@/ui/elements/ListSelect"; import { NumberInput } from "@/ui/elements/NumberInput"; import { ResourceCost } from "@/ui/elements/ResourceCost"; import { divideByPrecision } from "@/ui/utils/utils"; -import { ID, resources } from "@bibliothecadao/eternum"; +import { ID, RESOURCE_TIERS, ResourcesIds, resources } from "@bibliothecadao/eternum"; import { useMemo } from "react"; export const SelectResources = ({ @@ -24,8 +24,18 @@ export const SelectResources = ({ const { getBalance } = useResourceBalance(); const { playResourceSound } = usePlayResourceSound(); + const orderedResources = useMemo(() => { + return Object.values(RESOURCE_TIERS) + .flat() + .filter((resourceId) => resourceId !== ResourcesIds.Lords) + .map((resourceId) => ({ + id: resourceId, + trait: ResourcesIds[resourceId], + })); + }, []); + const unselectedResources = useMemo( - () => resources.filter((res) => !selectedResourceIds.includes(res.id)), + () => orderedResources.filter((res) => !selectedResourceIds.includes(res.id)), [selectedResourceIds], ); @@ -39,10 +49,11 @@ export const SelectResources = ({ }; return ( -
+
{selectedResourceIds.map((id: any, index: any) => { const resource = getBalance(entity_id, id); - const options = [resources.find((res) => res.id === id), ...unselectedResources].map((res: any) => ({ + + const options = [orderedResources.find((res) => res.id === id), ...unselectedResources].map((res: any) => ({ id: res.id, label: ( @@ -65,7 +76,10 @@ export const SelectResources = ({ )} ({ + ...option, + searchText: resources.find((res) => res.id === option.id)?.trait, + }))} value={selectedResourceIds[index]} onChange={(value) => { const updatedResourceIds = [...selectedResourceIds]; @@ -77,6 +91,7 @@ export const SelectResources = ({ }); playResourceSound(value); }} + enableFilter={true} /> { + const normalizedSearchTerm = normalizeDiacriticalMarks(searchTerm.toLowerCase()); return entities.filter( (entity) => entity.entity_id === selectedEntityId || - entity.name.toLowerCase().includes(searchTerm.toLowerCase()) || - (entity.accountName && entity.accountName.toLowerCase().includes(searchTerm.toLowerCase())), + normalizeDiacriticalMarks(entity.name.toLowerCase()).includes(normalizedSearchTerm) || + (entity.accountName && + normalizeDiacriticalMarks(entity.accountName.toLowerCase()).includes(normalizedSearchTerm)), ); }; @@ -319,9 +321,17 @@ export const TransferBetweenEntities = ({
-
+
+