Skip to content

Commit

Permalink
Fix title in claim modal (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
gpxl-dev authored Oct 5, 2023
1 parent dabbff9 commit 03af029
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/features/claims/ClaimModalSubheading.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { useEffect, useState } from "react";
import { formatNumber } from "../common/utils/formatNumber";
import { useClaimSelectionStore } from "../votes/store/useClaimSelectionStore";

export const ClaimModalSubheading = ({}: {}) => {
const [points, setPoints] = useState<{ total: number; selected: number }>();
const [pointsClaimableByEpoch, allClaims, selectedClaims] =
useClaimSelectionStore((state) => [
state.pointsClaimableByEpoch,
Expand All @@ -21,10 +23,19 @@ export const ClaimModalSubheading = ({}: {}) => {
0,
);

// Prevent title from updating when the modal is open
useEffect(() => {
if (points) return;
setPoints({
total: totalPointsClaimable,
selected: pointsSelected,
});
}, [totalPointsClaimable, pointsSelected, points]);

return (
<span>
Using {formatNumber(pointsSelected)} out of{" "}
{formatNumber(totalPointsClaimable)} points
Using {formatNumber(points?.selected)} out of{" "}
{formatNumber(points?.total)} points
</span>
);
};

0 comments on commit 03af029

Please sign in to comment.