@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 CHANGED
@@ -1786,30 +1786,14 @@ function ChatModal({
1786
1786
  } : void 0;
1787
1787
  const handlePhoneSubmit = async () => {
1788
1788
  if (!phoneInput.trim()) return;
1789
- try {
1790
- if (typeof window !== "undefined") {
1791
- localStorage.setItem("akropolys_user_phone", phoneInput.trim());
1792
- }
1793
- const isHistoryIntent = lastIntent === "capture" || lastIntent === "delete" || lastIntent === "view_history";
1794
- if (isHistoryIntent) {
1795
- const { phone, word } = parseMemoryKey(phoneInput);
1796
- if (!phone) return;
1797
- client.setShopperIdentity(phone, word);
1798
- setMemoryKey(phone + word);
1799
- setPaymentPhase("idle");
1800
- const lastUserMsg = [...messages].reverse().find((m) => m.role === "user");
1801
- if (lastUserMsg) {
1802
- await send(lastUserMsg.content);
1803
- }
1804
- return;
1805
- }
1806
- const res = await client.api.initiatePayment(phoneInput.trim());
1807
- setMerchantRef(res.merchantReference);
1808
- setPaymentPhase("awaiting");
1809
- } catch (e) {
1810
- console.error("[Akropolys] initiatePayment error", e);
1811
- setPaymentPhase("failed");
1812
- }
1789
+ const { phone, word } = parseMemoryKey(phoneInput);
1790
+ if (!phone) return;
1791
+ if (typeof window !== "undefined") localStorage.setItem("akropolys_user_phone", phone);
1792
+ client.setShopperIdentity(phone, word);
1793
+ setMemoryKey(phone + word);
1794
+ setPaymentPhase("idle");
1795
+ const lastUserMsg = [...messages].reverse().find((m) => m.role === "user");
1796
+ if (lastUserMsg) await send(lastUserMsg.content);
1813
1797
  };
1814
1798
  const msgsContainerRef = (0, import_react5.useRef)(null);
1815
1799
  (0, import_react5.useEffect)(() => {
@@ -2098,49 +2082,25 @@ function ChatModal({
2098
2082
  ] })
2099
2083
  ] }),
2100
2084
  error && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-error", children: getFriendlyError(error) }),
2101
- !replayMessages && paymentPhase === "prompt_phone" && (() => {
2102
- const isHistoryIntent = lastIntent === "capture" || lastIntent === "delete" || lastIntent === "view_history";
2103
- if (isHistoryIntent) {
2104
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hsk-cb-ai-msg", children: [
2105
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-ai-icon", style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SparkleIcon2, {}) }),
2106
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-ai-body", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-ai-text", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hsk-cb-phone-form", children: [
2107
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("label", { className: "hsk-cb-phone-label", children: "Your phone number \u2014 or paste your memory key" }),
2108
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2109
- "input",
2110
- {
2111
- type: "text",
2112
- className: "hsk-cb-phone-input",
2113
- placeholder: "0712345678 or 0712345678flyingthunder",
2114
- value: phoneInput,
2115
- onChange: (e) => setPhoneInput(e.target.value.replace(/[^0-9a-zA-Z]/g, "")),
2116
- onKeyDown: (e) => e.key === "Enter" && handlePhoneSubmit(),
2117
- autoFocus: true
2118
- }
2119
- ),
2120
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { className: "hsk-cb-phone-submit", onClick: handlePhoneSubmit, children: "Save & sync my items" })
2121
- ] }) }) })
2122
- ] });
2123
- }
2124
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hsk-cb-ai-msg", children: [
2125
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-ai-icon", style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SparkleIcon2, {}) }),
2126
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-ai-body", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-ai-text", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hsk-cb-phone-form", children: [
2127
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("label", { className: "hsk-cb-phone-label", children: "Enter your M-Pesa number to pay" }),
2128
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2129
- "input",
2130
- {
2131
- type: "tel",
2132
- className: "hsk-cb-phone-input",
2133
- placeholder: "0712 345 678",
2134
- value: phoneInput,
2135
- onChange: (e) => setPhoneInput(e.target.value.replace(/\D/g, "")),
2136
- onKeyDown: (e) => e.key === "Enter" && handlePhoneSubmit(),
2137
- autoFocus: true
2138
- }
2139
- ),
2140
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { className: "hsk-cb-phone-submit", onClick: handlePhoneSubmit, children: "Send STK push" })
2141
- ] }) }) })
2142
- ] });
2143
- })(),
2085
+ !replayMessages && paymentPhase === "prompt_phone" && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hsk-cb-ai-msg", children: [
2086
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-ai-icon", style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SparkleIcon2, {}) }),
2087
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-ai-body", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-ai-text", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hsk-cb-phone-form", children: [
2088
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("label", { className: "hsk-cb-phone-label", children: "Your phone number \u2014 or paste your memory key" }),
2089
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2090
+ "input",
2091
+ {
2092
+ type: "text",
2093
+ className: "hsk-cb-phone-input",
2094
+ placeholder: "0712345678 or 0712345678flyingthunder",
2095
+ value: phoneInput,
2096
+ onChange: (e) => setPhoneInput(e.target.value.replace(/[^0-9a-zA-Z]/g, "")),
2097
+ onKeyDown: (e) => e.key === "Enter" && handlePhoneSubmit(),
2098
+ autoFocus: true
2099
+ }
2100
+ ),
2101
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { className: "hsk-cb-phone-submit", onClick: handlePhoneSubmit, children: "Save & sync my items" })
2102
+ ] }) }) })
2103
+ ] }),
2144
2104
  !replayMessages && memoryKey && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hsk-cb-ai-msg", children: [
2145
2105
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-ai-icon", style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SparkleIcon2, {}) }),
2146
2106
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-ai-body", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-ai-text", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { padding: "10px 12px", border: "1px solid var(--hsk-border, #e5e5e5)", borderRadius: 8 }, children: [