@superlogic/spree-pay 0.1.29 → 0.1.31

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
@@ -44,7 +44,7 @@ var import_nice_modal_react7 = __toESM(require("@ebay/nice-modal-react"), 1);
44
44
  var import_swr5 = require("swr");
45
45
 
46
46
  // package.json
47
- var version = "0.1.29";
47
+ var version = "0.1.31";
48
48
 
49
49
  // src/context/SpreePayActionsContext.tsx
50
50
  var import_react = require("react");
@@ -372,9 +372,9 @@ var CheckoutButton = ({ isLoggedIn }) => {
372
372
  ) }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
373
373
  "a",
374
374
  {
375
- href: `${staticConfig.keycloakUrl}/realms/${env.tenantId}/protocol/openid-connect/logout?client_id=${staticConfig.keycloakClientId}&post_logout_redirect_uri=${window.location.origin}${window.location.pathname}`,
375
+ href: `${staticConfig.keycloakUrl}/realms/${env.tenantId}/protocol/openid-connect/auth?client_id=${staticConfig.keycloakClientId}&response_type=code&redirect_uri=${window.location.href}`,
376
376
  className: "bg-primary h-[60px] w-full cursor-pointer text-center text-xl leading-[60px] font-semibold text-white disabled:cursor-not-allowed disabled:opacity-50",
377
- children: "Login"
377
+ children: "Log in / Sign up for an AIR account"
378
378
  }
379
379
  )
380
380
  ] });
@@ -961,6 +961,13 @@ var useCards = () => {
961
961
  };
962
962
  };
963
963
 
964
+ // src/hooks/useSlapiBalance.ts
965
+ var import_swr3 = __toESM(require("swr"), 1);
966
+ var useSlapiBalance = () => {
967
+ const { data, isLoading, mutate } = (0, import_swr3.default)(`/v1/loyalty/accounts`);
968
+ return { balance: data?.detail, isBalanceLoading: isLoading, mutateBalance: mutate };
969
+ };
970
+
964
971
  // src/components/CreditCardTab/CreditCard/CreditCard.tsx
965
972
  var import_react6 = require("react");
966
973
  var import_react_stripe_js2 = require("@stripe/react-stripe-js");
@@ -1280,13 +1287,6 @@ var import_react12 = require("react");
1280
1287
  // src/components/common/PointsSwitch.tsx
1281
1288
  var import_react7 = require("react");
1282
1289
 
1283
- // src/hooks/useSlapiBalance.ts
1284
- var import_swr3 = __toESM(require("swr"), 1);
1285
- var useSlapiBalance = () => {
1286
- const { data, isLoading, mutate } = (0, import_swr3.default)(`/v1/loyalty/accounts`);
1287
- return { balance: data?.detail, isBalanceLoading: isLoading, mutateBalance: mutate };
1288
- };
1289
-
1290
1290
  // src/ui/switch.tsx
1291
1291
  var SwitchPrimitive = __toESM(require("@radix-ui/react-switch"), 1);
1292
1292
  var import_jsx_runtime14 = require("react/jsx-runtime");
@@ -1352,7 +1352,7 @@ var PointsSwitch = (props) => {
1352
1352
  )
1353
1353
  ] })
1354
1354
  ] }),
1355
- message && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-1 rounded-sm border-1 border-[#006FD533] bg-[#006FD50D] p-1.5", children: [
1355
+ message && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex gap-1 rounded-sm border-1 border-[#006FD533] bg-[#006FD50D] p-1.5", children: [
1356
1356
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("svg", { className: "size-5 shrink-0", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1357
1357
  "path",
1358
1358
  {
@@ -2378,6 +2378,8 @@ var PointsSelector = (props) => {
2378
2378
  const handleCommit = (value) => {
2379
2379
  setSelectedPaymentMethod({ ...selectedPaymentMethod, splitAmount: value });
2380
2380
  };
2381
+ const pointsValue = String(Math.round(splitTokens));
2382
+ const usdValue = formatUSD(usdAmount + getTransactionFee(usdAmount, appProps.transactionFeePercentage));
2381
2383
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
2382
2384
  "button",
2383
2385
  {
@@ -2401,14 +2403,15 @@ var PointsSelector = (props) => {
2401
2403
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "flex h-full w-full items-center justify-between gap-2 px-2 sm:gap-3 sm:px-3", children })
2402
2404
  ] }),
2403
2405
  isSelected && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "px-2 pt-6 pb-2 sm:px-3 md:px-4", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex justify-between gap-2 sm:gap-3", children: [
2404
- /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex max-w-[100px] flex-col gap-1", children: [
2406
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex flex-col gap-1", children: [
2405
2407
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2406
2408
  Input,
2407
2409
  {
2408
2410
  readOnly: true,
2409
2411
  name: "points amount",
2410
- value: Math.round(splitTokens),
2411
- className: "sm:text-md min-w-[80px] bg-white px-1 text-center text-xs font-medium sm:px-3",
2412
+ value: pointsValue,
2413
+ className: "sm:text-md min-w-[50px] bg-white px-1 text-center text-xs font-medium sm:min-w-[100px] sm:px-2",
2414
+ style: { width: `${pointsValue.length}ch` },
2412
2415
  onClick: (e) => e.stopPropagation()
2413
2416
  }
2414
2417
  ),
@@ -2426,14 +2429,15 @@ var PointsSelector = (props) => {
2426
2429
  step
2427
2430
  }
2428
2431
  ) }),
