@superlogic/spree-pay 0.1.23 → 0.1.24

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/build/index.cjs CHANGED
@@ -204,7 +204,7 @@ var useSpreePayConfig = () => {
204
204
  rainbowProjectId: data.rainbowProjectId ?? "3fdcd5ff50cb84917cd05e40146975d8",
205
205
  rainbowAppName: data.rainbowAppName ?? "AIR Shop",
206
206
  pointsTitle: data.pointsTitle ?? "AIR SP",
207
- pointsConversionRatio: data.pointsConversionRatio ?? 100,
207
+ pointsConversionRatio: data.pointsConversionRatio ?? 0.01,
208
208
  crypto: {
209
209
  ...data.crypto,
210
210
  oneInchAggregationRouter: data.crypto?.oneInchAggregationRouter || "0x111111125421ca6dc452d289314280a0f8842a65"
@@ -302,7 +302,7 @@ var getSplitAmount = (amount, splitTokens, pointsConversionRatio) => {
302
302
  return amount;
303
303
  }
304
304
  if (pointsConversionRatio <= 0) return amount;
305
- const usdCoveredByPoints = splitTokens / pointsConversionRatio;
305
+ const usdCoveredByPoints = splitTokens * pointsConversionRatio;
306
306
  const remaining = amount - usdCoveredByPoints;
307
307
  return Math.max(0, parseFloat(remaining.toFixed(2)));
308
308
  };
@@ -1319,7 +1319,7 @@ var PointsSwitch = (props) => {
1319
1319
  balance?.availablePoints ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("p", { className: "flex-1 text-right text-sm font-medium text-black", children: [
1320
1320
  formatPoints(balance.availablePoints, spreePayConfig?.pointsTitle),
1321
1321
  " ",
1322
- !!spreePayConfig?.pointsConversionRatio && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-black/50", children: formatUSD(balance.availablePoints / spreePayConfig.pointsConversionRatio) })
1322
+ !!spreePayConfig?.pointsConversionRatio && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-black/50", children: formatUSD(balance.availablePoints * spreePayConfig.pointsConversionRatio) })
1323
1323
  ] }) : null
1324
1324
  ] }),
1325
1325
  message && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-start gap-1 rounded-sm border-1 border-[#006FD533] bg-[#006FD50D] p-1.5", children: [
@@ -2339,7 +2339,8 @@ var PointsSelector = (props) => {
2339
2339
  const { spreePayConfig } = useSpreePayConfig();
2340
2340
  const { pointsConversionRatio } = spreePayConfig || {};
2341
2341
  const min = 0;
2342
- const max = Math.min((appProps.amount ?? 0) * (pointsConversionRatio ?? 0), balance?.availablePoints ?? 0);
2342
+ const maxByAmount = pointsConversionRatio && pointsConversionRatio > 0 ? (appProps.amount ?? 0) / pointsConversionRatio : 0;
2343
+ const max = Math.min(maxByAmount, balance?.availablePoints ?? 0);
2343
2344
  const step = 10;
2344
2345
  const [splitTokens, setSplitTokens] = (0, import_react10.useState)(0);
2345
2346
  const usdAmount = getSplitAmount(appProps.amount ?? 0, splitTokens, pointsConversionRatio);
@@ -2450,7 +2451,7 @@ var SplitBlock = (props) => {
2450
2451
  " ",
2451
2452
  formatPoints(balance.availablePoints, pointsTitle),
2452
2453
  " ",
2453
- pointsConversionRatio && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-black/50", children: formatUSD(balance.availablePoints / pointsConversionRatio) })
2454
+ pointsConversionRatio && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-black/50", children: formatUSD(balance.availablePoints * pointsConversionRatio) })
2454
2455
  ] }) : null }),
2455
2456
  isBalanceLoading ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "h-4 w-6 animate-pulse bg-gray-200" }) : !balance?.availablePoints && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-sm font-medium text-black", children: "No points available" }),
2456
2457
  address && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "text-sm font-medium text-black", children: address.length > 8 ? `${address.slice(0, 4)}...${address.slice(-4)}` : address })
@@ -3267,7 +3268,7 @@ var import_jsx_runtime39 = require("react/jsx-runtime");
3267
3268
  var CryptoTab = () => {
3268
3269
  const { spreePayConfig } = useSpreePayConfig();
3269
3270
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { children: [
3270
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "border-b-1 border-black/7 px-5 py-5 md:px-7 md:py-5", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CryptoWrapper, {}) }),
3271
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "border-b-1 border-black/7 px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CryptoWrapper, {}) }),
3271
3272
  /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PointsSwitch, { disabled: true, message: spreePayConfig?.crypto.pointsInfoMessage }) })
3272
3273
  ] });
3273
3274
  };
package/build/index.css CHANGED
@@ -1483,11 +1483,6 @@
1483
1483
  padding-inline: calc(var(--spacing) * 7);
1484
1484
  }
1485
1485
  }
