@superlogic/spree-pay 0.1.23 → 0.1.25

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: [
@@ -1337,6 +1337,7 @@ var PointsSwitch = (props) => {
1337
1337
 
1338
1338
  // src/components/CreditCardTab/Points/SplitBlock.tsx
1339
1339
  var import_react11 = require("react");
1340
+ var import_airkit2 = require("@mocanetwork/airkit");
1340
1341
 
1341
1342
  // src/components/CreditCardTab/Points/PointsSelector.tsx
1342
1343
  var import_react10 = require("react");
@@ -2339,7 +2340,8 @@ var PointsSelector = (props) => {
2339
2340
  const { spreePayConfig } = useSpreePayConfig();
2340
2341
  const { pointsConversionRatio } = spreePayConfig || {};
2341
2342
  const min = 0;
2342
- const max = Math.min((appProps.amount ?? 0) * (pointsConversionRatio ?? 0), balance?.availablePoints ?? 0);
2343
+ const maxByAmount = pointsConversionRatio && pointsConversionRatio > 0 ? (appProps.amount ?? 0) / pointsConversionRatio : 0;
2344
+ const max = Math.min(maxByAmount, balance?.availablePoints ?? 0);
2343
2345
  const step = 10;
2344
2346
  const [splitTokens, setSplitTokens] = (0, import_react10.useState)(0);
2345
2347
  const usdAmount = getSplitAmount(appProps.amount ?? 0, splitTokens, pointsConversionRatio);
@@ -2420,13 +2422,15 @@ var SplitBlock = (props) => {
2420
2422
  const [address, setAddress] = (0, import_react11.useState)(null);
2421
2423
  const [walletReady, setWalletReady] = (0, import_react11.useState)(false);
2422
2424
  const { pointsConversionRatio, pointsTitle } = spreePayConfig || {};
2425
+ const { env } = useSpreePayEnv();
2423
2426
  const initWallet = (0, import_react11.useCallback)(
2424
2427
  async (pointsChain) => {
2425
2428
  if (!pointsChain) return;
2426
2429
  try {
2427
2430
  const res = await getAirWallet({
2428
2431
  mocaChain: pointsChain.mocaChain,
2429
- partnerId: pointsChain.partnerId
2432
+ partnerId: pointsChain.partnerId,
2433
+ buildEnv: env.environment === "prod" ? import_airkit2.BUILD_ENV.PRODUCTION : import_airkit2.BUILD_ENV.SANDBOX
2430
2434
  });
2431
2435
  setAddress(res.address ?? null);
2432
2436
  setWalletReady(res.walletReady);
@@ -2437,7 +2441,7 @@ var SplitBlock = (props) => {
2437
2441
  console.error("Air Wallet init failed:", e);
2438
2442
  }
2439
2443
  },
2440
- [onToggle]
2444
+ [onToggle, env.environment]
2441
2445
  );
2442
2446
  (0, import_react11.useEffect)(() => {
2443
2447
  setAddress(null);
@@ -2450,7 +2454,7 @@ var SplitBlock = (props) => {
2450
2454
  " ",
2451
2455
  formatPoints(balance.availablePoints, pointsTitle),
2452
2456
  " ",
2453
- pointsConversionRatio && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-black/50", children: formatUSD(balance.availablePoints / pointsConversionRatio) })
2457
+ pointsConversionRatio && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-black/50", children: formatUSD(balance.availablePoints * pointsConversionRatio) })
2454
2458
  ] }) : null }),
2455
2459
  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
2460
  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 +3271,7 @@ var import_jsx_runtime39 = require("react/jsx-runtime");
3267
3271
  var CryptoTab = () => {
3268
3272
  const { spreePayConfig } = useSpreePayConfig();
3269
3273
  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, {}) }),
3274
+ /* @__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
3275
  /* @__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
3276
  ] });
3273
3277
  };
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: [
@@ -1297,6 +1297,7 @@ var PointsSwitch = (props) => {
1297
1297
 
1298
1298
  // src/components/CreditCardTab/Points/SplitBlock.tsx
1299
1299
  import { useCallback as useCallback4, useEffect as useEffect6, useState as useState9 } from "react";
1300
+ import { BUILD_ENV as BUILD_ENV2 } from "@mocanetwork/airkit";
1300
1301
 
1301
1302
  // src/components/CreditCardTab/Points/PointsSelector.tsx
1302
1303
  import { useState as useState8 } from "react";
@@ -2299,7 +2300,8 @@ var PointsSelector = (props) => {
2299
2300
  const { spreePayConfig } = useSpreePayConfig();
2300
2301
  const { pointsConversionRatio } = spreePayConfig || {};
2301
2302
  const min = 0;
2302
- const max = Math.min((appProps.amount ?? 0) * (pointsConversionRatio ?? 0), balance?.availablePoints ?? 0);
2303
+ const maxByAmount = pointsConversionRatio && pointsConversionRatio > 0 ? (appProps.amount ?? 0) / pointsConversionRatio : 0;
2304
+ const max = Math.min(maxByAmount, balance?.availablePoints ?? 0);
2303
2305
  const step = 10;
2304
2306
  const [splitTokens, setSplitTokens] = useState8(0);
2305
2307
  const usdAmount = getSplitAmount(appProps.amount ?? 0, splitTokens, pointsConversionRatio);
@@ -2380,13 +2382,15 @@ var SplitBlock = (props) => {
2380
2382
  const [address, setAddress] = useState9(null);
2381
2383
  const [walletReady, setWalletReady] = useState9(false);
2382
2384
  const { pointsConversionRatio, pointsTitle } = spreePayConfig || {};
2385
+ const { env } = useSpreePayEnv();
2383
2386
  const initWallet = useCallback4(
2384
2387
  async (pointsChain) => {
2385
2388
  if (!pointsChain) return;
2386
2389
  try {
2387
2390
  const res = await getAirWallet({
2388
2391
  mocaChain: pointsChain.mocaChain,
2389
- partnerId: pointsChain.partnerId
2392
+ partnerId: pointsChain.partnerId,
2393
+ buildEnv: env.environment === "prod" ? BUILD_ENV2.PRODUCTION : BUILD_ENV2.SANDBOX
2390
2394
  });
2391
2395
  setAddress(res.address ?? null);
2392
2396
  setWalletReady(res.walletReady);
@@ -2397,7 +2401,7 @@ var SplitBlock = (props) => {
2397
2401
  console.error("Air Wallet init failed:", e);
2398
2402
  }
2399
2403
  },
2400
- [onToggle]
2404
+ [onToggle, env.environment]
2401
2405
  );
2402
2406
  useEffect6(() => {
2403
2407
  setAddress(null);
@@ -2410,7 +2414,7 @@ var SplitBlock = (props) => {
2410
2414
  " ",
2411
2415
  formatPoints(balance.availablePoints, pointsTitle),
2412
2416
  " ",
2413
- pointsConversionRatio && /* @__PURE__ */ jsx25("span", { className: "text-black/50", children: formatUSD(balance.availablePoints / pointsConversionRatio) })
2417
+ pointsConversionRatio && /* @__PURE__ */ jsx25("span", { className: "text-black/50", children: formatUSD(balance.availablePoints * pointsConversionRatio) })
2414
2418
  ] }) : null }),
2415
2419
  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
2420
  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 +3231,7 @@ import { jsx as jsx39, jsxs as jsxs23 } from "react/jsx-runtime";
3227
3231
  var CryptoTab = () => {
3228
3232
  const { spreePayConfig } = useSpreePayConfig();
3229
3233
  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, {}) }),
3234
+ /* @__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
3235
  /* @__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
3236
  ] });
3233
3237
  };
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.25",
4
4
  "description": "Spree-pay React component and utilities",
5
5
  "private": false,
6
6
  "type": "module",