2429
- /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex max-w-[100px] flex-col gap-1", children: [
2432
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex flex-col gap-1", children: [
2430
2433
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2431
2434
  Input,
2432
2435
  {
2433
2436
  readOnly: true,
2434
2437
  name: "usd amount",
2435
- value: formatUSD(usdAmount + getTransactionFee(usdAmount, appProps.transactionFeePercentage)),
2436
- className: "sm:text-md min-w-[80px] bg-white px-1 text-center text-xs font-medium sm:px-3",
2438
+ value: usdValue,
2439
+ className: "sm:text-md min-w-[50px] bg-white px-1 text-center text-xs font-medium sm:min-w-[100px] sm:px-2",
2440
+ style: { width: `${usdValue.length}ch` },
2437
2441
  onClick: (e) => e.stopPropagation()
2438
2442
  }
2439
2443
  ),
@@ -2537,6 +2541,7 @@ var CreditCardTab = () => {
2537
2541
  const { spreePayConfig } = useSpreePayConfig();
2538
2542
  const { register } = useSpreePayRegister();
2539
2543
  const { mutateCards } = useCards();
2544
+ const { mutateBalance } = useSlapiBalance();
2540
2545
  const { cardPayment } = useCardPayment();
2541
2546
  const { splitPayment } = useSplitCardPayments();
2542
2547
  const { pointsPayment } = usePointsPayment();
@@ -2562,6 +2567,7 @@ var CreditCardTab = () => {
2562
2567
  } finally {
2563
2568
  setSelectedPaymentMethod({ ...selectedPaymentMethod, type: "CREDIT_CARD" /* CREDIT_CARD */, method: null });
2564
2569
  mutateCards();
2570
+ mutateBalance();
2565
2571
  }
2566
2572
  },
2567
2573
  [
@@ -2572,7 +2578,8 @@ var CreditCardTab = () => {
2572
2578
  setSelectedPaymentMethod,
2573
2579
  cardPayment,
2574
2580
  splitPayment,
2575
- spreePayConfig
2581
+ spreePayConfig,
2582
+ mutateBalance
2576
2583
  ]
2577
2584
  );
