@akropolys/kiku 1.5.17 → 1.5.18
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.js +27 -67
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -67
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1751,30 +1751,14 @@ function ChatModal({
|
|
|
1751
1751
|
} : void 0;
|
|
1752
1752
|
const handlePhoneSubmit = async () => {
|
|
1753
1753
|
if (!phoneInput.trim()) return;
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
client.setShopperIdentity(phone, word);
|
|
1763
|
-
setMemoryKey(phone + word);
|
|
1764
|
-
setPaymentPhase("idle");
|
|
1765
|
-
const lastUserMsg = [...messages].reverse().find((m) => m.role === "user");
|
|
1766
|
-
if (lastUserMsg) {
|
|
1767
|
-
await send(lastUserMsg.content);
|
|
1768
|
-
}
|
|
1769
|
-
return;
|
|
1770
|
-
}
|
|
1771
|
-
const res = await client.api.initiatePayment(phoneInput.trim());
|
|
1772
|
-
setMerchantRef(res.merchantReference);
|
|
1773
|
-
setPaymentPhase("awaiting");
|
|
1774
|
-
} catch (e) {
|
|
1775
|
-
console.error("[Akropolys] initiatePayment error", e);
|
|
1776
|
-
setPaymentPhase("failed");
|
|
1777
|
-
}
|
|
1754
|
+
const { phone, word } = parseMemoryKey(phoneInput);
|
|
1755
|
+
if (!phone) return;
|
|
1756
|
+
if (typeof window !== "undefined") localStorage.setItem("akropolys_user_phone", phone);
|
|
1757
|
+
client.setShopperIdentity(phone, word);
|
|
1758
|
+
setMemoryKey(phone + word);
|
|
1759
|
+
setPaymentPhase("idle");
|
|
1760
|
+
const lastUserMsg = [...messages].reverse().find((m) => m.role === "user");
|
|
1761
|
+
if (lastUserMsg) await send(lastUserMsg.content);
|
|
1778
1762
|
};
|
|
1779
1763
|
const msgsContainerRef = useRef5(null);
|
|
1780
1764
|
useEffect3(() => {
|
|
@@ -2063,49 +2047,25 @@ function ChatModal({
|
|
|
2063
2047
|
] })
|
|
2064
2048
|
] }),
|
|
2065
2049
|
error && /* @__PURE__ */ jsx7("div", { className: "hsk-cb-error", children: getFriendlyError(error) }),
|
|
2066
|
-
!replayMessages && paymentPhase === "prompt_phone" && (
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
/* @__PURE__ */ jsx7("button", { className: "hsk-cb-phone-submit", onClick: handlePhoneSubmit, children: "Save & sync my items" })
|
|
2086
|
-
] }) }) })
|
|
2087
|
-
] });
|
|
2088
|
-
}
|
|
2089
|
-
return /* @__PURE__ */ jsxs6("div", { className: "hsk-cb-ai-msg", children: [
|
|
2090
|
-
/* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-icon", style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ jsx7(SparkleIcon2, {}) }),
|
|
2091
|
-
/* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-body", children: /* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-text", children: /* @__PURE__ */ jsxs6("div", { className: "hsk-cb-phone-form", children: [
|
|
2092
|
-
/* @__PURE__ */ jsx7("label", { className: "hsk-cb-phone-label", children: "Enter your M-Pesa number to pay" }),
|
|
2093
|
-
/* @__PURE__ */ jsx7(
|
|
2094
|
-
"input",
|
|
2095
|
-
{
|
|
2096
|
-
type: "tel",
|
|
2097
|
-
className: "hsk-cb-phone-input",
|
|
2098
|
-
placeholder: "0712 345 678",
|
|
2099
|
-
value: phoneInput,
|
|
2100
|
-
onChange: (e) => setPhoneInput(e.target.value.replace(/\D/g, "")),
|
|
2101
|
-
onKeyDown: (e) => e.key === "Enter" && handlePhoneSubmit(),
|
|
2102
|
-
autoFocus: true
|
|
2103
|
-
}
|
|
2104
|
-
),
|
|
2105
|
-
/* @__PURE__ */ jsx7("button", { className: "hsk-cb-phone-submit", onClick: handlePhoneSubmit, children: "Send STK push" })
|
|
2106
|
-
] }) }) })
|
|
2107
|
-
] });
|
|
2108
|
-
})(),
|
|
2050
|
+
!replayMessages && paymentPhase === "prompt_phone" && /* @__PURE__ */ jsxs6("div", { className: "hsk-cb-ai-msg", children: [
|
|
2051
|
+
/* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-icon", style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ jsx7(SparkleIcon2, {}) }),
|
|
2052
|
+
/* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-body", children: /* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-text", children: /* @__PURE__ */ jsxs6("div", { className: "hsk-cb-phone-form", children: [
|
|
2053
|
+
/* @__PURE__ */ jsx7("label", { className: "hsk-cb-phone-label", children: "Your phone number \u2014 or paste your memory key" }),
|
|
2054
|
+
/* @__PURE__ */ jsx7(
|
|
2055
|
+
"input",
|
|
2056
|
+
{
|
|
2057
|
+
type: "text",
|
|
2058
|
+
className: "hsk-cb-phone-input",
|
|
2059
|
+
placeholder: "0712345678 or 0712345678flyingthunder",
|
|
2060
|
+
value: phoneInput,
|
|
2061
|
+
onChange: (e) => setPhoneInput(e.target.value.replace(/[^0-9a-zA-Z]/g, "")),
|
|
2062
|
+
onKeyDown: (e) => e.key === "Enter" && handlePhoneSubmit(),
|
|
2063
|
+
autoFocus: true
|
|
2064
|
+
}
|
|
2065
|
+
),
|
|
2066
|
+
/* @__PURE__ */ jsx7("button", { className: "hsk-cb-phone-submit", onClick: handlePhoneSubmit, children: "Save & sync my items" })
|
|
2067
|
+
] }) }) })
|
|
2068
|
+
] }),
|
|
2109
2069
|
!replayMessages && memoryKey && /* @__PURE__ */ jsxs6("div", { className: "hsk-cb-ai-msg", children: [
|
|
2110
2070
|
/* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-icon", style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ jsx7(SparkleIcon2, {}) }),
|
|
2111
2071
|
/* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-body", children: /* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-text", children: /* @__PURE__ */ jsxs6("div", { style: { padding: "10px 12px", border: "1px solid var(--hsk-border, #e5e5e5)", borderRadius: 8 }, children: [
|