@leatcom/portal-sessions 0.0.43 → 0.0.45

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/README.md CHANGED
@@ -27,8 +27,9 @@ Currently, there are five Portal Session types:
27
27
  * `PORTAL`: This is the 'default' session type, which doesn't have a predefined aim, but rather allows for flexible use. See this as a way for customers to login to their own portal.
28
28
  * `REDEEM_GIFTCARD`: A session to use and redeem gift card(s). Best used as payment option.
29
29
  * `TOP_UP_GIFTCARD`: A session to sell and/or top up existing gift cards.
30
- * `PREPAID`: A session to handle prepaid transactions.
31
- * `SAVE`: A session to handle an order and a subsequent credit reception.
30
+ * `PAY_PREPAID`: A session to handle prepaid transactions.
31
+ * `TOP_UP_PREPAID`: A session to top up prepaid balance.
32
+ * `POINTS_TRANSACTION`: A session to handle an order and a subsequent credit reception.
32
33
  * `VOUCHER`: A session to redeem vouchers.
33
34
 
34
35
  Initiate a new Portal Session as follows:
@@ -37,7 +38,38 @@ Initiate a new Portal Session as follows:
37
38
  apiKey={apiKey}
38
39
  shopUuid={shopUuid}
39
40
  type="PORTAL"
40
- scannerType="camera"
41
41
  onRedeemVoucher={(voucher) => handleVoucherLogic(voucher)}
42
42
  />
