@blocklet/ui-react
Version:
Some useful front-end web components that can be used in Blocklets.
77 lines (76 loc) • 2.39 kB
JavaScript
import { jsxs as a, Fragment as f, jsx as o } from "react/jsx-runtime";
import { use as u } from "react";
import { Box as s, Typography as c, Button as h } from "@mui/material";
import { useLocaleContext as x } from "@arcblock/ux/lib/Locale/context";
import { translate as g } from "@arcblock/ux/lib/Locale/util";
import { useMemoizedFn as l } from "ahooks";
import { useConfirm as y } from "@arcblock/ux/lib/Dialog";
import { SessionContext as v } from "@arcblock/did-connect-react/lib/Session";
import w from "@arcblock/ux/lib/Toast";
import { translations as C } from "../libs/locales.js";
function S({ onDestroySelf: t = void 0 }) {
const { confirmHolder: m } = y(), { locale: d } = x(), { session: e } = u(v), r = l((n, i = {}) => g(C, n, d, "en", i)), p = l(async () => {
if (!t || typeof t != "function")
return;
const n = e.withSecondaryAuth(t, {
extraParams: {
locale: d,
removeUserDid: e?.user?.did,
input: {
user: { did: e?.user?.did },
teamDid: window?.blocklet?.did
}
},
operation: "destroySelf"
});
try {
await n(), e.logout();
} catch (i) {
w.error(i?.message || r("destroyMyself.error"));
}
});
return /* @__PURE__ */ a(f, { children: [
/* @__PURE__ */ o(s, { children: /* @__PURE__ */ a(
s,
{
sx: {
display: "flex",
alignItems: "center",
gap: 1,
justifyContent: "space-between",
flexWrap: "wrap"
},
children: [
/* @__PURE__ */ a(s, { children: [
/* @__PURE__ */ o(
c,
{
variant: "h6",
sx: {
fontSize: "0.875rem !important",
fontWeight: "bold"
},
children: r("dangerZone.deleteAccount")
}
),
/* @__PURE__ */ o(
c,
{
variant: "caption",
sx: {
color: "text.secondary"
},
children: r("dangerZone.deleteAccountDescription")
}
)
] }),
/* @__PURE__ */ o(h, { variant: "contained", color: "error", size: "small", onClick: p, children: r("dangerZone.delete") })
]
}
) }),
m
] });
}
export {
S as default
};