Skip to content

Commit 42011d3

Browse files
authored
Merge pull request #484 from saasquatch/fix/earned-stat-type
fix: update reward balance query to total all status credit balance
2 parents b3b8293 + 36db162 commit 42011d3

File tree

4 files changed

+57
-14
lines changed

4 files changed

+57
-14
lines changed

packages/mint-components/CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [2.1.2] - 2026-03-09
11+
12+
### Fixed
13+
14+
- \<sqm-big-stat>
15+
- Fix expired rewards query reading `prettyAssignedCredit` instead of `prettyExpiredCredit`
16+
- Fix cancelled rewards query reading `prettyAssignedCredit` instead of `prettyCancelledCredit`
17+
- Fix earned rewards balance calculation to use sum of `totalAssignedCredit` and `totalPendingCredit`
18+
1019
## [2.1.1] - 2026-02-26
1120

1221
### Updated
@@ -1461,7 +1470,8 @@ This major release represents a significant advancement in the theming capabilit
14611470
- \<sqm-popup-container>
14621471
- \<sqm-stencilbook>
14631472

1464-
[unreleased]: https://github.com/saasquatch/program-tools/compare/mint-components@2.1.1...HEAD
1473+
[unreleased]: https://github.com/saasquatch/program-tools/compare/mint-components@2.1.2...HEAD
1474+
[2.1.2]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fmint-components%402.1.2
14651475
[2.1.1]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fmint-components%402.1.1
14661476
[2.1.0]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fmint-components%402.1.0
14671477
[2.0.10]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fmint-components%402.0.10

packages/mint-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@saasquatch/mint-components",
33
"title": "Mint Components",
4-
"version": "2.1.1",
4+
"version": "2.1.2",
55
"description": "A minimal design library with components for referral and loyalty experiences. Built with Shoelace components by Saasquatch.",
66
"icon": "https://res.cloudinary.com/saasquatch/image/upload/v1652219900/squatch-assets/For_Mint.svg",
77
"raisins": "docs/raisins.json",

packages/mint-components/src/components/sqm-big-stat/useBigStat.tsx

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -765,8 +765,8 @@ const rewardsExpiredQuery = (
765765
const arr = res.data?.viewer?.rewardBalanceDetails;
766766
const fallback = res.data?.fallback;
767767
return {
768-
value: arr?.[0]?.prettyAssignedCredit || 0,
769-
statvalue: arr?.[0]?.prettyAssignedCredit || fallback,
768+
value: arr?.[0]?.prettyExpiredCredit || 0,
769+
statvalue: arr?.[0]?.prettyExpiredCredit || fallback,
770770
};
771771
}
772772
);
@@ -818,8 +818,8 @@ const rewardsCancelledQuery = (
818818
const arr = res.data?.viewer?.rewardBalanceDetails;
819819
const fallback = res.data?.fallback;
820820
return {
821-
value: arr?.[0]?.prettyAssignedCredit || 0,
822-
statvalue: arr?.[0]?.prettyAssignedCredit || fallback,
821+
value: arr?.[0]?.prettyCancelledCredit || 0,
822+
statvalue: arr?.[0]?.prettyCancelledCredit || fallback,
823823
};
824824
}
825825
);
@@ -890,14 +890,16 @@ const rewardsBalanceQuery = (
890890
format = "prettyValue",
891891
global = ""
892892
) => {
893+
const formatType = parseRewardValueFormat[format] ?? "UNIT_FORMATTED";
894+
893895
return debugQuery(
894896
gql`
895897
query (
896898
$programId: ID
897899
$type: RewardType!
898900
$unit: String!
899-
$format: RewardValueFormatType!
900901
$locale: RSLocale
902+
$format: RewardValueFormatType!
901903
) {
902904
fallback: formatRewardPrettyValue(
903905
value: 0
@@ -913,7 +915,8 @@ const rewardsBalanceQuery = (
913915
locale: $locale
914916
) {
915917
... on CreditRewardBalance {
916-
prettyAvailableValue(formatType: $format)
918+
totalAssignedCredit
919+
totalPendingCredit
917920
}
918921
}
919922
}
@@ -922,18 +925,48 @@ const rewardsBalanceQuery = (
922925
`,
923926
{
924927
programId: !global && programId !== "classic" ? programId : null,
925-
926928
type,
927929
unit,
928-
format: parseRewardValueFormat[format] ?? "UNIT_FORMATTED",
929930
locale,
931+
format: formatType,
930932
},
931933
(res) => {
932934
const arr = res.data?.viewer?.rewardBalanceDetails;
933935
const fallback = res.data?.fallback;
936+
const balance = arr?.[0];
937+
const totalEarned = balance
938+
? (balance.totalAssignedCredit || 0) +
939+
(balance.totalPendingCredit || 0)
940+
: 0;
941+
942+
const result = useQuery(
943+
gql`
944+
query (
945+
$value: Int!
946+
$unit: String!
947+
$locale: RSLocale
948+
$format: RewardValueFormatType!
949+
) {
950+
formatRewardPrettyValue(
951+
value: $value
952+
unit: $unit
953+
locale: $locale
954+
formatType: $format
955+
)
956+
}
957+
`,
958+
{
959+
value: totalEarned,
960+
unit,
961+
locale,
962+
format: formatType,
963+
},
964+
res.loading
965+
);
966+
934967
return {
935-
value: arr?.[0]?.prettyAvailableValue || 0,
936-
statvalue: arr?.[0]?.prettyAvailableValue || fallback,
968+
value: totalEarned,
969+
statvalue: result?.data?.formatRewardPrettyValue || fallback,
937970
};
938971
}
939972
);

packages/mint-components/src/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard-view.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { h, VNode } from "@stencil/core";
22
import { intl } from "../../../global/global";
33
import { createStyleSheet } from "../../../styling/JSS";
4-
import { PayoutStatus } from "../sqm-payout-status-alert/usePayoutStatus";
54
import { TaxDocumentType } from "../data";
5+
import { PayoutStatus } from "../sqm-payout-status-alert/usePayoutStatus";
66

77
export interface TaxAndCashDashboardProps {
88
states: {
@@ -1153,7 +1153,7 @@ export const TaxAndCashDashboardView = (props: TaxAndCashDashboardProps) => {
11531153
</span>
11541154
</div>
11551155
</span>
1156-
{states.noFormNeeded &&
1156+
{!states.noFormNeeded &&
11571157
states.status !== "NOT_VERIFIED" && (
11581158
<sl-button
11591159
disabled={states.disabled || states.loading}

0 commit comments

Comments
 (0)