43
43
  ```
44
+
45
+ ## Portal Session Props
46
+
47
+ | Prop | Type | Required | Description |
48
+ |-----------------------------|--------------------------------------------------------------|----------|------------------------------------------------------------------------------------------------------------|
49
+ | `apiKey` | `string` | Yes | API key used to authenticate. |
50
+ | `shopUuid` | `string` | Yes | The shop's uuid. |
51
+ | `contactUuid` | `string` | No | Optional contact uuid. This opens the portal session for this contact specifically. |
52
+ | `type` | `PortalType` | No | Optional portal type, defaults to `"PORTAL"`. |
53
+ | `enableEmailIdentification` | `boolean` | No | Optional alternative route to identify a contact. |
54
+ | `enableOnScreenKeyboard` | `boolean` | No | Optional on-screen keyboard. |
55
+ | `allowMultipleGiftcards` | `boolean` | No | Allow using multiple giftcards in one session. Applies to sessions with `PortalType` `"REDEEM_GIFTCARD"`. |
56
+ | `amountInCents` | `number` | No | A purchase amount in cents. Applies to sessions with `PortalType` `"REDEEM_GIFTCARD"` and `"PAY_PREPAID"`. |
57
+ | `onContactLink` | `(contact: ContactResource) => void` | No | Optional callback. Called when a contact is linked to the portal session. |
58
+ | `onClaimReward` | `(reward: RewardResource, transactionUuid?: string) => void` | No | Optional callback. Called when a reward is claimed. |
59
+ | `onRedeemVoucher` | `(voucher: VoucherResource) => void` | No | Optional callback. Called when a voucher is redeemed. |
60
+ | `onUseGiftcard` | `(giftcardTransaction: GiftcardTransactionResource) => void` | No | Optional callback. Called when a giftcard payment is made. |
61
+
62
+ ## Types
63
+
64
+ `PortalType`
65
+ ```javascript
66
+ export enum PortalType {
67
+ REDEEM_GIFTCARD = "REDEEM_GIFTCARD",
68
+ TOP_UP_GIFTCARD = "TOP_UP_GIFTCARD",
69
+ PORTAL = "PORTAL",
70
+ PAY_PREPAID = "PAY_PREPAID",
71
+ TOP_UP_PREPAID = "TOP_UP_PREPAID",
72
+ POINTS_TRANSACTION = "POINTS_TRANSACTION",
73
+ VOUCHER = "VOUCHER",
74
+ }
75
+ ```
@@ -10721,7 +10721,7 @@ function ns({ state: e }) {
10721
10721
  }, [e, i, m, f, n]);
10722
10722
  return Pe(() => {
10723
10723
  i && !a && !h && E();
10724
- }, [i, a, h, E]), /* @__PURE__ */ u.jsxs(Tt, { children: [
10724
+ }, [i]), /* @__PURE__ */ u.jsxs(Tt, { children: [
10725
10725
  /* @__PURE__ */ u.jsx(Ct, { children: /* @__PURE__ */ u.jsx("div", { className: "flex h-16 items-center", children: /* @__PURE__ */ u.jsx("p", { children: n("scanOrEnterX", { x: "identifier" }) }) }) }),
10726
10726
  /* @__PURE__ */ u.jsx(Et, { children: /* @__PURE__ */ u.jsx(rs, { dataSetter: s, setDefer: v, label: n("contactIdentifier") }) }),
10727
10727
  /* @__PURE__ */ u.jsx(Bt, { children: /* @__PURE__ */ u.jsxs("div", { className: "flex flex-col gap-2", children: [
@@ -16577,12 +16577,8 @@ function Ix({ contact: e }) {
16577
16577
  /* @__PURE__ */ u.jsx(rc, { src: e.current_display_values.avatar, size: "2xl" }),
16578
16578
  /* @__PURE__ */ u.jsxs("div", { className: "flex flex-col gap-1", children: [
16579
16579
  /* @__PURE__ */ u.jsxs("div", { className: "flex gap-2", children: [
16580
- /* @__PURE__ */ u.jsxs("p", { className: "text-lg", children: [
16581
- e.current_display_values.firstname,
16582
- " ",
16583
- e.current_display_values.lastname
16584
- ] }),
16585
- /* @__PURE__ */ u.jsx(ic, { label: e.current_display_values.tier, size: "sm", stroke: !0 })
16580
+ /* @__PURE__ */ u.jsx("p", { className: "text-lg", children: e.current_display_values.firstname || e.current_display_values.lastname ? `${e.current_display_values.firstname} ${e.current_display_values.lastname}` : e.current_display_values.email }),
16581
+ e.current_display_values.tier && /* @__PURE__ */ u.jsx(ic, { label: e.current_display_values.tier, size: "sm", stroke: !0 })
16586
16582
  ] }),
16587
16583
  /* @__PURE__ */ u.jsxs("p", { className: "text-sm text-core-gray-500 ", children: [
16588
16584
  n("joined"),
@@ -16917,7 +16913,7 @@ function _x() {
16917
16913
  disabled: v.disabled,
16918
16914
  label: v.label,
16919
16915
  name: v.name,
16920
- value: a && a[v.name] ? a[v.name] : t.current_display_values[v.name],
16916
+ value: a && a[v.name] !== "undefined" ? a[v.name] : t.current_display_values[v.name],
16921
16917
  onChange: f
16922
16918
  },
16923
16919
  v.id
@@ -17126,7 +17122,7 @@ function Vx() {
17126
17122
  ] })
17127
17123
  ] }) }),
17128
17124
  /* @__PURE__ */ u.jsx(Et, { children: n || v ? /* @__PURE__ */ u.jsx(fs, { rows: 1 }) : /* @__PURE__ */ u.jsxs("div", { className: "flex flex-col gap-1 md:max-h-[528px]", children: [
17129
- /* @__PURE__ */ u.jsx("p", { className: "text-sm font-light text-core-gray-500", children: e("redeemableRewards") }),
17125
+ !!t.filter((y) => y.required_credits <= h.credit_balance.balance).length && /* @__PURE__ */ u.jsx("p", { className: "text-sm font-light text-core-gray-500", children: e("redeemableRewards") }),
17130
17126
  t.filter((y) => y.required_credits <= h.credit_balance.balance).map((y) => /* @__PURE__ */ u.jsx(
17131
17127
  Qs,
17132
17128
  {
@@ -17151,7 +17147,7 @@ function Vx() {
17151
17147
  !!p().length && !n && /* @__PURE__ */ u.jsx(Bt, { children: /* @__PURE__ */ u.jsx("div", { children: /* @__PURE__ */ u.jsx(dh, { children: p().map((y, x) => /* @__PURE__ */ u.jsxs(
17152
17148
  "div",
17153
17149
  {
17154
- className: " flex items-center justify-between rounded-lg border border-core-primary-100 bg-core-primary-50 p-2 text-xs",
17150
+ className: "flex items-center justify-between rounded-lg border border-core-primary-100 bg-core-primary-50 p-2 text-xs",
17155
17151
  children: [
17156
17152
  /* @__PURE__ */ u.jsxs("div", { className: "mr-4 flex items-center gap-4 overflow-hidden", children: [
17157
17153
  /* @__PURE__ */ u.jsx(
@@ -17712,7 +17708,7 @@ function s2() {
17712
17708
  const a = r.type in Wt ? `/${r.type.replaceAll("_", "-").toLowerCase()}` : "/";
17713
17709
  e(a);
17714
17710
  }
17715
- }, [i, s, e, r]), i ? /* @__PURE__ */ u.jsx("div", { className: "flex h-screen items-center justify-center text-core-gray-500", children: /* @__PURE__ */ u.jsx(Br, { className: "h-[48px] w-[48px]" }) }) : /* @__PURE__ */ u.jsx("div", { className: "text-error-600 flex w-full items-center justify-center", children: `${t(
17711
+ }, [i, s, e, r]), i ? /* @__PURE__ */ u.jsx("div", { className: "flex h-screen w-screen items-center justify-center text-core-primary-500", children: /* @__PURE__ */ u.jsx(Br, { className: "h-[48px] w-[48px]" }) }) : /* @__PURE__ */ u.jsx("div", { className: "text-error-600 flex w-full items-center justify-center", children: `${t(
17716
17712
  "portalSessionNotFound"
17717
17713
  )} (${n})` });
17718
17714
  }