1486
- .sl-spreepay .md\:py-5 {
1487
- @media (width >= 48rem) {
1488
- padding-block: calc(var(--spacing) * 5);
1489
- }
1490
- }
1491
1486
  .sl-spreepay .md\:py-6 {
1492
1487
  @media (width >= 48rem) {
1493
1488
  padding-block: calc(var(--spacing) * 6);
package/build/index.js CHANGED
@@ -164,7 +164,7 @@ var useSpreePayConfig = () => {
164
164
  rainbowProjectId: data.rainbowProjectId ?? "3fdcd5ff50cb84917cd05e40146975d8",
165
165
  rainbowAppName: data.rainbowAppName ?? "AIR Shop",
166
166
  pointsTitle: data.pointsTitle ?? "AIR SP",
167
- pointsConversionRatio: data.pointsConversionRatio ?? 100,
167
+ pointsConversionRatio: data.pointsConversionRatio ?? 0.01,
168
168
  crypto: {
169
169
  ...data.crypto,
170
170
  oneInchAggregationRouter: data.crypto?.oneInchAggregationRouter || "0x111111125421ca6dc452d289314280a0f8842a65"
@@ -262,7 +262,7 @@ var getSplitAmount = (amount, splitTokens, pointsConversionRatio) => {
262
262
  return amount;
263
263
  }
264
264
  if (pointsConversionRatio <= 0) return amount;
265
- const usdCoveredByPoints = splitTokens / pointsConversionRatio;
265
+ const usdCoveredByPoints = splitTokens * pointsConversionRatio;
266
266
  const remaining = amount - usdCoveredByPoints;
267
267
  return Math.max(0, parseFloat(remaining.toFixed(2)));
268
268
  };
@@ -1279,7 +1279,7 @@ var PointsSwitch = (props) => {
1279
1279
  balance?.availablePoints ? /* @__PURE__ */ jsxs9("p", { className: "flex-1 text-right text-sm font-medium text-black", children: [
1280
1280
  formatPoints(balance.availablePoints, spreePayConfig?.pointsTitle),
1281
1281
  " ",
1282
- !!spreePayConfig?.pointsConversionRatio && /* @__PURE__ */ jsx15("span", { className: "text-black/50", children: formatUSD(balance.availablePoints / spreePayConfig.pointsConversionRatio) })
1282
+ !!spreePayConfig?.pointsConversionRatio && /* @__PURE__ */ jsx15("span", { className: "text-black/50", children: formatUSD(balance.availablePoints * spreePayConfig.pointsConversionRatio) })
1283
1283
  ] }) : null
1284
1284
  ] }),
1285
1285
  message && /* @__PURE__ */ jsxs9("div", { className: "flex items-start gap-1 rounded-sm border-1 border-[#006FD533] bg-[#006FD50D] p-1.5", children: [
@@ -2299,7 +2299,8 @@ var PointsSelector = (props) => {
2299
2299
  const { spreePayConfig } = useSpreePayConfig();
2300
2300
  const { pointsConversionRatio } = spreePayConfig || {};
2301
2301
  const min = 0;
2302
- const max = Math.min((appProps.amount ?? 0) * (pointsConversionRatio ?? 0), balance?.availablePoints ?? 0);
2302
+ const maxByAmount = pointsConversionRatio && pointsConversionRatio > 0 ? (appProps.amount ?? 0) / pointsConversionRatio : 0;
2303
+ const max = Math.min(maxByAmount, balance?.availablePoints ?? 0);
2303
2304
  const step = 10;
2304
2305
  const [splitTokens, setSplitTokens] = useState8(0);
2305
2306
  const usdAmount = getSplitAmount(appProps.amount ?? 0, splitTokens, pointsConversionRatio);
@@ -2410,7 +2411,7 @@ var SplitBlock = (props) => {
2410
2411
  " ",
2411
2412
  formatPoints(balance.availablePoints, pointsTitle),
2412
2413
  " ",
2413
- pointsConversionRatio && /* @__PURE__ */ jsx25("span", { className: "text-black/50", children: formatUSD(balance.availablePoints / pointsConversionRatio) })
2414
+ pointsConversionRatio && /* @__PURE__ */ jsx25("span", { className: "text-black/50", children: formatUSD(balance.availablePoints * pointsConversionRatio) })
2414
2415
  ] }) : null }),
2415
2416
  isBalanceLoading ? /* @__PURE__ */ jsx25("div", { className: "h-4 w-6 animate-pulse bg-gray-200" }) : !balance?.availablePoints && /* @__PURE__ */ jsx25("p", { className: "text-sm font-medium text-black", children: "No points available" }),
2416
2417
  address && /* @__PURE__ */ jsx25("div", { className: "text-sm font-medium text-black", children: address.length > 8 ? `${address.slice(0, 4)}...${address.slice(-4)}` : address })
@@ -3227,7 +3228,7 @@ import { jsx as jsx39, jsxs as jsxs23 } from "react/jsx-runtime";
3227
3228
  var CryptoTab = () => {
3228
3229
  const { spreePayConfig } = useSpreePayConfig();
3229
3230
  return /* @__PURE__ */ jsxs23("div", { children: [
3230
- /* @__PURE__ */ jsx39("div", { className: "border-b-1 border-black/7 px-5 py-5 md:px-7 md:py-5", children: /* @__PURE__ */ jsx39(CryptoWrapper, {}) }),
3231
+ /* @__PURE__ */ jsx39("div", { className: "border-b-1 border-black/7 px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ jsx39(CryptoWrapper, {}) }),
3231
3232
  /* @__PURE__ */ jsx39("div", { className: "px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ jsx39(PointsSwitch, { disabled: true, message: spreePayConfig?.crypto.pointsInfoMessage }) })
3232
3233
  ] });
3233
3234
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superlogic/spree-pay",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "description": "Spree-pay React component and utilities",
5
5
  "private": false,
6
6
  "type": "module",