2578
2585
  (0, import_react13.useEffect)(() => {
package/build/index.css CHANGED
@@ -449,9 +449,6 @@
449
449
  .sl-spreepay .w-full {
450
450
  width: 100%;
451
451
  }
452
- .sl-spreepay .max-w-\[100px\] {
453
- max-width: 100px;
454
- }
455
452
  .sl-spreepay .max-w-\[540px\] {
456
453
  max-width: 540px;
457
454
  }
@@ -464,8 +461,8 @@
464
461
  .sl-spreepay .min-w-0 {
465
462
  min-width: calc(var(--spacing) * 0);
466
463
  }
467
- .sl-spreepay .min-w-\[80px\] {
468
- min-width: 80px;
464
+ .sl-spreepay .min-w-\[50px\] {
465
+ min-width: 50px;
469
466
  }
470
467
  .sl-spreepay .flex-1 {
471
468
  flex: 1;
@@ -1466,6 +1463,11 @@
1466
1463
  max-width: var(--container-lg);
1467
1464
  }
1468
1465
  }
1466
+ .sl-spreepay .sm\:min-w-\[100px\] {
1467
+ @media (width >= 40rem) {
1468
+ min-width: 100px;
1469
+ }
1470
+ }
1469
1471
  .sl-spreepay .sm\:flex-row {
1470
1472
  @media (width >= 40rem) {
1471
1473
  flex-direction: row;
@@ -1486,6 +1488,11 @@
1486
1488
  gap: calc(var(--spacing) * 3);
1487
1489
  }
1488
1490
  }
1491
+ .sl-spreepay .sm\:px-2 {
1492
+ @media (width >= 40rem) {
1493
+ padding-inline: calc(var(--spacing) * 2);
1494
+ }
1495
+ }
1489
1496
  .sl-spreepay .sm\:px-3 {
1490
1497
  @media (width >= 40rem) {
1491
1498
  padding-inline: calc(var(--spacing) * 3);
package/build/index.js CHANGED
@@ -4,7 +4,7 @@ import NiceModal7 from "@ebay/nice-modal-react";
4
4
  import { SWRConfig } from "swr";
5
5
 
6
6
  // package.json
7
- var version = "0.1.29";
7
+ var version = "0.1.31";
8
8
 
9
9
  // src/context/SpreePayActionsContext.tsx
10
10
  import { createContext, useCallback, useContext, useRef, useState } from "react";
@@ -332,9 +332,9 @@ var CheckoutButton = ({ isLoggedIn }) => {
332
332
  ) }) : /* @__PURE__ */ jsx4(
333
333
  "a",
334
334
  {
335
- href: `${staticConfig.keycloakUrl}/realms/${env.tenantId}/protocol/openid-connect/logout?client_id=${staticConfig.keycloakClientId}&post_logout_redirect_uri=${window.location.origin}${window.location.pathname}`,
335
+ href: `${staticConfig.keycloakUrl}/realms/${env.tenantId}/protocol/openid-connect/auth?client_id=${staticConfig.keycloakClientId}&response_type=code&redirect_uri=${window.location.href}`,
336
336
  className: "bg-primary h-[60px] w-full cursor-pointer text-center text-xl leading-[60px] font-semibold text-white disabled:cursor-not-allowed disabled:opacity-50",
337
- children: "Login"
337
+ children: "Log in / Sign up for an AIR account"
338
338
  }
339
339
  )
340
340
  ] });
@@ -921,6 +921,13 @@ var useCards = () => {
921
921
  };
922
922
  };
923
923
 
924
+ // src/hooks/useSlapiBalance.ts
925
+ import useSWR3 from "swr";
926
+ var useSlapiBalance = () => {
927
+ const { data, isLoading, mutate } = useSWR3(`/v1/loyalty/accounts`);
928
+ return { balance: data?.detail, isBalanceLoading: isLoading, mutateBalance: mutate };
929
+ };
930
+
924
931
  // src/components/CreditCardTab/CreditCard/CreditCard.tsx
925
932
  import { useMemo as useMemo2, useState as useState4 } from "react";
926
933
  import { Elements } from "@stripe/react-stripe-js";
@@ -1240,13 +1247,6 @@ import { useState as useState10 } from "react";
1240
1247
  // src/components/common/PointsSwitch.tsx
1241
1248
  import { useId as useId2 } from "react";
1242
1249
 
1243
- // src/hooks/useSlapiBalance.ts
1244
- import useSWR3 from "swr";
1245
- var useSlapiBalance = () => {
1246
- const { data, isLoading, mutate } = useSWR3(`/v1/loyalty/accounts`);
1247
- return { balance: data?.detail, isBalanceLoading: isLoading, mutateBalance: mutate };
1248
- };
1249
-
1250
1250
  // src/ui/switch.tsx
1251
1251
  import * as SwitchPrimitive from "@radix-ui/react-switch";
1252
1252
  import { jsx as jsx14 } from "react/jsx-runtime";
@@ -1312,7 +1312,7 @@ var PointsSwitch = (props) => {
1312
1312
  )
1313
1313
  ] })
1314
1314
  ] }),
