@wlloyalty/wll-react-sdk 1.0.112 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -139,7 +139,7 @@ declare class RoundupTileConfig {
139
139
  amountPrefix?: string | null;
140
140
  amountSuffix?: string | null;
141
141
  artworkUrl?: string | null;
142
- amount?: number;
142
+ balance?: number;
143
143
  ctaLink?: string | null;
144
144
  ctaLinkTarget?: CTALinkTarget;
145
145
  }
package/dist/native.js CHANGED
@@ -3744,59 +3744,52 @@ var useInitialGroupFetch = function (_a) {
3744
3744
  var sdk = useWllSdk();
3745
3745
  var _b = React.useState(true), isLoading = _b[0], setIsLoading = _b[1];
3746
3746
  var _c = React.useState(null), error = _c[0], setError = _c[1];
3747
- var fetchInProgressRef = React.useRef(false);
3748
3747
  React.useEffect(function () {
3749
- var isMounted = true;
3750
- var fetch = function () { return __awaiter(void 0, void 0, void 0, function () {
3748
+ var cancelled = false;
3749
+ var fetchGroup = function () { return __awaiter(void 0, void 0, void 0, function () {
3751
3750
  var response;
3752
- var _a;
3753
- return __generator(this, function (_b) {
3754
- switch (_b.label) {
3751
+ var _b;
3752
+ return __generator(this, function (_c) {
3753
+ switch (_c.label) {
3755
3754
  case 0:
3756
- if (fetchInProgressRef.current) {
3757
- return [2 /*return*/];
3758
- }
3759
- fetchInProgressRef.current = true;
3760
- if (!id || !sdk || !sdk.refreshGroup) {
3755
+ if (!id || !(sdk === null || sdk === void 0 ? void 0 : sdk.refreshGroup)) {
3761
3756
  setError('Unable to fetch group data: invalid configuration');
3762
3757
  setIsLoading(false);
3763
3758
  return [2 /*return*/];
3764
3759
  }
3765
3760
  setIsLoading(true);
3766
3761
  setError(null);
3767
- _b.label = 1;
3762
+ _c.label = 1;
3768
3763
  case 1:
3769
- _b.trys.push([1, 3, 4, 5]);
3764
+ _c.trys.push([1, 3, 4, 5]);
3770
3765
  return [4 /*yield*/, sdk.refreshGroup(id)];
3771
3766
  case 2:
3772
- response = _b.sent();
3773
- if (!isMounted)
3767
+ response = _c.sent();
3768
+ if (cancelled)
3774
3769
  return [2 /*return*/];
3775
3770
  if ((response === null || response === void 0 ? void 0 : response.status) === 'success' && response.data) {
3776
3771
  setGroupData(response.data);
3777
3772
  }
3778
3773
  else {
3779
- setError((_a = response === null || response === void 0 ? void 0 : response.error) !== null && _a !== void 0 ? _a : 'Failed to fetch group data');
3774
+ setError((_b = response === null || response === void 0 ? void 0 : response.error) !== null && _b !== void 0 ? _b : 'Failed to fetch group data');
3780
3775
  }
3781
3776
  return [3 /*break*/, 5];
3782
3777
  case 3:
3783
- _b.sent();
3784
- if (isMounted) {
3778
+ _c.sent();
3779
+ if (!cancelled)
3785
3780
  setError('An unexpected error occurred.');
3786
- }
3787
3781
  return [3 /*break*/, 5];
3788
3782
  case 4:
3789
- if (isMounted) {
3783
+ if (!cancelled)
3790
3784
  setIsLoading(false);
3791
- }
3792
3785
  return [7 /*endfinally*/];
3793
3786
  case 5: return [2 /*return*/];
3794
3787
  }
3795
3788
  });
3796
3789
  }); };
3797
- fetch();
3790
+ fetchGroup();
3798
3791
  return function () {
3799
- isMounted = false;
3792
+ cancelled = true;
3800
3793
  };
3801
3794
  }, [id, sdk, setGroupData]);
3802
3795
  return { isLoading: isLoading, error: error };
@@ -4419,7 +4412,7 @@ var Group = function (_a) {
4419
4412
  if (isLoading) {
4420
4413
  return (jsxRuntimeExports.jsx(reactNative.View, { style: {
4421
4414
  flex: 1,
4422
- padding: theme.sizes.lg,
4415
+ padding: IS_MOBILE ? theme.sizes.lg : undefined,
4423
4416
  }, accessible: true, accessibilityLabel: "Loading group data", children: jsxRuntimeExports.jsx(Skeleton, { numberOfSquares: IS_WEB ? 4 : 2 }) }));
4424
4417
  }
4425
4418
  if (error || !groupData) {
@@ -5081,6 +5074,22 @@ TierTile.Full = TierTileFull;
5081
5074
  TierTile.Half = TierTileHalf;
5082
5075
  TierTile.Empty = TierTileEmpty;
5083
5076
 
5077
+ /**
5078
+ * Renders formatted points value for a Roundup Tile.
5079
+ *
5080
+ * @returns JSX.Element or null if points are undefined or zero
5081
+ */
5082
+ var RoundupTileFormattedPoints = function () {
5083
+ var tileContext = useTileContext();
5084
+ if (!isContextValid(tileContext))
5085
+ return null;
5086
+ var _a = tileContext.configuration, _b = _a.balance, balance = _b === void 0 ? 0 : _b, _c = _a.amountPrefix, amountPrefix = _c === void 0 ? '' : _c, _d = _a.amountSuffix, amountSuffix = _d === void 0 ? '' : _d;
5087
+ if (balance === undefined)
5088
+ return null;
5089
+ var fullPointsText = "".concat(amountPrefix).concat(cleanNumber(balance)).concat(amountSuffix).trim();
5090
+ return (jsxRuntimeExports.jsx(reactNative.View, { testID: "roundup-tile-amount", role: "article", accessibilityLabel: "Amount: ".concat(fullPointsText), children: jsxRuntimeExports.jsx(Row, { align: "center", justify: "start", children: jsxRuntimeExports.jsx(Text, { variant: "caption", testID: "roundup-tile-value", children: fullPointsText }) }) }));
5091
+ };
5092
+
5084
5093
  /**
5085
5094
  * Custom hook that returns the styles for the RoundupTile component.
5086
5095
  * Applies responsive styling based on the current device.
@@ -5100,9 +5109,6 @@ var useRoundupTileStyles = function (isFullSize) {
5100
5109
  },
5101
5110
  contentContainer: {
5102
5111
  width: '100%',
5103
- marginTop: isFullSize
5104
- ? useResponsiveValue(theme.sizes.xxl, theme.sizes.md, isDesktop, isTablet)
5105
- : 0,
5106
5112
  },
5107
5113
  contentColumn: {
5108
5114
  flexGrow: 1,
@@ -5147,23 +5153,6 @@ var useRoundupTileStyles = function (isFullSize) {
5147
5153
  });
5148
5154
  };
5149
5155
 
5150
- /**
5151
- * Renders formatted points value for a Roundup Tile.
5152
- *
5153
- * @returns JSX.Element or null if points are undefined or zero
5154
- */
5155
- var RoundupTileFormattedPoints = function () {
5156
- var styles = useRoundupTileStyles();
5157
- var tileContext = useTileContext();
5158
- if (!isContextValid(tileContext))
5159
- return null;
5160
- var _a = tileContext.configuration, _b = _a.amountPrefix, amountPrefix = _b === void 0 ? '' : _b, _c = _a.amountSuffix, amountSuffix = _c === void 0 ? '' : _c, _d = _a.amount, amount = _d === void 0 ? 0 : _d;
5161
- if (amount === undefined)
5162
- return null;
5163
- var fullPointsText = "".concat(amountPrefix).concat(amount, " ").concat(amountSuffix).trim();
5164
- return (jsxRuntimeExports.jsx(reactNative.View, { testID: "roundup-tile-amount", role: "article", accessibilityLabel: "Amount: ".concat(fullPointsText), children: jsxRuntimeExports.jsxs(Row, { align: "center", justify: "start", children: [amountPrefix ? (jsxRuntimeExports.jsx(Text, { variant: "caption", testID: "roundup-tile-prefix", children: amountPrefix })) : null, jsxRuntimeExports.jsx(Text, { variant: "caption", testID: "roundup-tile-value", children: amount }), amountSuffix ? (jsxRuntimeExports.jsx(Text, { variant: "caption", style: styles.suffix, testID: "roundup-tile-suffix", children: amountSuffix })) : null] }) }));
5165
- };
5166
-
5167
5156
  /**
5168
5157
  * Renders the media of a Points Tile.
5169
5158
  *