Skip to content

Commit

Permalink
Add loading state
Browse files Browse the repository at this point in the history
  • Loading branch information
bob0005 committed Dec 16, 2024
1 parent ab32bdd commit ea60d44
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions client/src/ui/components/resources/realm-transfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const RealmTransfer = memo(

const { playerStructures } = useEntities();

const [isLoading, setIsLoading] = useState(false);
const [calls, setCalls] = useState<transferCall[]>([]);

const [type, setType] = useState<"send" | "receive">("send");
Expand Down Expand Up @@ -64,7 +65,7 @@ export const RealmTransfer = memo(
}, [calls]);

const handleTransfer = useCallback(() => {
// setIsLoading(true);
setIsLoading(true);
const cleanedCalls = calls.map(({ sender_entity_id, recipient_entity_id, resources }) => ({
sender_entity_id,
recipient_entity_id,
Expand All @@ -76,7 +77,7 @@ export const RealmTransfer = memo(
calls: cleanedCalls,
}).finally(() => {
// playDonkeyScreaming();
// setIsLoading(false);
setIsLoading(false);
});
}, [calls]);

Expand Down Expand Up @@ -143,7 +144,7 @@ export const RealmTransfer = memo(
</div>

<div className="pt-2 border-t border-gold/20">
<Button variant="primary" size="md" onClick={handleTransfer}>
<Button isLoading={isLoading} variant="primary" size="md" onClick={handleTransfer}>
{type === "send" ? "Send All" : "Receive All"}
</Button>
</div>
Expand Down

0 comments on commit ea60d44

Please sign in to comment.