@mhiliger/auth-fe 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.
- package/README.md +165 -0
- package/dist/auth-fe.es.js +1290 -0
- package/dist/auth-fe.umd.js +30 -0
- package/package.json +40 -0
|
@@ -0,0 +1,1290 @@
|
|
|
1
|
+
import Ze, { createContext as Or, useState as be, useContext as Cr, useEffect as we } from "react";
|
|
2
|
+
import { useQuery as Ee, useMutation as de } from "@tanstack/react-query";
|
|
3
|
+
import { useLocation as Ar, Outlet as qr, Navigate as ce, Routes as Fr, Route as W, useNavigate as Qe, NavLink as D } from "react-router-dom";
|
|
4
|
+
import { useForm as te, appendErrors as Dr } from "react-hook-form";
|
|
5
|
+
import Vr from "jwt-decode";
|
|
6
|
+
import { Box as b, Alert as Y, Typography as g, Stack as J, TextField as L, Button as se, CircularProgress as re } from "@mui/material";
|
|
7
|
+
import { validateFieldsNatively as $r, toNestErrors as Ir } from "@hookform/resolvers";
|
|
8
|
+
import * as k from "yup";
|
|
9
|
+
var Re = { exports: {} }, Q = {};
|
|
10
|
+
/**
|
|
11
|
+
* @license React
|
|
12
|
+
* react-jsx-runtime.production.min.js
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
15
|
+
*
|
|
16
|
+
* This source code is licensed under the MIT license found in the
|
|
17
|
+
* LICENSE file in the root directory of this source tree.
|
|
18
|
+
*/
|
|
19
|
+
var Xe;
|
|
20
|
+
function Lr() {
|
|
21
|
+
if (Xe) return Q;
|
|
22
|
+
Xe = 1;
|
|
23
|
+
var s = Ze, i = Symbol.for("react.element"), l = Symbol.for("react.fragment"), o = Object.prototype.hasOwnProperty, m = s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, f = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
24
|
+
function p(n, u, h) {
|
|
25
|
+
var c, w = {}, E = null, S = null;
|
|
26
|
+
h !== void 0 && (E = "" + h), u.key !== void 0 && (E = "" + u.key), u.ref !== void 0 && (S = u.ref);
|
|
27
|
+
for (c in u) o.call(u, c) && !f.hasOwnProperty(c) && (w[c] = u[c]);
|
|
28
|
+
if (n && n.defaultProps) for (c in u = n.defaultProps, u) w[c] === void 0 && (w[c] = u[c]);
|
|
29
|
+
return { $$typeof: i, type: n, key: E, ref: S, props: w, _owner: m.current };
|
|
30
|
+
}
|
|
31
|
+
return Q.Fragment = l, Q.jsx = p, Q.jsxs = p, Q;
|
|
32
|
+
}
|
|
33
|
+
var ee = {};
|
|
34
|
+
/**
|
|
35
|
+
* @license React
|
|
36
|
+
* react-jsx-runtime.development.js
|
|
37
|
+
*
|
|
38
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
39
|
+
*
|
|
40
|
+
* This source code is licensed under the MIT license found in the
|
|
41
|
+
* LICENSE file in the root directory of this source tree.
|
|
42
|
+
*/
|
|
43
|
+
var He;
|
|
44
|
+
function Yr() {
|
|
45
|
+
return He || (He = 1, process.env.NODE_ENV !== "production" && function() {
|
|
46
|
+
var s = Ze, i = Symbol.for("react.element"), l = Symbol.for("react.portal"), o = Symbol.for("react.fragment"), m = Symbol.for("react.strict_mode"), f = Symbol.for("react.profiler"), p = Symbol.for("react.provider"), n = Symbol.for("react.context"), u = Symbol.for("react.forward_ref"), h = Symbol.for("react.suspense"), c = Symbol.for("react.suspense_list"), w = Symbol.for("react.memo"), E = Symbol.for("react.lazy"), S = Symbol.for("react.offscreen"), _ = Symbol.iterator, A = "@@iterator";
|
|
47
|
+
function V(e) {
|
|
48
|
+
if (e === null || typeof e != "object")
|
|
49
|
+
return null;
|
|
50
|
+
var t = _ && e[_] || e[A];
|
|
51
|
+
return typeof t == "function" ? t : null;
|
|
52
|
+
}
|
|
53
|
+
var q = s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
54
|
+
function j(e) {
|
|
55
|
+
{
|
|
56
|
+
for (var t = arguments.length, a = new Array(t > 1 ? t - 1 : 0), d = 1; d < t; d++)
|
|
57
|
+
a[d - 1] = arguments[d];
|
|
58
|
+
N("error", e, a);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function N(e, t, a) {
|
|
62
|
+
{
|
|
63
|
+
var d = q.ReactDebugCurrentFrame, y = d.getStackAddendum();
|
|
64
|
+
y !== "" && (t += "%s", a = a.concat([y]));
|
|
65
|
+
var R = a.map(function(v) {
|
|
66
|
+
return String(v);
|
|
67
|
+
});
|
|
68
|
+
R.unshift("Warning: " + t), Function.prototype.apply.call(console[e], console, R);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
var $ = !1, O = !1, z = !1, ae = !1, X = !1, Se;
|
|
72
|
+
Se = Symbol.for("react.module.reference");
|
|
73
|
+
function rr(e) {
|
|
74
|
+
return !!(typeof e == "string" || typeof e == "function" || e === o || e === f || X || e === m || e === h || e === c || ae || e === S || $ || O || z || typeof e == "object" && e !== null && (e.$$typeof === E || e.$$typeof === w || e.$$typeof === p || e.$$typeof === n || e.$$typeof === u || // This needs to include all possible module reference object
|
|
75
|
+
// types supported by any Flight configuration anywhere since
|
|
76
|
+
// we don't know which Flight build this will end up being used
|
|
77
|
+
// with.
|
|
78
|
+
e.$$typeof === Se || e.getModuleId !== void 0));
|
|
79
|
+
}
|
|
80
|
+
function tr(e, t, a) {
|
|
81
|
+
var d = e.displayName;
|
|
82
|
+
if (d)
|
|
83
|
+
return d;
|
|
84
|
+
var y = t.displayName || t.name || "";
|
|
85
|
+
return y !== "" ? a + "(" + y + ")" : a;
|
|
86
|
+
}
|
|
87
|
+
function _e(e) {
|
|
88
|
+
return e.displayName || "Context";
|
|
89
|
+
}
|
|
90
|
+
function B(e) {
|
|
91
|
+
if (e == null)
|
|
92
|
+
return null;
|
|
93
|
+
if (typeof e.tag == "number" && j("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
|
|
94
|
+
return e.displayName || e.name || null;
|
|
95
|
+
if (typeof e == "string")
|
|
96
|
+
return e;
|
|
97
|
+
switch (e) {
|
|
98
|
+
case o:
|
|
99
|
+
return "Fragment";
|
|
100
|
+
case l:
|
|
101
|
+
return "Portal";
|
|
102
|
+
case f:
|
|
103
|
+
return "Profiler";
|
|
104
|
+
case m:
|
|
105
|
+
return "StrictMode";
|
|
106
|
+
case h:
|
|
107
|
+
return "Suspense";
|
|
108
|
+
case c:
|
|
109
|
+
return "SuspenseList";
|
|
110
|
+
}
|
|
111
|
+
if (typeof e == "object")
|
|
112
|
+
switch (e.$$typeof) {
|
|
113
|
+
case n:
|
|
114
|
+
var t = e;
|
|
115
|
+
return _e(t) + ".Consumer";
|
|
116
|
+
case p:
|
|
117
|
+
var a = e;
|
|
118
|
+
return _e(a._context) + ".Provider";
|
|
119
|
+
case u:
|
|
120
|
+
return tr(e, e.render, "ForwardRef");
|
|
121
|
+
case w:
|
|
122
|
+
var d = e.displayName || null;
|
|
123
|
+
return d !== null ? d : B(e.type) || "Memo";
|
|
124
|
+
case E: {
|
|
125
|
+
var y = e, R = y._payload, v = y._init;
|
|
126
|
+
try {
|
|
127
|
+
return B(v(R));
|
|
128
|
+
} catch {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
var U = Object.assign, H = 0, Te, Pe, ke, Oe, Ce, Ae, qe;
|
|
136
|
+
function Fe() {
|
|
137
|
+
}
|
|
138
|
+
Fe.__reactDisabledLog = !0;
|
|
139
|
+
function sr() {
|
|
140
|
+
{
|
|
141
|
+
if (H === 0) {
|
|
142
|
+
Te = console.log, Pe = console.info, ke = console.warn, Oe = console.error, Ce = console.group, Ae = console.groupCollapsed, qe = console.groupEnd;
|
|
143
|
+
var e = {
|
|
144
|
+
configurable: !0,
|
|
145
|
+
enumerable: !0,
|
|
146
|
+
value: Fe,
|
|
147
|
+
writable: !0
|
|
148
|
+
};
|
|
149
|
+
Object.defineProperties(console, {
|
|
150
|
+
info: e,
|
|
151
|
+
log: e,
|
|
152
|
+
warn: e,
|
|
153
|
+
error: e,
|
|
154
|
+
group: e,
|
|
155
|
+
groupCollapsed: e,
|
|
156
|
+
groupEnd: e
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
H++;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function nr() {
|
|
163
|
+
{
|
|
164
|
+
if (H--, H === 0) {
|
|
165
|
+
var e = {
|
|
166
|
+
configurable: !0,
|
|
167
|
+
enumerable: !0,
|
|
168
|
+
writable: !0
|
|
169
|
+
};
|
|
170
|
+
Object.defineProperties(console, {
|
|
171
|
+
log: U({}, e, {
|
|
172
|
+
value: Te
|
|
173
|
+
}),
|
|
174
|
+
info: U({}, e, {
|
|
175
|
+
value: Pe
|
|
176
|
+
}),
|
|
177
|
+
warn: U({}, e, {
|
|
178
|
+
value: ke
|
|
179
|
+
}),
|
|
180
|
+
error: U({}, e, {
|
|
181
|
+
value: Oe
|
|
182
|
+
}),
|
|
183
|
+
group: U({}, e, {
|
|
184
|
+
value: Ce
|
|
185
|
+
}),
|
|
186
|
+
groupCollapsed: U({}, e, {
|
|
187
|
+
value: Ae
|
|
188
|
+
}),
|
|
189
|
+
groupEnd: U({}, e, {
|
|
190
|
+
value: qe
|
|
191
|
+
})
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
H < 0 && j("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
var me = q.ReactCurrentDispatcher, pe;
|
|
198
|
+
function ie(e, t, a) {
|
|
199
|
+
{
|
|
200
|
+
if (pe === void 0)
|
|
201
|
+
try {
|
|
202
|
+
throw Error();
|
|
203
|
+
} catch (y) {
|
|
204
|
+
var d = y.stack.trim().match(/\n( *(at )?)/);
|
|
205
|
+
pe = d && d[1] || "";
|
|
206
|
+
}
|
|
207
|
+
return `
|
|
208
|
+
` + pe + e;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
var he = !1, oe;
|
|
212
|
+
{
|
|
213
|
+
var ar = typeof WeakMap == "function" ? WeakMap : Map;
|
|
214
|
+
oe = new ar();
|
|
215
|
+
}
|
|
216
|
+
function De(e, t) {
|
|
217
|
+
if (!e || he)
|
|
218
|
+
return "";
|
|
219
|
+
{
|
|
220
|
+
var a = oe.get(e);
|
|
221
|
+
if (a !== void 0)
|
|
222
|
+
return a;
|
|
223
|
+
}
|
|
224
|
+
var d;
|
|
225
|
+
he = !0;
|
|
226
|
+
var y = Error.prepareStackTrace;
|
|
227
|
+
Error.prepareStackTrace = void 0;
|
|
228
|
+
var R;
|
|
229
|
+
R = me.current, me.current = null, sr();
|
|
230
|
+
try {
|
|
231
|
+
if (t) {
|
|
232
|
+
var v = function() {
|
|
233
|
+
throw Error();
|
|
234
|
+
};
|
|
235
|
+
if (Object.defineProperty(v.prototype, "props", {
|
|
236
|
+
set: function() {
|
|
237
|
+
throw Error();
|
|
238
|
+
}
|
|
239
|
+
}), typeof Reflect == "object" && Reflect.construct) {
|
|
240
|
+
try {
|
|
241
|
+
Reflect.construct(v, []);
|
|
242
|
+
} catch (F) {
|
|
243
|
+
d = F;
|
|
244
|
+
}
|
|
245
|
+
Reflect.construct(e, [], v);
|
|
246
|
+
} else {
|
|
247
|
+
try {
|
|
248
|
+
v.call();
|
|
249
|
+
} catch (F) {
|
|
250
|
+
d = F;
|
|
251
|
+
}
|
|
252
|
+
e.call(v.prototype);
|
|
253
|
+
}
|
|
254
|
+
} else {
|
|
255
|
+
try {
|
|
256
|
+
throw Error();
|
|
257
|
+
} catch (F) {
|
|
258
|
+
d = F;
|
|
259
|
+
}
|
|
260
|
+
e();
|
|
261
|
+
}
|
|
262
|
+
} catch (F) {
|
|
263
|
+
if (F && d && typeof F.stack == "string") {
|
|
264
|
+
for (var x = F.stack.split(`
|
|
265
|
+
`), C = d.stack.split(`
|
|
266
|
+
`), T = x.length - 1, P = C.length - 1; T >= 1 && P >= 0 && x[T] !== C[P]; )
|
|
267
|
+
P--;
|
|
268
|
+
for (; T >= 1 && P >= 0; T--, P--)
|
|
269
|
+
if (x[T] !== C[P]) {
|
|
270
|
+
if (T !== 1 || P !== 1)
|
|
271
|
+
do
|
|
272
|
+
if (T--, P--, P < 0 || x[T] !== C[P]) {
|
|
273
|
+
var I = `
|
|
274
|
+
` + x[T].replace(" at new ", " at ");
|
|
275
|
+
return e.displayName && I.includes("<anonymous>") && (I = I.replace("<anonymous>", e.displayName)), typeof e == "function" && oe.set(e, I), I;
|
|
276
|
+
}
|
|
277
|
+
while (T >= 1 && P >= 0);
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
} finally {
|
|
282
|
+
he = !1, me.current = R, nr(), Error.prepareStackTrace = y;
|
|
283
|
+
}
|
|
284
|
+
var G = e ? e.displayName || e.name : "", K = G ? ie(G) : "";
|
|
285
|
+
return typeof e == "function" && oe.set(e, K), K;
|
|
286
|
+
}
|
|
287
|
+
function ir(e, t, a) {
|
|
288
|
+
return De(e, !1);
|
|
289
|
+
}
|
|
290
|
+
function or(e) {
|
|
291
|
+
var t = e.prototype;
|
|
292
|
+
return !!(t && t.isReactComponent);
|
|
293
|
+
}
|
|
294
|
+
function le(e, t, a) {
|
|
295
|
+
if (e == null)
|
|
296
|
+
return "";
|
|
297
|
+
if (typeof e == "function")
|
|
298
|
+
return De(e, or(e));
|
|
299
|
+
if (typeof e == "string")
|
|
300
|
+
return ie(e);
|
|
301
|
+
switch (e) {
|
|
302
|
+
case h:
|
|
303
|
+
return ie("Suspense");
|
|
304
|
+
case c:
|
|
305
|
+
return ie("SuspenseList");
|
|
306
|
+
}
|
|
307
|
+
if (typeof e == "object")
|
|
308
|
+
switch (e.$$typeof) {
|
|
309
|
+
case u:
|
|
310
|
+
return ir(e.render);
|
|
311
|
+
case w:
|
|
312
|
+
return le(e.type, t, a);
|
|
313
|
+
case E: {
|
|
314
|
+
var d = e, y = d._payload, R = d._init;
|
|
315
|
+
try {
|
|
316
|
+
return le(R(y), t, a);
|
|
317
|
+
} catch {
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return "";
|
|
322
|
+
}
|
|
323
|
+
var Z = Object.prototype.hasOwnProperty, Ve = {}, $e = q.ReactDebugCurrentFrame;
|
|
324
|
+
function ue(e) {
|
|
325
|
+
if (e) {
|
|
326
|
+
var t = e._owner, a = le(e.type, e._source, t ? t.type : null);
|
|
327
|
+
$e.setExtraStackFrame(a);
|
|
328
|
+
} else
|
|
329
|
+
$e.setExtraStackFrame(null);
|
|
330
|
+
}
|
|
331
|
+
function lr(e, t, a, d, y) {
|
|
332
|
+
{
|
|
333
|
+
var R = Function.call.bind(Z);
|
|
334
|
+
for (var v in e)
|
|
335
|
+
if (R(e, v)) {
|
|
336
|
+
var x = void 0;
|
|
337
|
+
try {
|
|
338
|
+
if (typeof e[v] != "function") {
|
|
339
|
+
var C = Error((d || "React class") + ": " + a + " type `" + v + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[v] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
|
340
|
+
throw C.name = "Invariant Violation", C;
|
|
341
|
+
}
|
|
342
|
+
x = e[v](t, v, d, a, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
|
|
343
|
+
} catch (T) {
|
|
344
|
+
x = T;
|
|
345
|
+
}
|
|
346
|
+
x && !(x instanceof Error) && (ue(y), j("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", d || "React class", a, v, typeof x), ue(null)), x instanceof Error && !(x.message in Ve) && (Ve[x.message] = !0, ue(y), j("Failed %s type: %s", a, x.message), ue(null));
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
var ur = Array.isArray;
|
|
351
|
+
function xe(e) {
|
|
352
|
+
return ur(e);
|
|
353
|
+
}
|
|
354
|
+
function cr(e) {
|
|
355
|
+
{
|
|
356
|
+
var t = typeof Symbol == "function" && Symbol.toStringTag, a = t && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
357
|
+
return a;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
function dr(e) {
|
|
361
|
+
try {
|
|
362
|
+
return Ie(e), !1;
|
|
363
|
+
} catch {
|
|
364
|
+
return !0;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
function Ie(e) {
|
|
368
|
+
return "" + e;
|
|
369
|
+
}
|
|
370
|
+
function Le(e) {
|
|
371
|
+
if (dr(e))
|
|
372
|
+
return j("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", cr(e)), Ie(e);
|
|
373
|
+
}
|
|
374
|
+
var Ye = q.ReactCurrentOwner, fr = {
|
|
375
|
+
key: !0,
|
|
376
|
+
ref: !0,
|
|
377
|
+
__self: !0,
|
|
378
|
+
__source: !0
|
|
379
|
+
}, Ne, ze;
|
|
380
|
+
function mr(e) {
|
|
381
|
+
if (Z.call(e, "ref")) {
|
|
382
|
+
var t = Object.getOwnPropertyDescriptor(e, "ref").get;
|
|
383
|
+
if (t && t.isReactWarning)
|
|
384
|
+
return !1;
|
|
385
|
+
}
|
|
386
|
+
return e.ref !== void 0;
|
|
387
|
+
}
|
|
388
|
+
function pr(e) {
|
|
389
|
+
if (Z.call(e, "key")) {
|
|
390
|
+
var t = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
391
|
+
if (t && t.isReactWarning)
|
|
392
|
+
return !1;
|
|
393
|
+
}
|
|
394
|
+
return e.key !== void 0;
|
|
395
|
+
}
|
|
396
|
+
function hr(e, t) {
|
|
397
|
+
typeof e.ref == "string" && Ye.current;
|
|
398
|
+
}
|
|
399
|
+
function xr(e, t) {
|
|
400
|
+
{
|
|
401
|
+
var a = function() {
|
|
402
|
+
Ne || (Ne = !0, j("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", t));
|
|
403
|
+
};
|
|
404
|
+
a.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
405
|
+
get: a,
|
|
406
|
+
configurable: !0
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
function vr(e, t) {
|
|
411
|
+
{
|
|
412
|
+
var a = function() {
|
|
413
|
+
ze || (ze = !0, j("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", t));
|
|
414
|
+
};
|
|
415
|
+
a.isReactWarning = !0, Object.defineProperty(e, "ref", {
|
|
416
|
+
get: a,
|
|
417
|
+
configurable: !0
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
var gr = function(e, t, a, d, y, R, v) {
|
|
422
|
+
var x = {
|
|
423
|
+
// This tag allows us to uniquely identify this as a React Element
|
|
424
|
+
$$typeof: i,
|
|
425
|
+
// Built-in properties that belong on the element
|
|
426
|
+
type: e,
|
|
427
|
+
key: t,
|
|
428
|
+
ref: a,
|
|
429
|
+
props: v,
|
|
430
|
+
// Record the component responsible for creating this element.
|
|
431
|
+
_owner: R
|
|
432
|
+
};
|
|
433
|
+
return x._store = {}, Object.defineProperty(x._store, "validated", {
|
|
434
|
+
configurable: !1,
|
|
435
|
+
enumerable: !1,
|
|
436
|
+
writable: !0,
|
|
437
|
+
value: !1
|
|
438
|
+
}), Object.defineProperty(x, "_self", {
|
|
439
|
+
configurable: !1,
|
|
440
|
+
enumerable: !1,
|
|
441
|
+
writable: !1,
|
|
442
|
+
value: d
|
|
443
|
+
}), Object.defineProperty(x, "_source", {
|
|
444
|
+
configurable: !1,
|
|
445
|
+
enumerable: !1,
|
|
446
|
+
writable: !1,
|
|
447
|
+
value: y
|
|
448
|
+
}), Object.freeze && (Object.freeze(x.props), Object.freeze(x)), x;
|
|
449
|
+
};
|
|
450
|
+
function yr(e, t, a, d, y) {
|
|
451
|
+
{
|
|
452
|
+
var R, v = {}, x = null, C = null;
|
|
453
|
+
a !== void 0 && (Le(a), x = "" + a), pr(t) && (Le(t.key), x = "" + t.key), mr(t) && (C = t.ref, hr(t, y));
|
|
454
|
+
for (R in t)
|
|
455
|
+
Z.call(t, R) && !fr.hasOwnProperty(R) && (v[R] = t[R]);
|
|
456
|
+
if (e && e.defaultProps) {
|
|
457
|
+
var T = e.defaultProps;
|
|
458
|
+
for (R in T)
|
|
459
|
+
v[R] === void 0 && (v[R] = T[R]);
|
|
460
|
+
}
|
|
461
|
+
if (x || C) {
|
|
462
|
+
var P = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
|
|
463
|
+
x && xr(v, P), C && vr(v, P);
|
|
464
|
+
}
|
|
465
|
+
return gr(e, x, C, y, d, Ye.current, v);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
var ve = q.ReactCurrentOwner, We = q.ReactDebugCurrentFrame;
|
|
469
|
+
function M(e) {
|
|
470
|
+
if (e) {
|
|
471
|
+
var t = e._owner, a = le(e.type, e._source, t ? t.type : null);
|
|
472
|
+
We.setExtraStackFrame(a);
|
|
473
|
+
} else
|
|
474
|
+
We.setExtraStackFrame(null);
|
|
475
|
+
}
|
|
476
|
+
var ge;
|
|
477
|
+
ge = !1;
|
|
478
|
+
function ye(e) {
|
|
479
|
+
return typeof e == "object" && e !== null && e.$$typeof === i;
|
|
480
|
+
}
|
|
481
|
+
function Be() {
|
|
482
|
+
{
|
|
483
|
+
if (ve.current) {
|
|
484
|
+
var e = B(ve.current.type);
|
|
485
|
+
if (e)
|
|
486
|
+
return `
|
|
487
|
+
|
|
488
|
+
Check the render method of \`` + e + "`.";
|
|
489
|
+
}
|
|
490
|
+
return "";
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
function jr(e) {
|
|
494
|
+
return "";
|
|
495
|
+
}
|
|
496
|
+
var Ue = {};
|
|
497
|
+
function br(e) {
|
|
498
|
+
{
|
|
499
|
+
var t = Be();
|
|
500
|
+
if (!t) {
|
|
501
|
+
var a = typeof e == "string" ? e : e.displayName || e.name;
|
|
502
|
+
a && (t = `
|
|
503
|
+
|
|
504
|
+
Check the top-level render call using <` + a + ">.");
|
|
505
|
+
}
|
|
506
|
+
return t;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
function Ke(e, t) {
|
|
510
|
+
{
|
|
511
|
+
if (!e._store || e._store.validated || e.key != null)
|
|
512
|
+
return;
|
|
513
|
+
e._store.validated = !0;
|
|
514
|
+
var a = br(t);
|
|
515
|
+
if (Ue[a])
|
|
516
|
+
return;
|
|
517
|
+
Ue[a] = !0;
|
|
518
|
+
var d = "";
|
|
519
|
+
e && e._owner && e._owner !== ve.current && (d = " It was passed a child from " + B(e._owner.type) + "."), M(e), j('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', a, d), M(null);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
function Me(e, t) {
|
|
523
|
+
{
|
|
524
|
+
if (typeof e != "object")
|
|
525
|
+
return;
|
|
526
|
+
if (xe(e))
|
|
527
|
+
for (var a = 0; a < e.length; a++) {
|
|
528
|
+
var d = e[a];
|
|
529
|
+
ye(d) && Ke(d, t);
|
|
530
|
+
}
|
|
531
|
+
else if (ye(e))
|
|
532
|
+
e._store && (e._store.validated = !0);
|
|
533
|
+
else if (e) {
|
|
534
|
+
var y = V(e);
|
|
535
|
+
if (typeof y == "function" && y !== e.entries)
|
|
536
|
+
for (var R = y.call(e), v; !(v = R.next()).done; )
|
|
537
|
+
ye(v.value) && Ke(v.value, t);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
function wr(e) {
|
|
542
|
+
{
|
|
543
|
+
var t = e.type;
|
|
544
|
+
if (t == null || typeof t == "string")
|
|
545
|
+
return;
|
|
546
|
+
var a;
|
|
547
|
+
if (typeof t == "function")
|
|
548
|
+
a = t.propTypes;
|
|
549
|
+
else if (typeof t == "object" && (t.$$typeof === u || // Note: Memo only checks outer props here.
|
|
550
|
+
// Inner props are checked in the reconciler.
|
|
551
|
+
t.$$typeof === w))
|
|
552
|
+
a = t.propTypes;
|
|
553
|
+
else
|
|
554
|
+
return;
|
|
555
|
+
if (a) {
|
|
556
|
+
var d = B(t);
|
|
557
|
+
lr(a, e.props, "prop", d, e);
|
|
558
|
+
} else if (t.PropTypes !== void 0 && !ge) {
|
|
559
|
+
ge = !0;
|
|
560
|
+
var y = B(t);
|
|
561
|
+
j("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", y || "Unknown");
|
|
562
|
+
}
|
|
563
|
+
typeof t.getDefaultProps == "function" && !t.getDefaultProps.isReactClassApproved && j("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
function Rr(e) {
|
|
567
|
+
{
|
|
568
|
+
for (var t = Object.keys(e.props), a = 0; a < t.length; a++) {
|
|
569
|
+
var d = t[a];
|
|
570
|
+
if (d !== "children" && d !== "key") {
|
|
571
|
+
M(e), j("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", d), M(null);
|
|
572
|
+
break;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
e.ref !== null && (M(e), j("Invalid attribute `ref` supplied to `React.Fragment`."), M(null));
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
var Ge = {};
|
|
579
|
+
function Je(e, t, a, d, y, R) {
|
|
580
|
+
{
|
|
581
|
+
var v = rr(e);
|
|
582
|
+
if (!v) {
|
|
583
|
+
var x = "";
|
|
584
|
+
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (x += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
|
|
585
|
+
var C = jr();
|
|
586
|
+
C ? x += C : x += Be();
|
|
587
|
+
var T;
|
|
588
|
+
e === null ? T = "null" : xe(e) ? T = "array" : e !== void 0 && e.$$typeof === i ? (T = "<" + (B(e.type) || "Unknown") + " />", x = " Did you accidentally export a JSX literal instead of a component?") : T = typeof e, j("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", T, x);
|
|
589
|
+
}
|
|
590
|
+
var P = yr(e, t, a, y, R);
|
|
591
|
+
if (P == null)
|
|
592
|
+
return P;
|
|
593
|
+
if (v) {
|
|
594
|
+
var I = t.children;
|
|
595
|
+
if (I !== void 0)
|
|
596
|
+
if (d)
|
|
597
|
+
if (xe(I)) {
|
|
598
|
+
for (var G = 0; G < I.length; G++)
|
|
599
|
+
Me(I[G], e);
|
|
600
|
+
Object.freeze && Object.freeze(I);
|
|
601
|
+
} else
|
|
602
|
+
j("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
603
|
+
else
|
|
604
|
+
Me(I, e);
|
|
605
|
+
}
|
|
606
|
+
if (Z.call(t, "key")) {
|
|
607
|
+
var K = B(e), F = Object.keys(t).filter(function(kr) {
|
|
608
|
+
return kr !== "key";
|
|
609
|
+
}), je = F.length > 0 ? "{key: someKey, " + F.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
610
|
+
if (!Ge[K + je]) {
|
|
611
|
+
var Pr = F.length > 0 ? "{" + F.join(": ..., ") + ": ...}" : "{}";
|
|
612
|
+
j(`A props object containing a "key" prop is being spread into JSX:
|
|
613
|
+
let props = %s;
|
|
614
|
+
<%s {...props} />
|
|
615
|
+
React keys must be passed directly to JSX without using spread:
|
|
616
|
+
let props = %s;
|
|
617
|
+
<%s key={someKey} {...props} />`, je, K, Pr, K), Ge[K + je] = !0;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return e === o ? Rr(P) : wr(P), P;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
function Er(e, t, a) {
|
|
624
|
+
return Je(e, t, a, !0);
|
|
625
|
+
}
|
|
626
|
+
function Sr(e, t, a) {
|
|
627
|
+
return Je(e, t, a, !1);
|
|
628
|
+
}
|
|
629
|
+
var _r = Sr, Tr = Er;
|
|
630
|
+
ee.Fragment = o, ee.jsx = _r, ee.jsxs = Tr;
|
|
631
|
+
}()), ee;
|
|
632
|
+
}
|
|
633
|
+
process.env.NODE_ENV === "production" ? Re.exports = Lr() : Re.exports = Yr();
|
|
634
|
+
var r = Re.exports;
|
|
635
|
+
const er = Or({}), Hr = ({ children: s }) => {
|
|
636
|
+
const [i, l] = be({}), [o, m] = be(void 0);
|
|
637
|
+
return /* @__PURE__ */ r.jsx(er.Provider, { value: { auth: i, setAuth: l, user: o, setUser: m }, children: s });
|
|
638
|
+
}, ne = () => {
|
|
639
|
+
const s = Cr(er);
|
|
640
|
+
if (!s)
|
|
641
|
+
throw new Error("useAuth must be used within an AuthProvider");
|
|
642
|
+
return s;
|
|
643
|
+
}, Nr = (s, i = "refresh") => {
|
|
644
|
+
const { setAuth: l } = ne(), o = () => s({ method: "GET", url: i }), { refetch: m } = Ee({
|
|
645
|
+
queryKey: ["refresh"],
|
|
646
|
+
queryFn: o,
|
|
647
|
+
onSuccess: (f) => {
|
|
648
|
+
l((p) => {
|
|
649
|
+
var n;
|
|
650
|
+
return { ...p, accessToken: (n = f == null ? void 0 : f.data) == null ? void 0 : n.accessToken };
|
|
651
|
+
});
|
|
652
|
+
},
|
|
653
|
+
onError: (f) => {
|
|
654
|
+
console.log("Refresh Failed", f);
|
|
655
|
+
},
|
|
656
|
+
enabled: !1,
|
|
657
|
+
retry: !1
|
|
658
|
+
});
|
|
659
|
+
return m;
|
|
660
|
+
}, Zr = (s, i = "refresh") => {
|
|
661
|
+
const { auth: l, setAuth: o } = ne(), m = Nr(s, i);
|
|
662
|
+
return we(() => {
|
|
663
|
+
const f = s.interceptors.request.use(
|
|
664
|
+
(n) => (n.headers.authorization || (n.headers.authorization = `Bearer ${l == null ? void 0 : l.accessToken}`), n),
|
|
665
|
+
(n) => Promise.reject(n)
|
|
666
|
+
), p = s.interceptors.response.use(
|
|
667
|
+
(n) => n,
|
|
668
|
+
async (n) => {
|
|
669
|
+
var h, c, w, E, S;
|
|
670
|
+
const u = n == null ? void 0 : n.config;
|
|
671
|
+
if ((c = (h = n == null ? void 0 : n.response) == null ? void 0 : h.data) != null && c.error && (n.message = `${n.response.data.error} (${n.response.status})`), u.url === i)
|
|
672
|
+
return Promise.reject(n);
|
|
673
|
+
if (((w = n == null ? void 0 : n.response) == null ? void 0 : w.status) === 403 && !(u != null && u.sent)) {
|
|
674
|
+
u.sent = !0;
|
|
675
|
+
try {
|
|
676
|
+
const _ = await m(), A = (S = (E = _ == null ? void 0 : _.data) == null ? void 0 : E.data) == null ? void 0 : S.accessToken;
|
|
677
|
+
return A ? (u.headers.authorization = `Bearer ${A}`, s(u)) : (o({ message: "Session expired. Please login again." }), Promise.reject(n));
|
|
678
|
+
} catch (_) {
|
|
679
|
+
return o({ message: "Session expired. Please login again." }), Promise.reject(_);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
return Promise.reject(n);
|
|
683
|
+
}
|
|
684
|
+
);
|
|
685
|
+
return () => {
|
|
686
|
+
s.interceptors.request.eject(f), s.interceptors.response.eject(p);
|
|
687
|
+
};
|
|
688
|
+
}, [l, m, s, i, o]), s;
|
|
689
|
+
}, Qr = (s, i = "auth") => de({
|
|
690
|
+
mutationFn: (l) => s({
|
|
691
|
+
url: i,
|
|
692
|
+
method: "POST",
|
|
693
|
+
data: l
|
|
694
|
+
}),
|
|
695
|
+
mutationKey: ["login"]
|
|
696
|
+
}), et = ({
|
|
697
|
+
allowedPerms: s,
|
|
698
|
+
unauthorizedPath: i = "/unauthorized",
|
|
699
|
+
loginPath: l = "/"
|
|
700
|
+
}) => {
|
|
701
|
+
var p;
|
|
702
|
+
const { auth: o } = ne(), m = Ar();
|
|
703
|
+
return ((p = o == null ? void 0 : o.permissions) == null ? void 0 : p.some((n) => s == null ? void 0 : s.includes(n.perm_key))) ? /* @__PURE__ */ r.jsx(qr, {}) : o != null && o.email ? /* @__PURE__ */ r.jsx(ce, { to: i, state: { from: m }, replace: !0 }) : /* @__PURE__ */ r.jsx(ce, { to: l, state: { from: m }, replace: !0 });
|
|
704
|
+
}, rt = ({
|
|
705
|
+
LoginComponent: s,
|
|
706
|
+
RegisterComponent: i,
|
|
707
|
+
UnauthorizedComponent: l,
|
|
708
|
+
LayoutComponent: o = ({ children: n }) => /* @__PURE__ */ r.jsx(r.Fragment, { children: n }),
|
|
709
|
+
postLoginRedirect: m = "/",
|
|
710
|
+
children: f,
|
|
711
|
+
publicRoutes: p = []
|
|
712
|
+
}) => {
|
|
713
|
+
const { auth: n } = ne(), u = !!n.email;
|
|
714
|
+
return /* @__PURE__ */ r.jsxs(Fr, { children: [
|
|
715
|
+
p.map(({ path: h, element: c }) => /* @__PURE__ */ r.jsx(W, { element: /* @__PURE__ */ r.jsx(o, {}), children: /* @__PURE__ */ r.jsx(W, { path: h, element: c }) }, h)),
|
|
716
|
+
u ? /* @__PURE__ */ r.jsxs(W, { element: /* @__PURE__ */ r.jsx(o, {}), children: [
|
|
717
|
+
f,
|
|
718
|
+
/* @__PURE__ */ r.jsx(W, { path: "/unauthorized", element: /* @__PURE__ */ r.jsx(l, {}) }),
|
|
719
|
+
/* @__PURE__ */ r.jsx(W, { path: "*", element: /* @__PURE__ */ r.jsx(ce, { to: m, replace: !0 }) })
|
|
720
|
+
] }) : /* @__PURE__ */ r.jsxs(W, { element: /* @__PURE__ */ r.jsx(o, {}), children: [
|
|
721
|
+
/* @__PURE__ */ r.jsx(W, { path: "/login", element: /* @__PURE__ */ r.jsx(s, { successRoute: m }) }),
|
|
722
|
+
/* @__PURE__ */ r.jsx(W, { path: "/register", element: /* @__PURE__ */ r.jsx(i, {}) }),
|
|
723
|
+
/* @__PURE__ */ r.jsx(W, { path: "*", element: /* @__PURE__ */ r.jsx(ce, { to: "/login", replace: !0 }) })
|
|
724
|
+
] })
|
|
725
|
+
] });
|
|
726
|
+
}, tt = ({
|
|
727
|
+
loginMutation: s,
|
|
728
|
+
// result of useLogin hook
|
|
729
|
+
successRoute: i = "/",
|
|
730
|
+
registerPath: l = "/register",
|
|
731
|
+
resetPath: o = "/forgot-password",
|
|
732
|
+
allowStay: m = !1,
|
|
733
|
+
onLoginSuccess: f
|
|
734
|
+
}) => {
|
|
735
|
+
var V, q;
|
|
736
|
+
const [p, n] = be(""), { auth: u, setAuth: h } = ne(), c = Qe(), w = te({
|
|
737
|
+
defaultValues: {
|
|
738
|
+
email: "",
|
|
739
|
+
password: "",
|
|
740
|
+
stayLoggedIn: !1
|
|
741
|
+
}
|
|
742
|
+
}), { handleSubmit: E, register: S, formState: { errors: _ } } = w, A = (j) => {
|
|
743
|
+
n(""), s.mutate(j);
|
|
744
|
+
};
|
|
745
|
+
return we(() => {
|
|
746
|
+
var j, N;
|
|
747
|
+
if (s.isSuccess) {
|
|
748
|
+
n("");
|
|
749
|
+
try {
|
|
750
|
+
const $ = (N = (j = s.data) == null ? void 0 : j.data) == null ? void 0 : N.accessToken, O = Vr($);
|
|
751
|
+
if (O.status !== "ACTIVE") {
|
|
752
|
+
n("Successful login... but user is not Active. See system administrator");
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
const z = {
|
|
756
|
+
userId: O.userId,
|
|
757
|
+
email: O.email,
|
|
758
|
+
first: O.first,
|
|
759
|
+
last: O.last,
|
|
760
|
+
status: O.status,
|
|
761
|
+
permissions: O.permissions,
|
|
762
|
+
accessToken: $
|
|
763
|
+
};
|
|
764
|
+
h(z), f && f(z), c(i);
|
|
765
|
+
} catch ($) {
|
|
766
|
+
console.error("Token decoding error:", $), n("Error processing login response");
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
}, [s.isSuccess, s.data, c, h, i, f]), we(() => {
|
|
770
|
+
var j, N, $, O;
|
|
771
|
+
if (s.isError) {
|
|
772
|
+
const z = (($ = (N = (j = s.error) == null ? void 0 : j.response) == null ? void 0 : N.data) == null ? void 0 : $.error) || ((O = s.error) == null ? void 0 : O.message);
|
|
773
|
+
n(z);
|
|
774
|
+
}
|
|
775
|
+
}, [s.isError, s.error]), /* @__PURE__ */ r.jsxs(b, { sx: { width: { xs: "90%", md: "33%" }, margin: "auto", padding: "20px" }, children: [
|
|
776
|
+
s.isLoading && /* @__PURE__ */ r.jsx(Y, { severity: "info", children: "Logging on to system..." }),
|
|
777
|
+
p && /* @__PURE__ */ r.jsx(Y, { severity: "error", children: p }),
|
|
778
|
+
/* @__PURE__ */ r.jsx(g, { variant: "h5", children: "Login" }),
|
|
779
|
+
/* @__PURE__ */ r.jsx("form", { onSubmit: E(A), noValidate: !0, children: /* @__PURE__ */ r.jsxs(J, { spacing: 2, children: [
|
|
780
|
+
/* @__PURE__ */ r.jsx(
|
|
781
|
+
L,
|
|
782
|
+
{
|
|
783
|
+
...S("email"),
|
|
784
|
+
label: "Email",
|
|
785
|
+
type: "email",
|
|
786
|
+
placeholder: "Enter email",
|
|
787
|
+
margin: "normal",
|
|
788
|
+
size: "small",
|
|
789
|
+
error: !!_.email,
|
|
790
|
+
helperText: (V = _.email) == null ? void 0 : V.message
|
|
791
|
+
}
|
|
792
|
+
),
|
|
793
|
+
/* @__PURE__ */ r.jsx(
|
|
794
|
+
L,
|
|
795
|
+
{
|
|
796
|
+
...S("password"),
|
|
797
|
+
label: "Password",
|
|
798
|
+
type: "password",
|
|
799
|
+
placeholder: "Enter password",
|
|
800
|
+
margin: "normal",
|
|
801
|
+
size: "small",
|
|
802
|
+
error: !!_.password,
|
|
803
|
+
helperText: (q = _.password) == null ? void 0 : q.message
|
|
804
|
+
}
|
|
805
|
+
),
|
|
806
|
+
/* @__PURE__ */ r.jsx(b, { sx: { mt: 2 }, children: /* @__PURE__ */ r.jsx(D, { style: { textDecoration: "underline" }, to: o, children: "Reset Password" }) }),
|
|
807
|
+
/* @__PURE__ */ r.jsx(se, { sx: { margin: "10px" }, variant: "outlined", type: "submit", children: "Submit" })
|
|
808
|
+
] }) }),
|
|
809
|
+
/* @__PURE__ */ r.jsx(b, { sx: { mt: 2 }, children: /* @__PURE__ */ r.jsx(D, { style: { textDecoration: "underline" }, to: l, children: "Register to Login" }) })
|
|
810
|
+
] });
|
|
811
|
+
};
|
|
812
|
+
function fe(s, i, l) {
|
|
813
|
+
return i === void 0 && (i = {}), l === void 0 && (l = {}), function(o, m, f) {
|
|
814
|
+
try {
|
|
815
|
+
return Promise.resolve(function(p, n) {
|
|
816
|
+
try {
|
|
817
|
+
var u = (i.context && process.env.NODE_ENV === "development" && console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"), Promise.resolve(s[l.mode === "sync" ? "validateSync" : "validate"](o, Object.assign({ abortEarly: !1 }, i, { context: m }))).then(function(h) {
|
|
818
|
+
return f.shouldUseNativeValidation && $r({}, f), { values: l.raw ? o : h, errors: {} };
|
|
819
|
+
}));
|
|
820
|
+
} catch (h) {
|
|
821
|
+
return n(h);
|
|
822
|
+
}
|
|
823
|
+
return u && u.then ? u.then(void 0, n) : u;
|
|
824
|
+
}(0, function(p) {
|
|
825
|
+
if (!p.inner) throw p;
|
|
826
|
+
return { values: {}, errors: Ir((n = p, u = !f.shouldUseNativeValidation && f.criteriaMode === "all", (n.inner || []).reduce(function(h, c) {
|
|
827
|
+
if (h[c.path] || (h[c.path] = { message: c.message, type: c.type }), u) {
|
|
828
|
+
var w = h[c.path].types, E = w && w[c.type];
|
|
829
|
+
h[c.path] = Dr(c.path, u, h, c.type, E ? [].concat(E, c.message) : c.message);
|
|
830
|
+
}
|
|
831
|
+
return h;
|
|
832
|
+
}, {})), f) };
|
|
833
|
+
var n, u;
|
|
834
|
+
}));
|
|
835
|
+
} catch (p) {
|
|
836
|
+
return Promise.reject(p);
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
const st = ({
|
|
841
|
+
onSubmit: s,
|
|
842
|
+
loginPath: i = "/login"
|
|
843
|
+
}) => {
|
|
844
|
+
var c, w, E;
|
|
845
|
+
Qe();
|
|
846
|
+
const l = /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%]).{8,24}$/, m = k.object().shape({
|
|
847
|
+
email: k.string().email("Invalid email").required("Required"),
|
|
848
|
+
password: k.string().matches(l, "8 - 24 characters, must include uppercase and lowercase letters, a number and a special character").required("Required"),
|
|
849
|
+
confirmPwd: k.string().oneOf([k.ref("password"), null], "Passwords must match").required("Required")
|
|
850
|
+
}), f = te({
|
|
851
|
+
defaultValues: {
|
|
852
|
+
email: "",
|
|
853
|
+
password: "",
|
|
854
|
+
confirmPwd: ""
|
|
855
|
+
},
|
|
856
|
+
resolver: fe(m)
|
|
857
|
+
}), { handleSubmit: p, register: n, formState: { errors: u } } = f, h = (S) => {
|
|
858
|
+
s ? s(S) : console.log("Registration submitted:", S);
|
|
859
|
+
};
|
|
860
|
+
return /* @__PURE__ */ r.jsxs(b, { sx: { width: { xs: "90%", md: "33%" }, margin: "auto", padding: "20px" }, children: [
|
|
861
|
+
/* @__PURE__ */ r.jsx(g, { variant: "h5", children: "Register" }),
|
|
862
|
+
/* @__PURE__ */ r.jsx("form", { onSubmit: p(h), noValidate: !0, children: /* @__PURE__ */ r.jsxs(J, { spacing: 2, children: [
|
|
863
|
+
/* @__PURE__ */ r.jsx(
|
|
864
|
+
L,
|
|
865
|
+
{
|
|
866
|
+
...n("email"),
|
|
867
|
+
label: "Email",
|
|
868
|
+
type: "email",
|
|
869
|
+
placeholder: "Enter email",
|
|
870
|
+
margin: "normal",
|
|
871
|
+
size: "small",
|
|
872
|
+
error: !!u.email,
|
|
873
|
+
helperText: (c = u.email) == null ? void 0 : c.message
|
|
874
|
+
}
|
|
875
|
+
),
|
|
876
|
+
/* @__PURE__ */ r.jsx(
|
|
877
|
+
L,
|
|
878
|
+
{
|
|
879
|
+
...n("password"),
|
|
880
|
+
label: "Password",
|
|
881
|
+
type: "password",
|
|
882
|
+
placeholder: "Enter password",
|
|
883
|
+
margin: "normal",
|
|
884
|
+
size: "small",
|
|
885
|
+
error: !!u.password,
|
|
886
|
+
helperText: (w = u.password) == null ? void 0 : w.message
|
|
887
|
+
}
|
|
888
|
+
),
|
|
889
|
+
/* @__PURE__ */ r.jsx(
|
|
890
|
+
L,
|
|
891
|
+
{
|
|
892
|
+
...n("confirmPwd"),
|
|
893
|
+
label: "Confirm Password",
|
|
894
|
+
type: "password",
|
|
895
|
+
placeholder: "Re-enter Password",
|
|
896
|
+
margin: "normal",
|
|
897
|
+
size: "small",
|
|
898
|
+
error: !!u.confirmPwd,
|
|
899
|
+
helperText: (E = u.confirmPwd) == null ? void 0 : E.message
|
|
900
|
+
}
|
|
901
|
+
),
|
|
902
|
+
/* @__PURE__ */ r.jsx(se, { sx: { margin: "10px" }, variant: "outlined", type: "submit", children: "Submit" })
|
|
903
|
+
] }) }),
|
|
904
|
+
/* @__PURE__ */ r.jsx(b, { sx: { mt: 2 }, children: /* @__PURE__ */ r.jsx(D, { style: { textDecoration: "underline" }, to: i, children: "Login if already a user" }) })
|
|
905
|
+
] });
|
|
906
|
+
}, nt = () => /* @__PURE__ */ r.jsxs(
|
|
907
|
+
J,
|
|
908
|
+
{
|
|
909
|
+
sx: {
|
|
910
|
+
margin: "10vh",
|
|
911
|
+
alignItems: "center"
|
|
912
|
+
},
|
|
913
|
+
children: [
|
|
914
|
+
/* @__PURE__ */ r.jsx(g, { variant: "h4", children: "You are not authorized to access this page." }),
|
|
915
|
+
/* @__PURE__ */ r.jsx("br", {}),
|
|
916
|
+
/* @__PURE__ */ r.jsx("br", {}),
|
|
917
|
+
/* @__PURE__ */ r.jsx(g, { variant: "h5", children: "Contact your system administrator for access rights." })
|
|
918
|
+
]
|
|
919
|
+
}
|
|
920
|
+
), at = ({
|
|
921
|
+
onSubmit: s,
|
|
922
|
+
isLoading: i = !1,
|
|
923
|
+
isSuccess: l = !1,
|
|
924
|
+
successMessage: o = "If this email is not already registered, you will receive a verification email shortly.",
|
|
925
|
+
error: m,
|
|
926
|
+
loginPath: f = "/login"
|
|
927
|
+
}) => {
|
|
928
|
+
var E, S, _, A, V, q;
|
|
929
|
+
const p = k.object().shape({
|
|
930
|
+
email: k.string().email("Invalid email").required("Email is required"),
|
|
931
|
+
first: k.string().required("First name is required"),
|
|
932
|
+
last: k.string().required("Last name is required"),
|
|
933
|
+
requestNote: k.string().max(256, "Request note must be 256 characters or less")
|
|
934
|
+
}), n = te({
|
|
935
|
+
defaultValues: {
|
|
936
|
+
email: "",
|
|
937
|
+
first: "",
|
|
938
|
+
last: "",
|
|
939
|
+
requestNote: ""
|
|
940
|
+
},
|
|
941
|
+
resolver: fe(p)
|
|
942
|
+
}), { handleSubmit: u, register: h, formState: { errors: c } } = n, w = (j) => {
|
|
943
|
+
s && s(j);
|
|
944
|
+
};
|
|
945
|
+
return l ? /* @__PURE__ */ r.jsxs(b, { sx: { width: { xs: "90%", md: "50%" }, margin: "auto", padding: "20px" }, children: [
|
|
946
|
+
/* @__PURE__ */ r.jsx(g, { variant: "h5", gutterBottom: !0, children: "Registration Submitted" }),
|
|
947
|
+
/* @__PURE__ */ r.jsx(Y, { severity: "success", sx: { mb: 2 }, children: o }),
|
|
948
|
+
/* @__PURE__ */ r.jsx(g, { variant: "body1", paragraph: !0, children: "Please check your email for a verification link. The link will expire in 24 hours." }),
|
|
949
|
+
/* @__PURE__ */ r.jsx(g, { variant: "body2", color: "text.secondary", children: "If you don't receive an email within a few minutes, check your spam folder." }),
|
|
950
|
+
/* @__PURE__ */ r.jsx(b, { sx: { mt: 3 }, children: /* @__PURE__ */ r.jsx(D, { style: { textDecoration: "underline" }, to: f, children: "Return to Login" }) })
|
|
951
|
+
] }) : /* @__PURE__ */ r.jsxs(b, { sx: { width: { xs: "90%", md: "50%" }, margin: "auto", padding: "20px" }, children: [
|
|
952
|
+
/* @__PURE__ */ r.jsx(g, { variant: "h5", gutterBottom: !0, children: "Request Access" }),
|
|
953
|
+
/* @__PURE__ */ r.jsx(g, { variant: "body2", color: "text.secondary", sx: { mb: 2 }, children: "Fill out this form to request access. An administrator will review your request after you verify your email." }),
|
|
954
|
+
m && /* @__PURE__ */ r.jsx(Y, { severity: "error", sx: { mb: 2 }, children: ((S = (E = m.response) == null ? void 0 : E.data) == null ? void 0 : S.error) || m.message || "An error occurred" }),
|
|
955
|
+
/* @__PURE__ */ r.jsx("form", { onSubmit: u(w), noValidate: !0, children: /* @__PURE__ */ r.jsxs(J, { spacing: 2, children: [
|
|
956
|
+
/* @__PURE__ */ r.jsx(
|
|
957
|
+
L,
|
|
958
|
+
{
|
|
959
|
+
...h("email"),
|
|
960
|
+
label: "Email",
|
|
961
|
+
type: "email",
|
|
962
|
+
placeholder: "Enter your email",
|
|
963
|
+
margin: "normal",
|
|
964
|
+
size: "small",
|
|
965
|
+
required: !0,
|
|
966
|
+
error: !!c.email,
|
|
967
|
+
helperText: (_ = c.email) == null ? void 0 : _.message
|
|
968
|
+
}
|
|
969
|
+
),
|
|
970
|
+
/* @__PURE__ */ r.jsx(
|
|
971
|
+
L,
|
|
972
|
+
{
|
|
973
|
+
...h("first"),
|
|
974
|
+
label: "First Name",
|
|
975
|
+
type: "text",
|
|
976
|
+
placeholder: "Enter your first name",
|
|
977
|
+
margin: "normal",
|
|
978
|
+
size: "small",
|
|
979
|
+
required: !0,
|
|
980
|
+
error: !!c.first,
|
|
981
|
+
helperText: (A = c.first) == null ? void 0 : A.message
|
|
982
|
+
}
|
|
983
|
+
),
|
|
984
|
+
/* @__PURE__ */ r.jsx(
|
|
985
|
+
L,
|
|
986
|
+
{
|
|
987
|
+
...h("last"),
|
|
988
|
+
label: "Last Name",
|
|
989
|
+
type: "text",
|
|
990
|
+
placeholder: "Enter your last name",
|
|
991
|
+
margin: "normal",
|
|
992
|
+
size: "small",
|
|
993
|
+
required: !0,
|
|
994
|
+
error: !!c.last,
|
|
995
|
+
helperText: (V = c.last) == null ? void 0 : V.message
|
|
996
|
+
}
|
|
997
|
+
),
|
|
998
|
+
/* @__PURE__ */ r.jsx(
|
|
999
|
+
L,
|
|
1000
|
+
{
|
|
1001
|
+
...h("requestNote"),
|
|
1002
|
+
label: "Request Note (Optional)",
|
|
1003
|
+
type: "text",
|
|
1004
|
+
placeholder: "Why do you need access?",
|
|
1005
|
+
margin: "normal",
|
|
1006
|
+
size: "small",
|
|
1007
|
+
multiline: !0,
|
|
1008
|
+
rows: 3,
|
|
1009
|
+
error: !!c.requestNote,
|
|
1010
|
+
helperText: ((q = c.requestNote) == null ? void 0 : q.message) || "Max 256 characters"
|
|
1011
|
+
}
|
|
1012
|
+
),
|
|
1013
|
+
/* @__PURE__ */ r.jsx(
|
|
1014
|
+
se,
|
|
1015
|
+
{
|
|
1016
|
+
sx: { margin: "10px" },
|
|
1017
|
+
variant: "contained",
|
|
1018
|
+
type: "submit",
|
|
1019
|
+
disabled: i,
|
|
1020
|
+
children: i ? /* @__PURE__ */ r.jsx(re, { size: 24 }) : "Submit Request"
|
|
1021
|
+
}
|
|
1022
|
+
)
|
|
1023
|
+
] }) }),
|
|
1024
|
+
/* @__PURE__ */ r.jsx(b, { sx: { mt: 2 }, children: /* @__PURE__ */ r.jsx(D, { style: { textDecoration: "underline" }, to: f, children: "Already have an account? Login" }) })
|
|
1025
|
+
] });
|
|
1026
|
+
}, it = ({
|
|
1027
|
+
isLoading: s = !1,
|
|
1028
|
+
isSuccess: i = !1,
|
|
1029
|
+
isError: l = !1,
|
|
1030
|
+
error: o,
|
|
1031
|
+
data: m,
|
|
1032
|
+
loginPath: f = "/login"
|
|
1033
|
+
}) => {
|
|
1034
|
+
var p, n;
|
|
1035
|
+
if (s)
|
|
1036
|
+
return /* @__PURE__ */ r.jsxs(b, { sx: { width: { xs: "90%", md: "50%" }, margin: "auto", padding: "20px", textAlign: "center" }, children: [
|
|
1037
|
+
/* @__PURE__ */ r.jsx(re, { size: 48, sx: { mb: 2 } }),
|
|
1038
|
+
/* @__PURE__ */ r.jsx(g, { variant: "h6", children: "Verifying your email..." })
|
|
1039
|
+
] });
|
|
1040
|
+
if (l) {
|
|
1041
|
+
const u = ((n = (p = o == null ? void 0 : o.response) == null ? void 0 : p.data) == null ? void 0 : n.error) || (o == null ? void 0 : o.message) || "Verification failed";
|
|
1042
|
+
return /* @__PURE__ */ r.jsxs(b, { sx: { width: { xs: "90%", md: "50%" }, margin: "auto", padding: "20px" }, children: [
|
|
1043
|
+
/* @__PURE__ */ r.jsx(g, { variant: "h5", gutterBottom: !0, children: "Verification Failed" }),
|
|
1044
|
+
/* @__PURE__ */ r.jsx(Y, { severity: "error", sx: { mb: 2 }, children: u }),
|
|
1045
|
+
/* @__PURE__ */ r.jsx(g, { variant: "body1", paragraph: !0, children: "The verification link may have expired or already been used." }),
|
|
1046
|
+
/* @__PURE__ */ r.jsx(g, { variant: "body2", color: "text.secondary", children: "If you need a new verification link, please submit a new registration request." }),
|
|
1047
|
+
/* @__PURE__ */ r.jsxs(b, { sx: { mt: 3 }, children: [
|
|
1048
|
+
/* @__PURE__ */ r.jsx(D, { style: { textDecoration: "underline" }, to: "/register", children: "Submit New Request" }),
|
|
1049
|
+
/* @__PURE__ */ r.jsx(b, { component: "span", sx: { mx: 2 }, children: "|" }),
|
|
1050
|
+
/* @__PURE__ */ r.jsx(D, { style: { textDecoration: "underline" }, to: f, children: "Return to Login" })
|
|
1051
|
+
] })
|
|
1052
|
+
] });
|
|
1053
|
+
}
|
|
1054
|
+
return i ? /* @__PURE__ */ r.jsxs(b, { sx: { width: { xs: "90%", md: "50%" }, margin: "auto", padding: "20px" }, children: [
|
|
1055
|
+
/* @__PURE__ */ r.jsx(g, { variant: "h5", gutterBottom: !0, children: "Email Verified" }),
|
|
1056
|
+
/* @__PURE__ */ r.jsx(Y, { severity: "success", sx: { mb: 2 }, children: (m == null ? void 0 : m.message) || "Your email has been verified successfully." }),
|
|
1057
|
+
/* @__PURE__ */ r.jsx(g, { variant: "body1", paragraph: !0, children: "Your request is now pending administrator review." }),
|
|
1058
|
+
/* @__PURE__ */ r.jsx(g, { variant: "body2", color: "text.secondary", children: "You will receive an email when your request has been reviewed. This typically takes 1-2 business days." }),
|
|
1059
|
+
/* @__PURE__ */ r.jsx(b, { sx: { mt: 3 }, children: /* @__PURE__ */ r.jsx(D, { style: { textDecoration: "underline" }, to: f, children: "Return to Login" }) })
|
|
1060
|
+
] }) : /* @__PURE__ */ r.jsx(b, { sx: { width: { xs: "90%", md: "50%" }, margin: "auto", padding: "20px", textAlign: "center" }, children: /* @__PURE__ */ r.jsx(g, { variant: "h6", children: "Processing verification..." }) });
|
|
1061
|
+
}, ot = ({
|
|
1062
|
+
isValidating: s = !1,
|
|
1063
|
+
isValidToken: i = !1,
|
|
1064
|
+
validationError: l,
|
|
1065
|
+
userEmail: o,
|
|
1066
|
+
userFirst: m,
|
|
1067
|
+
onSubmit: f,
|
|
1068
|
+
isSubmitting: p = !1,
|
|
1069
|
+
isSuccess: n = !1,
|
|
1070
|
+
submitError: u,
|
|
1071
|
+
loginPath: h = "/login",
|
|
1072
|
+
passwordRegex: c = /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%]).{8,24}$/,
|
|
1073
|
+
passwordMessage: w = "8-24 characters, must include uppercase and lowercase letters, a number and a special character (!@#$%)"
|
|
1074
|
+
}) => {
|
|
1075
|
+
var j, N, $, O, z, ae;
|
|
1076
|
+
const E = k.object().shape({
|
|
1077
|
+
password: k.string().matches(c, w).required("Password is required"),
|
|
1078
|
+
confirmPassword: k.string().oneOf([k.ref("password"), null], "Passwords must match").required("Please confirm your password")
|
|
1079
|
+
}), S = te({
|
|
1080
|
+
defaultValues: {
|
|
1081
|
+
password: "",
|
|
1082
|
+
confirmPassword: ""
|
|
1083
|
+
},
|
|
1084
|
+
resolver: fe(E)
|
|
1085
|
+
}), { handleSubmit: _, register: A, formState: { errors: V } } = S, q = (X) => {
|
|
1086
|
+
f && f({ password: X.password });
|
|
1087
|
+
};
|
|
1088
|
+
if (s)
|
|
1089
|
+
return /* @__PURE__ */ r.jsxs(b, { sx: { width: { xs: "90%", md: "50%" }, margin: "auto", padding: "20px", textAlign: "center" }, children: [
|
|
1090
|
+
/* @__PURE__ */ r.jsx(re, { size: 48, sx: { mb: 2 } }),
|
|
1091
|
+
/* @__PURE__ */ r.jsx(g, { variant: "h6", children: "Validating your link..." })
|
|
1092
|
+
] });
|
|
1093
|
+
if (!i && !s) {
|
|
1094
|
+
const X = ((N = (j = l == null ? void 0 : l.response) == null ? void 0 : j.data) == null ? void 0 : N.error) || (l == null ? void 0 : l.message) || "Invalid or expired link";
|
|
1095
|
+
return /* @__PURE__ */ r.jsxs(b, { sx: { width: { xs: "90%", md: "50%" }, margin: "auto", padding: "20px" }, children: [
|
|
1096
|
+
/* @__PURE__ */ r.jsx(g, { variant: "h5", gutterBottom: !0, children: "Invalid Link" }),
|
|
1097
|
+
/* @__PURE__ */ r.jsx(Y, { severity: "error", sx: { mb: 2 }, children: X }),
|
|
1098
|
+
/* @__PURE__ */ r.jsx(g, { variant: "body1", paragraph: !0, children: "This password setup link is invalid or has expired." }),
|
|
1099
|
+
/* @__PURE__ */ r.jsx(g, { variant: "body2", color: "text.secondary", children: "If you believe this is an error, please contact an administrator." }),
|
|
1100
|
+
/* @__PURE__ */ r.jsx(b, { sx: { mt: 3 }, children: /* @__PURE__ */ r.jsx(D, { style: { textDecoration: "underline" }, to: h, children: "Return to Login" }) })
|
|
1101
|
+
] });
|
|
1102
|
+
}
|
|
1103
|
+
return n ? /* @__PURE__ */ r.jsxs(b, { sx: { width: { xs: "90%", md: "50%" }, margin: "auto", padding: "20px" }, children: [
|
|
1104
|
+
/* @__PURE__ */ r.jsx(g, { variant: "h5", gutterBottom: !0, children: "Password Set Successfully" }),
|
|
1105
|
+
/* @__PURE__ */ r.jsx(Y, { severity: "success", sx: { mb: 2 }, children: "Your password has been set. You can now log in to your account." }),
|
|
1106
|
+
/* @__PURE__ */ r.jsx(b, { sx: { mt: 3 }, children: /* @__PURE__ */ r.jsx(D, { style: { textDecoration: "underline" }, to: h, children: "Go to Login" }) })
|
|
1107
|
+
] }) : /* @__PURE__ */ r.jsxs(b, { sx: { width: { xs: "90%", md: "50%" }, margin: "auto", padding: "20px" }, children: [
|
|
1108
|
+
/* @__PURE__ */ r.jsx(g, { variant: "h5", gutterBottom: !0, children: "Set Your Password" }),
|
|
1109
|
+
m && /* @__PURE__ */ r.jsxs(g, { variant: "body1", sx: { mb: 1 }, children: [
|
|
1110
|
+
"Welcome, ",
|
|
1111
|
+
m,
|
|
1112
|
+
"!"
|
|
1113
|
+
] }),
|
|
1114
|
+
o && /* @__PURE__ */ r.jsxs(g, { variant: "body2", color: "text.secondary", sx: { mb: 2 }, children: [
|
|
1115
|
+
"Setting password for: ",
|
|
1116
|
+
o
|
|
1117
|
+
] }),
|
|
1118
|
+
u && /* @__PURE__ */ r.jsx(Y, { severity: "error", sx: { mb: 2 }, children: ((O = ($ = u.response) == null ? void 0 : $.data) == null ? void 0 : O.error) || u.message || "An error occurred" }),
|
|
1119
|
+
/* @__PURE__ */ r.jsx("form", { onSubmit: _(q), noValidate: !0, children: /* @__PURE__ */ r.jsxs(J, { spacing: 2, children: [
|
|
1120
|
+
/* @__PURE__ */ r.jsx(
|
|
1121
|
+
L,
|
|
1122
|
+
{
|
|
1123
|
+
...A("password"),
|
|
1124
|
+
label: "Password",
|
|
1125
|
+
type: "password",
|
|
1126
|
+
placeholder: "Enter your password",
|
|
1127
|
+
margin: "normal",
|
|
1128
|
+
size: "small",
|
|
1129
|
+
required: !0,
|
|
1130
|
+
error: !!V.password,
|
|
1131
|
+
helperText: (z = V.password) == null ? void 0 : z.message
|
|
1132
|
+
}
|
|
1133
|
+
),
|
|
1134
|
+
/* @__PURE__ */ r.jsx(g, { variant: "caption", color: "text.secondary", children: w }),
|
|
1135
|
+
/* @__PURE__ */ r.jsx(
|
|
1136
|
+
L,
|
|
1137
|
+
{
|
|
1138
|
+
...A("confirmPassword"),
|
|
1139
|
+
label: "Confirm Password",
|
|
1140
|
+
type: "password",
|
|
1141
|
+
placeholder: "Re-enter your password",
|
|
1142
|
+
margin: "normal",
|
|
1143
|
+
size: "small",
|
|
1144
|
+
required: !0,
|
|
1145
|
+
error: !!V.confirmPassword,
|
|
1146
|
+
helperText: (ae = V.confirmPassword) == null ? void 0 : ae.message
|
|
1147
|
+
}
|
|
1148
|
+
),
|
|
1149
|
+
/* @__PURE__ */ r.jsx(
|
|
1150
|
+
se,
|
|
1151
|
+
{
|
|
1152
|
+
sx: { margin: "10px" },
|
|
1153
|
+
variant: "contained",
|
|
1154
|
+
type: "submit",
|
|
1155
|
+
disabled: p,
|
|
1156
|
+
children: p ? /* @__PURE__ */ r.jsx(re, { size: 24 }) : "Set Password"
|
|
1157
|
+
}
|
|
1158
|
+
)
|
|
1159
|
+
] }) })
|
|
1160
|
+
] });
|
|
1161
|
+
}, lt = ({
|
|
1162
|
+
title: s = "Registration Complete",
|
|
1163
|
+
message: i = "Your account is now active. You can log in with your credentials.",
|
|
1164
|
+
loginPath: l = "/login"
|
|
1165
|
+
}) => /* @__PURE__ */ r.jsxs(b, { sx: { width: { xs: "90%", md: "50%" }, margin: "auto", padding: "20px" }, children: [
|
|
1166
|
+
/* @__PURE__ */ r.jsx(g, { variant: "h5", gutterBottom: !0, children: s }),
|
|
1167
|
+
/* @__PURE__ */ r.jsx(Y, { severity: "success", sx: { mb: 2 }, children: i }),
|
|
1168
|
+
/* @__PURE__ */ r.jsx(b, { sx: { mt: 3 }, children: /* @__PURE__ */ r.jsx(D, { style: { textDecoration: "underline" }, to: l, children: "Go to Login" }) })
|
|
1169
|
+
] }), ut = ({
|
|
1170
|
+
onSubmit: s,
|
|
1171
|
+
isLoading: i = !1,
|
|
1172
|
+
isSuccess: l = !1,
|
|
1173
|
+
successMessage: o = "If an account exists for this email, you will receive a password reset link shortly.",
|
|
1174
|
+
error: m,
|
|
1175
|
+
loginPath: f = "/login"
|
|
1176
|
+
}) => {
|
|
1177
|
+
var E, S, _;
|
|
1178
|
+
const p = k.object().shape({
|
|
1179
|
+
email: k.string().email("Invalid email").required("Email is required")
|
|
1180
|
+
}), n = te({
|
|
1181
|
+
defaultValues: {
|
|
1182
|
+
email: ""
|
|
1183
|
+
},
|
|
1184
|
+
resolver: fe(p)
|
|
1185
|
+
}), { handleSubmit: u, register: h, formState: { errors: c } } = n, w = (A) => {
|
|
1186
|
+
s && s(A);
|
|
1187
|
+
};
|
|
1188
|
+
return l ? /* @__PURE__ */ r.jsxs(b, { sx: { width: { xs: "90%", md: "50%" }, margin: "auto", padding: "20px" }, children: [
|
|
1189
|
+
/* @__PURE__ */ r.jsx(g, { variant: "h5", gutterBottom: !0, children: "Reset Link Sent" }),
|
|
1190
|
+
/* @__PURE__ */ r.jsx(Y, { severity: "success", sx: { mb: 2 }, children: o }),
|
|
1191
|
+
/* @__PURE__ */ r.jsx(g, { variant: "body1", paragraph: !0, children: "Please check your email for a link to reset your password." }),
|
|
1192
|
+
/* @__PURE__ */ r.jsx(b, { sx: { mt: 3 }, children: /* @__PURE__ */ r.jsx(D, { style: { textDecoration: "underline" }, to: f, children: "Return to Login" }) })
|
|
1193
|
+
] }) : /* @__PURE__ */ r.jsxs(b, { sx: { width: { xs: "90%", md: "50%" }, margin: "auto", padding: "20px" }, children: [
|
|
1194
|
+
/* @__PURE__ */ r.jsx(g, { variant: "h5", gutterBottom: !0, children: "Reset Password" }),
|
|
1195
|
+
/* @__PURE__ */ r.jsx(g, { variant: "body2", color: "text.secondary", sx: { mb: 2 }, children: "Enter your email address below and we'll send you a link to reset your password." }),
|
|
1196
|
+
m && /* @__PURE__ */ r.jsx(Y, { severity: "error", sx: { mb: 2 }, children: ((S = (E = m.response) == null ? void 0 : E.data) == null ? void 0 : S.error) || m.message || "An error occurred" }),
|
|
1197
|
+
/* @__PURE__ */ r.jsx("form", { onSubmit: u(w), noValidate: !0, children: /* @__PURE__ */ r.jsxs(J, { spacing: 2, children: [
|
|
1198
|
+
/* @__PURE__ */ r.jsx(
|
|
1199
|
+
L,
|
|
1200
|
+
{
|
|
1201
|
+
...h("email"),
|
|
1202
|
+
label: "Email",
|
|
1203
|
+
type: "email",
|
|
1204
|
+
placeholder: "Enter your email",
|
|
1205
|
+
margin: "normal",
|
|
1206
|
+
size: "small",
|
|
1207
|
+
required: !0,
|
|
1208
|
+
error: !!c.email,
|
|
1209
|
+
helperText: (_ = c.email) == null ? void 0 : _.message
|
|
1210
|
+
}
|
|
1211
|
+
),
|
|
1212
|
+
/* @__PURE__ */ r.jsx(
|
|
1213
|
+
se,
|
|
1214
|
+
{
|
|
1215
|
+
sx: { margin: "10px" },
|
|
1216
|
+
variant: "contained",
|
|
1217
|
+
type: "submit",
|
|
1218
|
+
disabled: i,
|
|
1219
|
+
children: i ? /* @__PURE__ */ r.jsx(re, { size: 24 }) : "Send Reset Link"
|
|
1220
|
+
}
|
|
1221
|
+
)
|
|
1222
|
+
] }) }),
|
|
1223
|
+
/* @__PURE__ */ r.jsx(b, { sx: { mt: 2 }, children: /* @__PURE__ */ r.jsx(D, { style: { textDecoration: "underline" }, to: f, children: "Back to Login" }) })
|
|
1224
|
+
] });
|
|
1225
|
+
}, ct = (s, i = "/register/submit") => de({
|
|
1226
|
+
mutationFn: async ({ email: l, first: o, last: m, requestNote: f }) => (await s.post(i, {
|
|
1227
|
+
email: l,
|
|
1228
|
+
first: o,
|
|
1229
|
+
last: m,
|
|
1230
|
+
requestNote: f
|
|
1231
|
+
})).data
|
|
1232
|
+
}), dt = (s, i, l = "/register/verify") => Ee({
|
|
1233
|
+
queryKey: ["emailVerification", i],
|
|
1234
|
+
queryFn: async () => {
|
|
1235
|
+
if (!i)
|
|
1236
|
+
throw new Error("No verification token provided");
|
|
1237
|
+
return (await s.get(`${l}/${i}`)).data;
|
|
1238
|
+
},
|
|
1239
|
+
enabled: !!i,
|
|
1240
|
+
retry: !1,
|
|
1241
|
+
refetchOnWindowFocus: !1
|
|
1242
|
+
}), zr = (s, i, l = "/register/setup") => Ee({
|
|
1243
|
+
queryKey: ["validateSetupToken", i],
|
|
1244
|
+
queryFn: async () => {
|
|
1245
|
+
if (!i)
|
|
1246
|
+
throw new Error("No setup token provided");
|
|
1247
|
+
return (await s.get(`${l}/${i}`)).data;
|
|
1248
|
+
},
|
|
1249
|
+
enabled: !!i,
|
|
1250
|
+
retry: !1,
|
|
1251
|
+
refetchOnWindowFocus: !1
|
|
1252
|
+
}), Wr = (s, i = "/register/setup") => de({
|
|
1253
|
+
mutationFn: async ({ token: l, password: o }) => (await s.post(`${i}/${l}`, { password: o })).data
|
|
1254
|
+
}), ft = (s, i = "/register/forgot-password") => de({
|
|
1255
|
+
mutationFn: async ({ email: l }) => (await s.post(i, { email: l })).data
|
|
1256
|
+
}), mt = (s, i, l = "/register/setup") => {
|
|
1257
|
+
var f, p, n;
|
|
1258
|
+
const o = zr(s, i, l), m = Wr(s, l);
|
|
1259
|
+
return {
|
|
1260
|
+
validation: o,
|
|
1261
|
+
setPassword: m,
|
|
1262
|
+
isValidToken: o.isSuccess && ((f = o.data) == null ? void 0 : f.valid),
|
|
1263
|
+
userEmail: (p = o.data) == null ? void 0 : p.email,
|
|
1264
|
+
userFirst: (n = o.data) == null ? void 0 : n.first
|
|
1265
|
+
};
|
|
1266
|
+
};
|
|
1267
|
+
export {
|
|
1268
|
+
er as AuthContext,
|
|
1269
|
+
Hr as AuthProvider,
|
|
1270
|
+
it as EmailVerification,
|
|
1271
|
+
tt as Login,
|
|
1272
|
+
ut as PasswordResetRequest,
|
|
1273
|
+
ot as PasswordSetup,
|
|
1274
|
+
st as Register,
|
|
1275
|
+
at as RegistrationRequest,
|
|
1276
|
+
lt as RegistrationSuccess,
|
|
1277
|
+
et as RequireAuth,
|
|
1278
|
+
rt as StandardAuthRoutes,
|
|
1279
|
+
nt as Unauthorized,
|
|
1280
|
+
ne as useAuth,
|
|
1281
|
+
dt as useEmailVerification,
|
|
1282
|
+
Qr as useLogin,
|
|
1283
|
+
mt as usePasswordSetup,
|
|
1284
|
+
Nr as useRefreshToken,
|
|
1285
|
+
ct as useRegistrationSubmit,
|
|
1286
|
+
ft as useRequestPasswordReset,
|
|
1287
|
+
Zr as useSecureAxios,
|
|
1288
|
+
Wr as useSetPassword,
|
|
1289
|
+
zr as useValidateSetupToken
|
|
1290
|
+
};
|