diff --git a/src/views/User/UserPoints.jsx b/src/views/User/UserPoints.jsx
index ad21edd..04cb6df 100644
--- a/src/views/User/UserPoints.jsx
+++ b/src/views/User/UserPoints.jsx
@@ -786,30 +786,30 @@ const UserPoints = () => {
)
const pointsCards = [
- {
- icon: ,
- title: 'Total',
- text: `${totalPoints} points`,
- subtext: 'All time earned',
- },
{
icon: ,
title: 'Available',
text: `${availablePoints} points`,
subtext: 'Ready to redeem',
},
- {
- icon: ,
- title: 'Period Points',
- text: `${periodPoints} points`,
- subtext: `${tabValue === 24 * 30 ? 'All time' : tabValue === 6 * 30 ? 'Last 6 months' : `Last ${tabValue} days`}`,
- },
{
icon: ,
title: 'Redeemed',
text: `${redeemedPoints} points`,
subtext: 'Previously used',
},
+ {
+ icon: ,
+ title: 'Total',
+ text: `${totalPoints} points`,
+ subtext: 'All time earned',
+ },
+ {
+ icon: ,
+ title: 'Period Points',
+ text: `${periodPoints} points`,
+ subtext: `${tabValue === 24 * 30 ? 'All time' : tabValue === 6 * 30 ? 'Last 6 months' : `Last ${tabValue} days`}`,
+ },
]
return pointsCards.map((card, index) => (
@@ -934,25 +934,31 @@ const UserPoints = () => {
{
- setIsRedeemModalOpen(false)
- },
- isOpen: isRedeemModalOpen,
- available: circleUsers.find(user => user.userId === selectedUser)
- ?.points,
- user: circleUsers.find(user => user.userId === selectedUser),
- onSave: ({ userId, points }) => {
- RedeemPoints(userId, points, userProfile.circleID)
- .then(() => {
- setIsRedeemModalOpen(false)
- handleCircleMembersRefetch()
- })
- .catch(err => {
- console.log(err)
- })
- },
- }}
+ config={(() => {
+ const user = circleUsers.find(u => u.userId === selectedUser)
+ const availablePoints = user
+ ? (user.points || 0) - (user.pointsRedeemed || 0)
+ : 0
+
+ return {
+ onClose: () => {
+ setIsRedeemModalOpen(false)
+ },
+ isOpen: isRedeemModalOpen,
+ available: availablePoints,
+ user: user,
+ onSave: ({ userId, points }) => {
+ RedeemPoints(userId, points, userProfile.circleID)
+ .then(() => {
+ setIsRedeemModalOpen(false)
+ handleCircleMembersRefetch()
+ })
+ .catch(err => {
+ console.log(err)
+ })
+ },
+ }
+ })()}
/>
)