@dashadmin/dash-admin 1.0.0

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.
@@ -0,0 +1,150 @@
1
+ import { jsx as e, jsxs as o } from "react/jsx-runtime";
2
+ import { Box as n, Alert as x, Button as y, Grid as m, IconButton as S, TextField as I } from "@mui/material";
3
+ import { useState as a, useEffect as R } from "react";
4
+ import { useRedirect as k, useNotify as E } from "react-admin";
5
+ import { b as j, c as A, F as B } from "./index-U84xs0Dc.js";
6
+ import "react-redux";
7
+ import "@dashadmin/dash-admin-state";
8
+ import "@mui/icons-material/MenuOpen";
9
+ import "@dashadmin/dash-auth";
10
+ import "react-router-dom";
11
+ import "@mui/icons-material/NavigateNext";
12
+ import F from "@mui/icons-material/Home";
13
+ import "@dashadmin/dash-constants";
14
+ import "react-toastify";
15
+ import "@dashadmin/dash-dialog";
16
+ import "@dashadmin/dash-modal";
17
+ import "@mui/icons-material/ExpandMore";
18
+ import "@dashadmin/dash-auto-admin";
19
+ import "react-router";
20
+ import "@mui/icons-material/NotificationsActive";
21
+ import "react-custom-scrollbars-2";
22
+ import { dashStorage as H } from "@dashadmin/dash-utils";
23
+ import "@mui/x-date-pickers";
24
+ import "@mui/x-date-pickers/AdapterDayjs";
25
+ const ae = ({}) => {
26
+ const [l, b] = a(""), [c, p] = a(!1), [d, u] = a(""), [v, C] = a(!1), { axios: w } = j(), h = k(), f = E(), N = async (s) => {
27
+ var g;
28
+ s.preventDefault(), u(""), p(!0);
29
+ try {
30
+ const { data: r } = await w.post("password/email", {
31
+ email: l
32
+ });
33
+ C(!0), f(r.message, { type: "success" });
34
+ } catch (r) {
35
+ let i = "Ha ocurrido un error";
36
+ if ((g = r == null ? void 0 : r.response) != null && g.data) {
37
+ const t = r.response.data;
38
+ t.errors && t.errors.email && t.errors.email.length > 0 ? i = t.errors.email[0] : t.message && (i = t.message);
39
+ } else r != null && r.message && (i = r.message);
40
+ u(i), f(i, { type: "warning" });
41
+ } finally {
42
+ p(!1);
43
+ }
44
+ };
45
+ return R(() => {
46
+ H.clear(), A();
47
+ }, []), /* @__PURE__ */ e(B, { children: /* @__PURE__ */ e(
48
+ n,
49
+ {
50
+ sx: {
51
+ //height: '100vh',
52
+ display: "flex",
53
+ alignItems: "flex-start",
54
+ // align to top
55
+ justifyContent: "center",
56
+ pt: 8
57
+ // thick top margin
58
+ },
59
+ children: /* @__PURE__ */ e(
60
+ n,
61
+ {
62
+ sx: {
63
+ width: "100%",
64
+ maxWidth: 420,
65
+ mx: "auto"
66
+ },
67
+ children: v ? /* @__PURE__ */ o(
68
+ n,
69
+ {
70
+ sx: {
71
+ display: "flex",
72
+ flexDirection: "column",
73
+ alignItems: "center",
74
+ justifyContent: "center",
75
+ boxShadow: 3,
76
+ borderRadius: 2,
77
+ p: 4,
78
+ minWidth: 320,
79
+ minHeight: 200,
80
+ bgcolor: "background.paper",
81
+ mt: 8,
82
+ // thick top margin
83
+ mx: "auto"
84
+ },
85
+ children: [
86
+ /* @__PURE__ */ e("h1", { className: "dash-app-login-form-title", style: { margin: 0 }, children: "Recuperar Contraseña" }),
87
+ /* @__PURE__ */ e(x, { severity: "success", sx: { mt: 2, mb: 2 }, children: "Si el correo existe en nuestro sistema, recibirás un enlace para restablecer tu contraseña." }),
88
+ /* @__PURE__ */ e(
89
+ y,
90
+ {
91
+ variant: "contained",
92
+ color: "primary",
93
+ onClick: () => h("/login"),
94
+ sx: { mt: 2 },
95
+ children: "Ir al Login"
96
+ }
97
+ )
98
+ ]
99
+ }
100
+ ) : /* @__PURE__ */ o("form", { onSubmit: N, className: "dash-app-login-form", children: [
101
+ /* @__PURE__ */ o(m, { container: !0, sx: { mb: 4, mt: 2 }, spacing: 2, alignItems: "center", children: [
102
+ /* @__PURE__ */ e(m, { item: !0, xs: 2, children: /* @__PURE__ */ e(
103
+ S,
104
+ {
105
+ color: "primary",
106
+ size: "large",
107
+ onClick: () => h("/"),
108
+ children: /* @__PURE__ */ e(F, {})
109
+ }
110
+ ) }),
111
+ /* @__PURE__ */ e(m, { item: !0, xs: 10, children: /* @__PURE__ */ e("h1", { className: "dash-app-login-form-title", style: { margin: 0 }, children: "Recuperar Contraseña" }) })
112
+ ] }),
113
+ d && /* @__PURE__ */ e(x, { severity: "error", sx: { mb: 2 }, children: d }),
114
+ /* @__PURE__ */ e("div", { className: "dash-app-form-item", children: /* @__PURE__ */ e(
115
+ I,
116
+ {
117
+ fullWidth: !0,
118
+ variant: "outlined",
119
+ label: "Email",
120
+ placeholder: "Email",
121
+ required: !0,
122
+ value: l,
123
+ inputProps: { type: "email" },
124
+ onChange: (s) => b(s.target.value),
125
+ className: "dash-app-form-item-input",
126
+ autoComplete: "username",
127
+ name: "email",
128
+ type: "email",
129
+ id: "email"
130
+ }
131
+ ) }),
132
+ /* @__PURE__ */ e("div", { className: "dash-app-form-item mt-1", children: /* @__PURE__ */ e(
133
+ y,
134
+ {
135
+ type: "submit",
136
+ variant: "contained",
137
+ disabled: c,
138
+ sx: { mb: 2, width: "100%" },
139
+ children: c ? "Cargando..." : "Resetear Contraseña"
140
+ }
141
+ ) })
142
+ ] })
143
+ }
144
+ )
145
+ }
146
+ ) });
147
+ };
148
+ export {
149
+ ae as default
150
+ };
@@ -0,0 +1,99 @@
1
+ import { jsx as t, jsxs as g } from "react/jsx-runtime";
2
+ import { useState as m, useEffect as h } from "react";
3
+ import { useSearchParams as v, useNavigate as x } from "react-router-dom";
4
+ import { b as y, F as b } from "./index-U84xs0Dc.js";
5
+ import { Box as k, CircularProgress as C, Typography as P } from "@mui/material";
6
+ import { getEnv as T } from "@dashadmin/dash-constants/src/DASHAdminSystemConstants";
7
+ import "react-redux";
8
+ import "react-admin";
9
+ import "@dashadmin/dash-admin-state";
10
+ import "@mui/icons-material/MenuOpen";
11
+ import "@dashadmin/dash-auth";
12
+ import "@mui/icons-material/NavigateNext";
13
+ import "@mui/icons-material/Home";
14
+ import "@dashadmin/dash-constants";
15
+ import "react-toastify";
16
+ import "@dashadmin/dash-dialog";
17
+ import "@dashadmin/dash-modal";
18
+ import "@mui/icons-material/ExpandMore";
19
+ import "@dashadmin/dash-auto-admin";
20
+ import "react-router";
21
+ import "@mui/icons-material/NotificationsActive";
22
+ import "react-custom-scrollbars-2";
23
+ import "@dashadmin/dash-utils";
24
+ import "@mui/x-date-pickers";
25
+ import "@mui/x-date-pickers/AdapterDayjs";
26
+ const Y = ({}) => {
27
+ const [a] = v(), e = x(), { axios: s } = y(), [l, r] = m("loading"), [u, i] = m("Verificando cuenta..."), d = T("APP_BACKEND_URL") || "http://localhost:8000", p = async () => {
28
+ try {
29
+ const o = a.get("verification_url");
30
+ if (o) {
31
+ switch ((await s.get(o)).status) {
32
+ case 200:
33
+ r("success"), i("Cuenta verificada correctamente. Redirigiendo al login..."), setTimeout(() => e("/login"), 3e3);
34
+ break;
35
+ case 204:
36
+ r("success"), i("Cuenta ya verificada. Redirigiendo al login..."), setTimeout(() => e("/login"), 3e3);
37
+ break;
38
+ default:
39
+ r("error"), i("Error al verificar la cuenta. Por favor, intente nuevamente."), setTimeout(() => e("/login"), 3e3);
40
+ break;
41
+ }
42
+ return;
43
+ }
44
+ const n = a.get("id"), c = a.get("hash");
45
+ if (!n || !c) {
46
+ r("error"), i("Link de verificación inválido."), setTimeout(() => e("/login"), 8e3);
47
+ return;
48
+ }
49
+ const f = `${d}/api/email/verify/${n}/${c}`;
50
+ switch ((await s.get(f)).status) {
51
+ case 200:
52
+ r("success"), i("Cuenta verificada correctamente. Redirigiendo al login..."), setTimeout(() => e("/login"), 3e3);
53
+ break;
54
+ case 204:
55
+ r("success"), i("Cuenta ya verificada. Redirigiendo al login..."), setTimeout(() => e("/login"), 3e3);
56
+ break;
57
+ default:
58
+ r("error"), i("Error al verificar la cuenta. Por favor, intente nuevamente."), setTimeout(() => e("/login"), 8e3);
59
+ break;
60
+ }
61
+ } catch (o) {
62
+ console.error("Verification error:", o), r("error"), i("Error al verificar la cuenta. Por favor, intente nuevamente."), setTimeout(() => e("/login"), 8e3);
63
+ }
64
+ };
65
+ return h(() => {
66
+ p();
67
+ }, []), /* @__PURE__ */ t(
68
+ b,
69
+ {
70
+ children: /* @__PURE__ */ t("div", { className: "dash-app-login-form", children: /* @__PURE__ */ g(
71
+ k,
72
+ {
73
+ sx: {
74
+ display: "flex",
75
+ flexDirection: "column",
76
+ alignItems: "center",
77
+ justifyContent: "center",
78
+ boxShadow: 3,
79
+ borderRadius: 2,
80
+ p: 4,
81
+ minWidth: 320,
82
+ minHeight: 200,
83
+ backgroundColor: "background.paper",
84
+ mx: "auto",
85
+ my: 8
86
+ },
87
+ children: [
88
+ /* @__PURE__ */ t("h1", { className: "dash-app-login-form-title", children: "Verificación de Cuenta" }),
89
+ l === "loading" && /* @__PURE__ */ t(C, { size: 60, thickness: 4 }),
90
+ /* @__PURE__ */ t(P, { sx: { mt: 2, textAlign: "center" }, children: u })
91
+ ]
92
+ }
93
+ ) })
94
+ }
95
+ );
96
+ };
97
+ export {
98
+ Y as default
99
+ };