@wlloyalty/wll-react-sdk 1.0.113 → 1.2.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 +1 -1
- package/dist/native.js +40 -30
- package/dist/native.js.map +1 -1
- package/dist/types/mocks/tiles/roundupTile.d.ts +10 -3
- package/dist/types/types/tile.d.ts +1 -1
- package/dist/types/utils/pointsHelpers.d.ts +6 -0
- package/dist/web.js +54 -51
- package/dist/web.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/native.js
CHANGED
|
@@ -3739,39 +3739,50 @@ var useGroupRefresh = function (_a) {
|
|
|
3739
3739
|
}, [id, sdk, enabled, setGroupData]);
|
|
3740
3740
|
};
|
|
3741
3741
|
|
|
3742
|
+
var inFlightRequests = new Map();
|
|
3742
3743
|
var useInitialGroupFetch = function (_a) {
|
|
3743
3744
|
var id = _a.id, setGroupData = _a.setGroupData;
|
|
3744
3745
|
var sdk = useWllSdk();
|
|
3745
3746
|
var _b = React.useState(true), isLoading = _b[0], setIsLoading = _b[1];
|
|
3746
3747
|
var _c = React.useState(null), error = _c[0], setError = _c[1];
|
|
3747
3748
|
React.useEffect(function () {
|
|
3749
|
+
if (!id || !(sdk === null || sdk === void 0 ? void 0 : sdk.refreshGroup)) {
|
|
3750
|
+
setError('Unable to fetch group data: invalid configuration');
|
|
3751
|
+
setIsLoading(false);
|
|
3752
|
+
return;
|
|
3753
|
+
}
|
|
3748
3754
|
var cancelled = false;
|
|
3749
|
-
var
|
|
3750
|
-
var
|
|
3755
|
+
var fetch = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3756
|
+
var existing, request, res;
|
|
3751
3757
|
var _b;
|
|
3752
3758
|
return __generator(this, function (_c) {
|
|
3753
3759
|
switch (_c.label) {
|
|
3754
3760
|
case 0:
|
|
3755
|
-
if (!id || !(sdk === null || sdk === void 0 ? void 0 : sdk.refreshGroup)) {
|
|
3756
|
-
setError('Unable to fetch group data: invalid configuration');
|
|
3757
|
-
setIsLoading(false);
|
|
3758
|
-
return [2 /*return*/];
|
|
3759
|
-
}
|
|
3760
3761
|
setIsLoading(true);
|
|
3761
3762
|
setError(null);
|
|
3763
|
+
existing = inFlightRequests.get(id);
|
|
3764
|
+
request = existing !== null && existing !== void 0 ? existing : sdk.refreshGroup(id);
|
|
3765
|
+
if (!existing) {
|
|
3766
|
+
inFlightRequests.set(id, request);
|
|
3767
|
+
request.finally(function () {
|
|
3768
|
+
if (inFlightRequests.get(id) === request) {
|
|
3769
|
+
inFlightRequests.delete(id);
|
|
3770
|
+
}
|
|
3771
|
+
});
|
|
3772
|
+
}
|
|
3762
3773
|
_c.label = 1;
|
|
3763
3774
|
case 1:
|
|
3764
3775
|
_c.trys.push([1, 3, 4, 5]);
|
|
3765
|
-
return [4 /*yield*/,
|
|
3776
|
+
return [4 /*yield*/, request];
|
|
3766
3777
|
case 2:
|
|
3767
|
-
|
|
3778
|
+
res = _c.sent();
|
|
3768
3779
|
if (cancelled)
|
|
3769
3780
|
return [2 /*return*/];
|
|
3770
|
-
if ((
|
|
3771
|
-
setGroupData(
|
|
3781
|
+
if ((res === null || res === void 0 ? void 0 : res.status) === 'success' && res.data) {
|
|
3782
|
+
setGroupData(res.data);
|
|
3772
3783
|
}
|
|
3773
3784
|
else {
|
|
3774
|
-
setError((_b =
|
|
3785
|
+
setError((_b = res === null || res === void 0 ? void 0 : res.error) !== null && _b !== void 0 ? _b : 'Failed to fetch group data');
|
|
3775
3786
|
}
|
|
3776
3787
|
return [3 /*break*/, 5];
|
|
3777
3788
|
case 3:
|
|
@@ -3787,7 +3798,7 @@ var useInitialGroupFetch = function (_a) {
|
|
|
3787
3798
|
}
|
|
3788
3799
|
});
|
|
3789
3800
|
}); };
|
|
3790
|
-
|
|
3801
|
+
fetch();
|
|
3791
3802
|
return function () {
|
|
3792
3803
|
cancelled = true;
|
|
3793
3804
|
};
|
|
@@ -5074,6 +5085,22 @@ TierTile.Full = TierTileFull;
|
|
|
5074
5085
|
TierTile.Half = TierTileHalf;
|
|
5075
5086
|
TierTile.Empty = TierTileEmpty;
|
|
5076
5087
|
|
|
5088
|
+
/**
|
|
5089
|
+
* Renders formatted points value for a Roundup Tile.
|
|
5090
|
+
*
|
|
5091
|
+
* @returns JSX.Element or null if points are undefined or zero
|
|
5092
|
+
*/
|
|
5093
|
+
var RoundupTileFormattedPoints = function () {
|
|
5094
|
+
var tileContext = useTileContext();
|
|
5095
|
+
if (!isContextValid(tileContext))
|
|
5096
|
+
return null;
|
|
5097
|
+
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;
|
|
5098
|
+
if (balance === undefined)
|
|
5099
|
+
return null;
|
|
5100
|
+
var fullPointsText = "".concat(amountPrefix).concat(cleanNumber(balance)).concat(amountSuffix).trim();
|
|
5101
|
+
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 }) }) }));
|
|
5102
|
+
};
|
|
5103
|
+
|
|
5077
5104
|
/**
|
|
5078
5105
|
* Custom hook that returns the styles for the RoundupTile component.
|
|
5079
5106
|
* Applies responsive styling based on the current device.
|
|
@@ -5137,23 +5164,6 @@ var useRoundupTileStyles = function (isFullSize) {
|
|
|
5137
5164
|
});
|
|
5138
5165
|
};
|
|
5139
5166
|
|
|
5140
|
-
/**
|
|
5141
|
-
* Renders formatted points value for a Roundup Tile.
|
|
5142
|
-
*
|
|
5143
|
-
* @returns JSX.Element or null if points are undefined or zero
|
|
5144
|
-
*/
|
|
5145
|
-
var RoundupTileFormattedPoints = function () {
|
|
5146
|
-
var styles = useRoundupTileStyles();
|
|
5147
|
-
var tileContext = useTileContext();
|
|
5148
|
-
if (!isContextValid(tileContext))
|
|
5149
|
-
return null;
|
|
5150
|
-
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;
|
|
5151
|
-
if (amount === undefined)
|
|
5152
|
-
return null;
|
|
5153
|
-
var fullPointsText = "".concat(amountPrefix).concat(amount, " ").concat(amountSuffix).trim();
|
|
5154
|
-
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] }) }));
|
|
5155
|
-
};
|
|
5156
|
-
|
|
5157
5167
|
/**
|
|
5158
5168
|
* Renders the media of a Points Tile.
|
|
5159
5169
|
*
|