Files
CRM-OLD-FRONT/assets/login.lazy-CNWwm0Pr.js
2025-07-24 20:14:43 +03:00

178 lines
5.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import {h as P, a as w, b as T, j as o, B as v, d as S, aX as N, f, O as y, P as a, r as m, aS as z, $ as L, aY as O, ac as b, a0 as C, ax as E, aZ as R, X as _, a_ as B, c as q} from "./index-CdMy-Rhi.js";
var j = {
root: "m_7485cace"
};
const D = {}
, W = S( (i, {size: e, fluid: s}) => ({
root: {
"--container-size": s ? void 0 : N(e, "container-size")
}
}))
, h = P( (i, e) => {
const s = w("Container", D, i)
, {classNames: r, className: c, style: d, styles: n, unstyled: l, vars: p, fluid: u, mod: t, ...g} = s
, x = T({
name: "Container",
classes: j,
props: s,
className: c,
style: d,
classNames: r,
styles: n,
unstyled: l,
vars: p,
varsResolver: W
});
return o.jsx(v, {
ref: e,
mod: [{
fluid: u
}, t],
...x("root"),
...g
})
}
);
h.classes = j;
h.displayName = "@mantine/core/Container";
class k {
static loginAuthLoginPost({requestBody: e}) {
return f(y, {
method: "POST",
url: "/auth/login",
body: e,
mediaType: "application/json",
errors: {
422: "Validation Error"
}
})
}
static testAuthTestPost() {
return f(y, {
method: "POST",
url: "/auth/test"
})
}
}
const F = "_title_hwj38_1"
, V = {
title: F
}
, A = ({wrapperProps: i, dataAuthUrl: e, usePic: s=!1, botName: r, className: c, buttonSize: d="large", dataOnauth: n, cornerRadius: l, requestAccess: p=!0}) => {
const u = m.useRef(null);
return m.useEffect( () => {
if (u.current === null)
return;
if (typeof n > "u" && typeof e > "u")
throw new Error("One of this props should be defined: dataAuthUrl (redirect URL), dataOnauth (callback fn) should be defined.");
typeof n == "function" && (window.TelegramLoginWidget = {
dataOnauth: g => n(g)
});
const t = document.createElement("script");
t.src = "https://telegram.org/js/telegram-widget.js?22",
t.setAttribute("data-telegram-login", r),
t.setAttribute("data-size", d),
l !== void 0 && t.setAttribute("data-radius", l.toString()),
p && t.setAttribute("data-request-access", "write"),
t.setAttribute("data-userpic", s.toString()),
typeof e == "string" ? t.setAttribute("data-auth-url", e) : t.setAttribute("data-onauth", "TelegramLoginWidget.dataOnauth(user)"),
t.async = !0,
u.current.appendChild(t)
}
, [r, d, l, n, p, s, u, e]),
o.jsx("div", {
ref: u,
className: c,
...i
})
}
;
A.propTypes = {
botName: a.string.isRequired,
usePic: a.bool,
className: a.string,
cornerRadius: a.number,
requestAccess: a.bool,
wrapperProps: a.object,
dataOnauth: a.func,
dataAuthUrl: a.string,
buttonSize: a.oneOf(["large", "medium", "small"])
};
const X = () => {
const i = z()
, e = L(r => r.auth)
, s = O();
return m.useEffect( () => {
e.isAuthorized && s({
to: "/leads"
}).then( () => {
s({
to: "/leads"
}).then( () => {
b.success({
message: "Вы успешно вошли!"
})
}
)
}
)
}
, [e.isAuthorized]),
e.isAuthorized ? o.jsx(C, {
to: "/leads"
}) : o.jsxs(h, {
size: 420,
my: 40,
children: [o.jsx(E, {
ta: "center",
className: V.title,
children: "Добро пожаловать"
}), o.jsxs(R, {
withBorder: !0,
shadow: "md",
p: 30,
mt: 30,
radius: "md",
children: [o.jsx(A, {
botName: "LogidexCRMBot",
dataOnauth: () => {}
,
wrapperProps: {
style: {
display: "none"
}
}
}), o.jsx(_, {
fullWidth: !0,
onClick: () => {
window.Telegram.Login.auth({
bot_id: "8223019480",
request_access: !0
}, r => {
k.loginAuthLoginPost({
requestBody: r
}).then( ({accessToken: c}) => {
i(B({
accessToken: c
}))
}
).catch( () => {
b.error({
message: "Не удалось войти!"
})
}
)
}
)
}
,
children: "Войти через Telegram"
})]
})]
})
}
, I = q("/login")({
component: X
});
export {I as Route};