1315
- message && /* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-1 rounded-sm border-1 border-[#006FD533] bg-[#006FD50D] p-1.5", children: [
1315
+ message && /* @__PURE__ */ jsxs9("div", { className: "flex gap-1 rounded-sm border-1 border-[#006FD533] bg-[#006FD50D] p-1.5", children: [
1316
1316
  /* @__PURE__ */ jsx15("svg", { className: "size-5 shrink-0", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsx15(
1317
1317
  "path",
1318
1318
  {
@@ -2338,6 +2338,8 @@ var PointsSelector = (props) => {
2338
2338
  const handleCommit = (value) => {
2339
2339
  setSelectedPaymentMethod({ ...selectedPaymentMethod, splitAmount: value });
2340
2340
  };
2341
+ const pointsValue = String(Math.round(splitTokens));
2342
+ const usdValue = formatUSD(usdAmount + getTransactionFee(usdAmount, appProps.transactionFeePercentage));
2341
2343
  return /* @__PURE__ */ jsxs12(
2342
2344
  "button",
2343
2345
  {
@@ -2361,14 +2363,15 @@ var PointsSelector = (props) => {
2361
2363
  /* @__PURE__ */ jsx24("div", { className: "flex h-full w-full items-center justify-between gap-2 px-2 sm:gap-3 sm:px-3", children })
2362
2364
  ] }),
2363
2365
  isSelected && /* @__PURE__ */ jsx24("div", { className: "px-2 pt-6 pb-2 sm:px-3 md:px-4", children: /* @__PURE__ */ jsxs12("div", { className: "flex justify-between gap-2 sm:gap-3", children: [
2364
- /* @__PURE__ */ jsxs12("div", { className: "flex max-w-[100px] flex-col gap-1", children: [
2366
+ /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-1", children: [
2365
2367
  /* @__PURE__ */ jsx24(
2366
2368
  Input,
2367
2369
  {
2368
2370
  readOnly: true,
2369
2371
  name: "points amount",
2370
- value: Math.round(splitTokens),
2371
- className: "sm:text-md min-w-[80px] bg-white px-1 text-center text-xs font-medium sm:px-3",
2372
+ value: pointsValue,
2373
+ className: "sm:text-md min-w-[50px] bg-white px-1 text-center text-xs font-medium sm:min-w-[100px] sm:px-2",
2374
+ style: { width: `${pointsValue.length}ch` },
2372
2375
  onClick: (e) => e.stopPropagation()
2373
2376
  }
2374
2377
  ),
@@ -2386,14 +2389,15 @@ var PointsSelector = (props) => {
2386
2389
  step
2387
2390
  }
2388
2391
  ) }),
2389
- /* @__PURE__ */ jsxs12("div", { className: "flex max-w-[100px] flex-col gap-1", children: [
2392
+ /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-1", children: [
2390
2393
  /* @__PURE__ */ jsx24(
2391
2394
  Input,
2392
2395
  {
2393
2396
  readOnly: true,
2394
2397
  name: "usd amount",
2395
- value: formatUSD(usdAmount + getTransactionFee(usdAmount, appProps.transactionFeePercentage)),
2396
- className: "sm:text-md min-w-[80px] bg-white px-1 text-center text-xs font-medium sm:px-3",
2398
+ value: usdValue,
2399
+ className: "sm:text-md min-w-[50px] bg-white px-1 text-center text-xs font-medium sm:min-w-[100px] sm:px-2",
2400
+ style: { width: `${usdValue.length}ch` },
2397
2401
  onClick: (e) => e.stopPropagation()
2398
2402
  }
2399
2403
  ),
@@ -2497,6 +2501,7 @@ var CreditCardTab = () => {
2497
2501
  const { spreePayConfig } = useSpreePayConfig();
2498
2502
  const { register } = useSpreePayRegister();
2499
2503
  const { mutateCards } = useCards();
2504
+ const { mutateBalance } = useSlapiBalance();
2500
2505
  const { cardPayment } = useCardPayment();
2501
2506
  const { splitPayment } = useSplitCardPayments();
2502
2507
  const { pointsPayment } = usePointsPayment();
@@ -2522,6 +2527,7 @@ var CreditCardTab = () => {
2522
2527
  } finally {
2523
2528
  setSelectedPaymentMethod({ ...selectedPaymentMethod, type: "CREDIT_CARD" /* CREDIT_CARD */, method: null });
2524
2529
  mutateCards();
2530
+ mutateBalance();
2525
2531
  }
2526
2532
  },
2527
2533
  [
@@ -2532,7 +2538,8 @@ var CreditCardTab = () => {
2532
2538
  setSelectedPaymentMethod,
2533
2539
  cardPayment,
2534
2540
  splitPayment,
2535
- spreePayConfig
2541
+ spreePayConfig,
2542
+ mutateBalance
2536
2543
  ]
2537
2544
  );
2538
2545
  useEffect7(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superlogic/spree-pay",
3
- "version": "0.1.29",
3
+ "version": "0.1.31",
4
4
  "description": "Spree-pay React component and utilities",
5
5
  "private": false,
6
6
  "type": "module",