@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.mjs CHANGED
@@ -1751,30 +1751,14 @@ function ChatModal({
1751
1751
  } : void 0;
1752
1752
  const handlePhoneSubmit = async () => {
1753
1753
  if (!phoneInput.trim()) return;
1754
- try {
1755
- if (typeof window !== "undefined") {
1756
- localStorage.setItem("akropolys_user_phone", phoneInput.trim());
1757
- }
1758
- const isHistoryIntent = lastIntent === "capture" || lastIntent === "delete" || lastIntent === "view_history";
1759
- if (isHistoryIntent) {
1760
- const { phone, word } = parseMemoryKey(phoneInput);
1761
- if (!phone) return;
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
- const isHistoryIntent = lastIntent === "capture" || lastIntent === "delete" || lastIntent === "view_history";
2068
- if (isHistoryIntent) {
2069
- return /* @__PURE__ */ jsxs6("div", { className: "hsk-cb-ai-msg", children: [
2070
- /* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-icon", style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ jsx7(SparkleIcon2, {}) }),
2071
- /* @__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: [
2072
- /* @__PURE__ */ jsx7("label", { className: "hsk-cb-phone-label", children: "Your phone number \u2014 or paste your memory key" }),
2073
- /* @__PURE__ */ jsx7(
2074
- "input",
2075
- {
2076
- type: "text",
2077
- className: "hsk-cb-phone-input",
2078
- placeholder: "0712345678 or 0712345678flyingthunder",
2079
- value: phoneInput,
2080
- onChange: (e) => setPhoneInput(e.target.value.replace(/[^0-9a-zA-Z]/g, "")),
2081
- onKeyDown: (e) => e.key === "Enter" && handlePhoneSubmit(),
2082
- autoFocus: true
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: [