UNPKG

@kinde-oss/kinde-auth-react

Version:

Kinde React SDK for authentication

103 lines (102 loc) 2.16 kB
import { t as e } from "./useKindeAuth-BFlFfLEC.js"; import { useCallback as t } from "react"; import { jsx as n } from "react/jsx-runtime"; //#region src/components/LoginLink.tsx function r({ children: r, ...i }) { let a = e(), o = t(async () => { a.login(i); }, [a, i]), s = (e) => { i.onClick && i.onClick(e), o(); }; return /* @__PURE__ */ n("button", { type: "button", ...i, onClick: s, children: r }); } //#endregion //#region src/components/RegisterLink.tsx function i({ children: r, ...i }) { let a = e(), o = t(async () => { a.register(i); }, [a, i]), s = (e) => { i.onClick && i.onClick(e), o(); }; return /* @__PURE__ */ n("button", { type: "button", ...i, onClick: s, children: r }); } //#endregion //#region src/components/LogoutLink.tsx function a({ children: r, ...i }) { let a = e(), o = t(async () => { a.logout({ redirectUrl: i.redirectUrl, allSessions: i.allSessions }); }, [ a, i.redirectUrl, i.allSessions ]); return /* @__PURE__ */ n("button", { type: "button", ...i, onClick: () => { o(); }, children: r }); } //#endregion //#region src/components/PortalLink.tsx function o({ children: r, ...i }) { let a = e(), o = t(async () => { try { let e = await a.generatePortalUrl({ subNav: i.subNav, returnUrl: i.returnUrl || window.location.href }); window.location.href = e.url.toString(); } catch (e) { console.error("Failed to generate portal URL:", e); } }, [ a, i.returnUrl, i.subNav ]); return /* @__PURE__ */ n("button", { type: "button", ...i, onClick: async () => { await o(); }, children: r }); } //#endregion //#region src/components/SwitchOrgLink.tsx function s({ children: r, orgCode: i, ...a }) { let o = e(), s = t(async () => { try { await o.switchOrg(i); } catch (e) { console.error("Failed to switch organization:", e); } }, [o, i]), c = (e) => { a.onClick && a.onClick(e), s(); }; return /* @__PURE__ */ n("button", { type: "button", ...a, onClick: c, children: r }); } //#endregion export { r as LoginLink, a as LogoutLink, o as PortalLink, i as RegisterLink, s as SwitchOrgLink };