@swype-org/react-sdk 0.1.13 → 0.1.14
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.cjs +59 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +59 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2065,7 +2065,7 @@ function SwypePayment({
|
|
|
2065
2065
|
useWalletConnector
|
|
2066
2066
|
}) {
|
|
2067
2067
|
const { apiBaseUrl, tokens, depositAmount } = useSwypeConfig();
|
|
2068
|
-
const { ready, authenticated, login, getAccessToken } = reactAuth.usePrivy();
|
|
2068
|
+
const { ready, authenticated, login, logout, getAccessToken } = reactAuth.usePrivy();
|
|
2069
2069
|
const [step, setStep] = react.useState("login");
|
|
2070
2070
|
const [error, setError] = react.useState(null);
|
|
2071
2071
|
const [providers, setProviders] = react.useState([]);
|
|
@@ -2416,6 +2416,38 @@ function SwypePayment({
|
|
|
2416
2416
|
setAdvancedSettings({ asset: null, chain: null });
|
|
2417
2417
|
if (accounts.length > 0) setSelectedAccountId(accounts[0].id);
|
|
2418
2418
|
};
|
|
2419
|
+
const handleLogout = react.useCallback(async () => {
|
|
2420
|
+
try {
|
|
2421
|
+
await logout();
|
|
2422
|
+
} catch {
|
|
2423
|
+
}
|
|
2424
|
+
if (typeof window !== "undefined") {
|
|
2425
|
+
window.localStorage.removeItem(ACTIVE_CREDENTIAL_STORAGE_KEY);
|
|
2426
|
+
}
|
|
2427
|
+
polling.stopPolling();
|
|
2428
|
+
setActiveCredentialId(null);
|
|
2429
|
+
setStep("login");
|
|
2430
|
+
setError(null);
|
|
2431
|
+
setTransfer(null);
|
|
2432
|
+
setCreatingTransfer(false);
|
|
2433
|
+
setRegisteringPasskey(false);
|
|
2434
|
+
setProviders([]);
|
|
2435
|
+
setAccounts([]);
|
|
2436
|
+
setChains([]);
|
|
2437
|
+
setSelectedAccountId(null);
|
|
2438
|
+
setSelectedWalletId(null);
|
|
2439
|
+
setSelectedProviderId(null);
|
|
2440
|
+
setConnectingNewAccount(false);
|
|
2441
|
+
setAmount(depositAmount != null ? depositAmount.toString() : "");
|
|
2442
|
+
setAdvancedSettings({ asset: null, chain: null });
|
|
2443
|
+
setMobileFlow(false);
|
|
2444
|
+
setSelectSourceChainName("");
|
|
2445
|
+
setSelectSourceTokenSymbol("");
|
|
2446
|
+
initializedSelectSourceActionRef.current = null;
|
|
2447
|
+
processingStartedAtRef.current = null;
|
|
2448
|
+
pollingTransferIdRef.current = null;
|
|
2449
|
+
mobileSigningTransferIdRef.current = null;
|
|
2450
|
+
}, [logout, polling, depositAmount]);
|
|
2419
2451
|
const handleConnectNewAccount = (providerId) => {
|
|
2420
2452
|
setSelectedProviderId(providerId);
|
|
2421
2453
|
setSelectedAccountId(null);
|
|
@@ -2773,7 +2805,32 @@ function SwypePayment({
|
|
|
2773
2805
|
const canPay = !isNaN(parsedAmount) && parsedAmount > 0 && !!sourceId && !loadingData;
|
|
2774
2806
|
const noAccounts = !loadingData && accounts.length === 0;
|
|
2775
2807
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: cardStyle, children: [
|
|
2776
|
-
|
|
2808
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { position: "relative" }, children: [
|
|
2809
|
+
stepBadge("Review & pay"),
|
|
2810
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2811
|
+
"button",
|
|
2812
|
+
{
|
|
2813
|
+
type: "button",
|
|
2814
|
+
onClick: handleLogout,
|
|
2815
|
+
style: {
|
|
2816
|
+
position: "absolute",
|
|
2817
|
+
top: 0,
|
|
2818
|
+
right: 0,
|
|
2819
|
+
background: "transparent",
|
|
2820
|
+
border: "none",
|
|
2821
|
+
color: tokens.textMuted,
|
|
2822
|
+
cursor: "pointer",
|
|
2823
|
+
fontSize: "0.75rem",
|
|
2824
|
+
fontWeight: 600,
|
|
2825
|
+
letterSpacing: "0.04em",
|
|
2826
|
+
textTransform: "uppercase",
|
|
2827
|
+
fontFamily: "inherit",
|
|
2828
|
+
padding: 0
|
|
2829
|
+
},
|
|
2830
|
+
children: "Logout"
|
|
2831
|
+
}
|
|
2832
|
+
)
|
|
2833
|
+
] }),
|
|
2777
2834
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: errorStyle, children: error }),
|
|
2778
2835
|
loadingData ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "24px 0", textAlign: "center" }, children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, { label: "Loading..." }) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2779
2836
|
/* @__PURE__ */ jsxRuntime.jsxs(
|