@thetechfossil/auth2 1.2.20 → 1.2.22

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.
@@ -5,12 +5,16 @@ import { UpfilesClient, ImageManager } from '@thetechfossil/upfiles';
5
5
  import React, { createContext, forwardRef, useContext, useState, useCallback, useEffect, useMemo, useRef } from 'react';
6
6
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
7
 
8
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
- }) : x)(function(x) {
11
- if (typeof require !== "undefined") return require.apply(this, arguments);
12
- throw Error('Dynamic require of "' + x + '" is not supported');
13
- });
8
+ var ERROR_MESSAGES = {
9
+ NETWORK_ERROR: "Unable to connect to the server. Please check your internet connection and try again.",
10
+ TIMEOUT: "The request took too long. Please try again.",
11
+ SERVER_ERROR: "Something went wrong on our end. Please try again later.",
12
+ UNAUTHORIZED: "Your session has expired. Please log in again.",
13
+ FORBIDDEN: "You do not have permission to perform this action.",
14
+ NOT_FOUND: "The requested resource was not found.",
15
+ RATE_LIMITED: "Too many requests. Please wait a moment and try again.",
16
+ UNKNOWN: "An unexpected error occurred. Please try again."
17
+ };
14
18
  var HttpClient = class {
15
19
  constructor(baseUrl, defaultHeaders = {}) {
16
20
  this.csrfToken = null;
@@ -45,7 +49,7 @@ var HttpClient = class {
45
49
  }
46
50
  return config;
47
51
  },
48
- (error) => Promise.reject(error)
52
+ (error) => Promise.reject(this.createUserFriendlyError(error))
49
53
  );
50
54
  this.axiosInstance.interceptors.response.use(
51
55
  (response) => response,
@@ -60,18 +64,71 @@ var HttpClient = class {
60
64
  }
61
65
  return this.axiosInstance(originalRequest);
62
66
  } catch (refreshError) {
63
- return Promise.reject(refreshError);
67
+ return Promise.reject(this.createUserFriendlyError(refreshError));
64
68
  }
65
69
  }
66
- if (error.response && error.response.data && error.response.data.message) {
67
- const customError = new Error(error.response.data.message);
68
- customError.response = error.response;
69
- return Promise.reject(customError);
70
- }
71
- return Promise.reject(error);
70
+ return Promise.reject(this.createUserFriendlyError(error));
72
71
  }
73
72
  );
74
73
  }
74
+ /**
75
+ * Creates a user-friendly error message from an Axios error
76
+ */
77
+ createUserFriendlyError(error) {
78
+ if (error instanceof Error && !error.isAxiosError) {
79
+ return error;
80
+ }
81
+ let message;
82
+ let statusCode;
83
+ if (axios.isAxiosError(error)) {
84
+ statusCode = error.response?.status;
85
+ const responseData = error.response?.data;
86
+ if (responseData?.message) {
87
+ message = responseData.message;
88
+ } else if (!error.response) {
89
+ if (error.code === "ECONNABORTED" || error.message.includes("timeout")) {
90
+ message = ERROR_MESSAGES.TIMEOUT;
91
+ } else if (error.code === "ERR_NETWORK" || error.message === "Network Error") {
92
+ message = ERROR_MESSAGES.NETWORK_ERROR;
93
+ } else {
94
+ message = ERROR_MESSAGES.NETWORK_ERROR;
95
+ }
96
+ } else {
97
+ switch (statusCode) {
98
+ case 400:
99
+ message = responseData?.message || "Invalid request. Please check your input.";
100
+ break;
101
+ case 401:
102
+ message = responseData?.message || ERROR_MESSAGES.UNAUTHORIZED;
103
+ break;
104
+ case 403:
105
+ message = responseData?.message || ERROR_MESSAGES.FORBIDDEN;
106
+ break;
107
+ case 404:
108
+ message = responseData?.message || ERROR_MESSAGES.NOT_FOUND;
109
+ break;
110
+ case 429:
111
+ message = ERROR_MESSAGES.RATE_LIMITED;
112
+ break;
113
+ case 500:
114
+ case 502:
115
+ case 503:
116
+ case 504:
117
+ message = ERROR_MESSAGES.SERVER_ERROR;
118
+ break;
119
+ default:
120
+ message = responseData?.message || ERROR_MESSAGES.UNKNOWN;
121
+ }
122
+ }
123
+ } else {
124
+ message = error?.message || ERROR_MESSAGES.UNKNOWN;
125
+ }
126
+ const customError = new Error(message);
127
+ customError.response = error?.response;
128
+ customError.statusCode = statusCode;
129
+ customError.originalError = error;
130
+ return customError;
131
+ }
75
132
  async get(endpoint, headers) {
76
133
  const response = await this.axiosInstance.get(endpoint, { headers });
77
134
  return response.data;
@@ -277,6 +334,7 @@ var AuthService = class {
277
334
  if (token) {
278
335
  this.token = token;
279
336
  this.httpClient.setAuthToken(token);
337
+ this.setTokenCookie(token);
280
338
  }
281
339
  } catch (error) {
282
340
  console.warn("Failed to load token from storage:", error);
@@ -287,15 +345,28 @@ var AuthService = class {
287
345
  if (typeof window !== "undefined" && this.config.localStorageKey) {
288
346
  try {
289
347
  localStorage.setItem(this.config.localStorageKey, token);
348
+ this.setTokenCookie(token);
290
349
  } catch (error) {
291
350
  console.warn("Failed to save token to storage:", error);
292
351
  }
293
352
  }
294
353
  }
354
+ setTokenCookie(token) {
355
+ if (typeof window !== "undefined") {
356
+ const maxAge = 7 * 24 * 60 * 60;
357
+ document.cookie = `auth_token=${token}; path=/; max-age=${maxAge}; SameSite=Lax`;
358
+ }
359
+ }
360
+ removeTokenCookie() {
361
+ if (typeof window !== "undefined") {
362
+ document.cookie = "auth_token=; path=/; max-age=0; SameSite=Lax";
363
+ }
364
+ }
295
365
  removeTokenFromStorage() {
296
366
  if (typeof window !== "undefined" && this.config.localStorageKey) {
297
367
  try {
298
368
  localStorage.removeItem(this.config.localStorageKey);
369
+ this.removeTokenCookie();
299
370
  } catch (error) {
300
371
  console.warn("Failed to remove token from storage:", error);
301
372
  }
@@ -1274,14 +1345,6 @@ function useThemeColors() {
1274
1345
  const { theme } = useAuthTheme();
1275
1346
  return theme === "dark" ? darkTheme : lightTheme;
1276
1347
  }
1277
- var PhoneInputWithCountry = null;
1278
- try {
1279
- const module = __require("react-phone-number-input");
1280
- PhoneInputWithCountry = module.default || module;
1281
- __require("react-phone-number-input/style.css");
1282
- } catch (error) {
1283
- console.warn("react-phone-number-input not available, using fallback");
1284
- }
1285
1348
  var CustomPhoneInput = React.forwardRef((props, ref) => /* @__PURE__ */ jsx(
1286
1349
  "input",
1287
1350
  {
@@ -1302,6 +1365,8 @@ var PhoneInput = ({
1302
1365
  }) => {
1303
1366
  const colors = useThemeColors();
1304
1367
  const [defaultCountry, setDefaultCountry] = useState("US");
1368
+ const [PhoneInputComponent, setPhoneInputComponent] = useState(null);
1369
+ const [isLoading, setIsLoading] = useState(true);
1305
1370
  const styleContent = useMemo(() => `
1306
1371
  .PhoneInput {
1307
1372
  display: flex;
@@ -1414,6 +1479,29 @@ var PhoneInput = ({
1414
1479
  opacity: 0.6;
1415
1480
  }
1416
1481
  `, [colors]);
1482
+ useEffect(() => {
1483
+ let mounted = true;
1484
+ const loadPhoneInput = async () => {
1485
+ try {
1486
+ const module = await import('react-phone-number-input');
1487
+ if (mounted) {
1488
+ setPhoneInputComponent(() => module.default);
1489
+ }
1490
+ } catch (error) {
1491
+ if (mounted) {
1492
+ setPhoneInputComponent(null);
1493
+ }
1494
+ } finally {
1495
+ if (mounted) {
1496
+ setIsLoading(false);
1497
+ }
1498
+ }
1499
+ };
1500
+ loadPhoneInput();
1501
+ return () => {
1502
+ mounted = false;
1503
+ };
1504
+ }, []);
1417
1505
  useEffect(() => {
1418
1506
  const detectCountry = async () => {
1419
1507
  try {
@@ -1466,7 +1554,6 @@ var PhoneInput = ({
1466
1554
  }
1467
1555
  }
1468
1556
  } catch (error) {
1469
- console.log("Country detection failed, using default US");
1470
1557
  }
1471
1558
  };
1472
1559
  detectCountry();
@@ -1474,7 +1561,31 @@ var PhoneInput = ({
1474
1561
  const handleChange = useMemo(() => (val) => {
1475
1562
  onChange(val || "");
1476
1563
  }, [onChange]);
1477
- if (!PhoneInputWithCountry) {
1564
+ if (isLoading) {
1565
+ return /* @__PURE__ */ jsx(
1566
+ "input",
1567
+ {
1568
+ id,
1569
+ type: "tel",
1570
+ value,
1571
+ onChange: (e) => onChange(e.target.value),
1572
+ disabled,
1573
+ required,
1574
+ placeholder,
1575
+ style: {
1576
+ width: "100%",
1577
+ padding: "12px 16px",
1578
+ border: `1px solid ${colors.borderSecondary}`,
1579
+ borderRadius: "8px",
1580
+ fontSize: "16px",
1581
+ backgroundColor: colors.bgSecondary,
1582
+ color: colors.textPrimary,
1583
+ ...style
1584
+ }
1585
+ }
1586
+ );
1587
+ }
1588
+ if (!PhoneInputComponent) {
1478
1589
  return /* @__PURE__ */ jsx(
1479
1590
  "input",
1480
1591
  {
@@ -1508,7 +1619,7 @@ var PhoneInput = ({
1508
1619
  children: [
1509
1620
  /* @__PURE__ */ jsx("style", { children: styleContent }),
1510
1621
  /* @__PURE__ */ jsx(
1511
- PhoneInputWithCountry,
1622
+ PhoneInputComponent,
1512
1623
  {
1513
1624
  id,
1514
1625
  international: true,
@@ -2006,6 +2117,28 @@ var RegisterForm = ({
2006
2117
  const [error, setError] = useState(null);
2007
2118
  const [showPassword, setShowPassword] = useState(false);
2008
2119
  const [showConfirmPassword, setShowConfirmPassword] = useState(false);
2120
+ const [invitationDetails, setInvitationDetails] = useState(null);
2121
+ const [isLoadingInvitation, setIsLoadingInvitation] = useState(false);
2122
+ const config = authConfig || {
2123
+ baseUrl: "http://localhost:7000"
2124
+ };
2125
+ useEffect(() => {
2126
+ if (invitationToken) {
2127
+ setIsLoadingInvitation(true);
2128
+ fetch(`${config.baseUrl}/api/v1/auth/verify-invitation/${invitationToken}`).then((res) => res.json()).then((data) => {
2129
+ setInvitationDetails(data);
2130
+ if (data.valid && data.email) {
2131
+ setEmail(data.email);
2132
+ }
2133
+ }).catch((err) => {
2134
+ console.error("Failed to verify invitation:", err);
2135
+ setError("Failed to verify invitation. Please try again.");
2136
+ }).finally(() => {
2137
+ setIsLoadingInvitation(false);
2138
+ });
2139
+ }
2140
+ }, [invitationToken, config.baseUrl]);
2141
+ const isEmailDisabled = isLoading || invitationDetails?.valid && !!invitationDetails?.email;
2009
2142
  const getPasswordStrength = (pwd) => {
2010
2143
  if (!pwd) return { strength: "weak", score: 0, label: "" };
2011
2144
  let score = 0;
@@ -2019,9 +2152,6 @@ var RegisterForm = ({
2019
2152
  return { strength: "strong", score, label: "Strong" };
2020
2153
  };
2021
2154
  getPasswordStrength(password);
2022
- const config = authConfig || {
2023
- baseUrl: "http://localhost:7000"
2024
- };
2025
2155
  const { register } = useAuth(config);
2026
2156
  const handleSubmit = async (e) => {
2027
2157
  e.preventDefault();
@@ -2056,6 +2186,25 @@ var RegisterForm = ({
2056
2186
  if (response.ok && data.success) {
2057
2187
  if (typeof window !== "undefined" && data.token) {
2058
2188
  localStorage.setItem("auth_token", data.token);
2189
+ if (data.invitation?.organizationId && data.invitation?.role) {
2190
+ localStorage.setItem("currentOrganizationId", data.invitation.organizationId);
2191
+ const backendUrl = typeof window !== "undefined" ? process.env.NEXT_PUBLIC_INVENTORY_API_URL || process.env.NEXT_PUBLIC_BIZFLOW_API_URL || "http://localhost:5002" : "http://localhost:5002";
2192
+ try {
2193
+ await fetch(`${backendUrl}/api/auth/sync-with-role`, {
2194
+ method: "POST",
2195
+ headers: {
2196
+ "Content-Type": "application/json",
2197
+ "Authorization": `Bearer ${data.token}`
2198
+ },
2199
+ body: JSON.stringify({
2200
+ organizationId: data.invitation.organizationId,
2201
+ roleName: data.invitation.role
2202
+ })
2203
+ });
2204
+ } catch (syncError) {
2205
+ console.error("Failed to sync user role with backend:", syncError);
2206
+ }
2207
+ }
2059
2208
  }
2060
2209
  onRegisterSuccess?.();
2061
2210
  } else {
@@ -2163,7 +2312,7 @@ var RegisterForm = ({
2163
2312
  value: email,
2164
2313
  onChange: (e) => setEmail(e.target.value),
2165
2314
  required: !phoneNumber,
2166
- disabled: isLoading,
2315
+ disabled: isEmailDisabled,
2167
2316
  style: {
2168
2317
  width: "100%",
2169
2318
  padding: "12px 16px",
@@ -2171,9 +2320,11 @@ var RegisterForm = ({
2171
2320
  borderRadius: "8px",
2172
2321
  fontSize: "16px",
2173
2322
  boxSizing: "border-box",
2174
- color: colors.textPrimary,
2323
+ color: isEmailDisabled ? colors.textSecondary : colors.textPrimary,
2175
2324
  transition: "all 0.2s ease",
2176
- backgroundColor: colors.bgSecondary
2325
+ backgroundColor: isEmailDisabled ? colors.bgHover : colors.bgSecondary,
2326
+ cursor: isEmailDisabled ? "not-allowed" : "text",
2327
+ opacity: isEmailDisabled ? 0.7 : 1
2177
2328
  },
2178
2329
  placeholder: "Enter your email"
2179
2330
  }
@@ -2876,7 +3027,7 @@ var EmailVerificationPage = ({
2876
3027
  } })
2877
3028
  ] }) });
2878
3029
  }
2879
- return /* @__PURE__ */ jsx("div", { style: {
3030
+ return /* @__PURE__ */ jsxs("div", { style: {
2880
3031
  maxWidth: "500px",
2881
3032
  margin: "0 auto",
2882
3033
  padding: "30px",
@@ -2885,44 +3036,86 @@ var EmailVerificationPage = ({
2885
3036
  backgroundColor: "#ffffff",
2886
3037
  textAlign: "center",
2887
3038
  border: "1px solid #eaeaea"
2888
- }, children: /* @__PURE__ */ jsxs("div", { style: {
2889
- padding: "20px"
2890
3039
  }, children: [
2891
- /* @__PURE__ */ jsx("h2", { style: { color: "black" }, children: "Email Verification" }),
2892
- /* @__PURE__ */ jsx("div", { style: {
2893
- padding: "16px 20px",
2894
- margin: "24px 0",
2895
- borderRadius: "8px",
2896
- fontSize: "15px",
2897
- fontWeight: 500,
2898
- backgroundColor: isSuccess ? "#d4edda" : "#f8d7da",
2899
- color: isSuccess ? "#155724" : "#721c24",
2900
- border: isSuccess ? "1px solid #c3e6cb" : "1px solid #f5c6cb"
2901
- }, children: message }),
2902
- isSuccess && /* @__PURE__ */ jsxs("div", { style: {
2903
- marginTop: "24px"
3040
+ /* @__PURE__ */ jsxs("div", { style: {
3041
+ padding: "20px"
2904
3042
  }, children: [
2905
- /* @__PURE__ */ jsx("p", { style: { color: "black" }, children: "Your email has been successfully verified!" }),
2906
- /* @__PURE__ */ jsx(
2907
- "button",
2908
- {
2909
- onClick: () => window.location.href = "/login",
2910
- style: {
2911
- padding: "12px 24px",
2912
- backgroundColor: "#007bff",
2913
- color: "white",
2914
- border: "none",
2915
- borderRadius: "8px",
2916
- fontSize: "16px",
2917
- fontWeight: 600,
2918
- cursor: "pointer",
2919
- transition: "all 0.2s ease"
2920
- },
2921
- children: "Go to Login"
3043
+ /* @__PURE__ */ jsx("h2", { style: { color: "black" }, children: isSuccess ? "\u2713 Email Verified!" : "\u2717 Verification Failed" }),
3044
+ /* @__PURE__ */ jsx("div", { style: {
3045
+ padding: "16px 20px",
3046
+ margin: "24px 0",
3047
+ borderRadius: "8px",
3048
+ fontSize: "15px",
3049
+ fontWeight: 500,
3050
+ backgroundColor: isSuccess ? "#d4edda" : "#f8d7da",
3051
+ color: isSuccess ? "#155724" : "#721c24",
3052
+ border: isSuccess ? "1px solid #c3e6cb" : "1px solid #f5c6cb"
3053
+ }, children: message }),
3054
+ isSuccess ? /* @__PURE__ */ jsxs("div", { style: { marginTop: "24px" }, children: [
3055
+ /* @__PURE__ */ jsx("p", { style: { color: "#666", marginBottom: "16px" }, children: "Redirecting to login..." }),
3056
+ /* @__PURE__ */ jsx("div", { style: {
3057
+ border: "3px solid #d4edda",
3058
+ borderTop: "3px solid #28a745",
3059
+ borderRadius: "50%",
3060
+ width: "30px",
3061
+ height: "30px",
3062
+ animation: "spin 1s linear infinite",
3063
+ margin: "0 auto"
3064
+ } })
3065
+ ] }) : /* @__PURE__ */ jsxs("div", { style: { marginTop: "24px" }, children: [
3066
+ /* @__PURE__ */ jsx("p", { style: { color: "#666", marginBottom: "16px" }, children: "The verification link may have expired or already been used." }),
3067
+ /* @__PURE__ */ jsx(
3068
+ "button",
3069
+ {
3070
+ onClick: () => {
3071
+ const registerPath = process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_REGISTER || process.env.REACT_APP_AUTH_REDIRECT_TO_REGISTER || "/auth/register";
3072
+ window.location.href = registerPath;
3073
+ },
3074
+ style: {
3075
+ padding: "12px 24px",
3076
+ backgroundColor: "#007bff",
3077
+ color: "white",
3078
+ border: "none",
3079
+ borderRadius: "8px",
3080
+ fontSize: "16px",
3081
+ fontWeight: 600,
3082
+ cursor: "pointer",
3083
+ transition: "all 0.2s ease",
3084
+ marginRight: "12px"
3085
+ },
3086
+ children: "Register Again"
3087
+ }
3088
+ ),
3089
+ /* @__PURE__ */ jsx(
3090
+ "button",
3091
+ {
3092
+ onClick: () => {
3093
+ const loginPath = process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_TO_LOGIN || "/auth/login";
3094
+ window.location.href = loginPath;
3095
+ },
3096
+ style: {
3097
+ padding: "12px 24px",
3098
+ backgroundColor: "#6c757d",
3099
+ color: "white",
3100
+ border: "none",
3101
+ borderRadius: "8px",
3102
+ fontSize: "16px",
3103
+ fontWeight: 600,
3104
+ cursor: "pointer",
3105
+ transition: "all 0.2s ease"
3106
+ },
3107
+ children: "Go to Login"
3108
+ }
3109
+ )
3110
+ ] })
3111
+ ] }),
3112
+ /* @__PURE__ */ jsx("style", { children: `
3113
+ @keyframes spin {
3114
+ 0% { transform: rotate(0deg); }
3115
+ 100% { transform: rotate(360deg); }
2922
3116
  }
2923
- )
2924
- ] })
2925
- ] }) });
3117
+ ` })
3118
+ ] });
2926
3119
  };
2927
3120
  var ThemeWrapper = forwardRef(
2928
3121
  ({ children, className = "", style }, ref) => {
@@ -5133,6 +5326,274 @@ var UserProfile = ({
5133
5326
  ] })
5134
5327
  ] });
5135
5328
  };
5329
+ var SuperAdminSignIn = ({ redirectUrl, appearance }) => {
5330
+ const { signIn, isSignedIn, loading: authLoading, user } = useAuth2();
5331
+ const colors = useThemeColors();
5332
+ const [email, setEmail] = useState("");
5333
+ const [password, setPassword] = useState("");
5334
+ const [showPassword, setShowPassword] = useState(false);
5335
+ const [isLoading, setIsLoading] = useState(false);
5336
+ const [error, setError] = useState(null);
5337
+ const [success, setSuccess] = useState(null);
5338
+ useEffect(() => {
5339
+ if (isSignedIn && user) {
5340
+ const isSuperAdmin = user.role === "SUPER_ADMIN" || user.role === "SUPERADMIN";
5341
+ if (isSuperAdmin) {
5342
+ const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
5343
+ const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
5344
+ window.location.href = `${baseUrl}${redirect}`;
5345
+ } else {
5346
+ setError("Access denied. Only Super Admin users can access this portal.");
5347
+ document.cookie = "auth_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT";
5348
+ document.cookie = "refresh_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT";
5349
+ }
5350
+ }
5351
+ }, [isSignedIn, user, redirectUrl]);
5352
+ const handleSubmit = async (e) => {
5353
+ e.preventDefault();
5354
+ setIsLoading(true);
5355
+ setError(null);
5356
+ setSuccess(null);
5357
+ try {
5358
+ const response = await signIn({ email, password });
5359
+ if (response.success) {
5360
+ const userRole = response.user?.role;
5361
+ const isSuperAdmin = userRole === "SUPER_ADMIN" || userRole === "SUPERADMIN";
5362
+ if (!isSuperAdmin) {
5363
+ document.cookie = "auth_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT";
5364
+ document.cookie = "refresh_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT";
5365
+ setError("Access denied. Only Super Admin users can access this portal.");
5366
+ return;
5367
+ }
5368
+ setSuccess("Login successful! Redirecting...");
5369
+ } else {
5370
+ setError(response.message || "Login failed. Please check your credentials.");
5371
+ }
5372
+ } catch (err) {
5373
+ setError(err instanceof Error ? err.message : "An error occurred during login.");
5374
+ } finally {
5375
+ setIsLoading(false);
5376
+ }
5377
+ };
5378
+ if (authLoading) {
5379
+ return /* @__PURE__ */ jsx("div", { style: { textAlign: "center", padding: "40px" }, children: /* @__PURE__ */ jsx("div", { children: "Loading..." }) });
5380
+ }
5381
+ return /* @__PURE__ */ jsx(
5382
+ ThemeWrapper,
5383
+ {
5384
+ style: {
5385
+ maxWidth: "400px",
5386
+ margin: "0 auto",
5387
+ padding: "30px",
5388
+ borderRadius: "12px",
5389
+ boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
5390
+ backgroundColor: colors.bgPrimary,
5391
+ border: `1px solid ${colors.borderPrimary}`,
5392
+ ...appearance?.elements?.card
5393
+ },
5394
+ children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
5395
+ /* @__PURE__ */ jsxs("div", { style: { textAlign: "center", marginBottom: "24px" }, children: [
5396
+ /* @__PURE__ */ jsx("div", { style: {
5397
+ width: "60px",
5398
+ height: "60px",
5399
+ margin: "0 auto 16px",
5400
+ backgroundColor: colors.buttonPrimary + "20",
5401
+ borderRadius: "12px",
5402
+ display: "flex",
5403
+ alignItems: "center",
5404
+ justifyContent: "center"
5405
+ }, children: /* @__PURE__ */ jsxs("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", stroke: colors.buttonPrimary, strokeWidth: "2", children: [
5406
+ /* @__PURE__ */ jsx("path", { d: "M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" }),
5407
+ /* @__PURE__ */ jsx("path", { d: "M9 12l2 2 4-4" })
5408
+ ] }) }),
5409
+ /* @__PURE__ */ jsx("h2", { style: {
5410
+ color: colors.textPrimary,
5411
+ fontSize: "24px",
5412
+ fontWeight: 600,
5413
+ margin: 0,
5414
+ ...appearance?.elements?.headerTitle
5415
+ }, children: "Super Admin Portal" }),
5416
+ /* @__PURE__ */ jsx("p", { style: {
5417
+ color: colors.textSecondary,
5418
+ fontSize: "14px",
5419
+ marginTop: "8px"
5420
+ }, children: "Sign in with your administrator credentials" })
5421
+ ] }),
5422
+ error && /* @__PURE__ */ jsx("div", { style: {
5423
+ padding: "12px 16px",
5424
+ marginBottom: "20px",
5425
+ backgroundColor: colors.errorBg,
5426
+ color: colors.errorText,
5427
+ border: `1px solid ${colors.errorBorder}`,
5428
+ borderRadius: "8px",
5429
+ fontSize: "14px"
5430
+ }, children: error }),
5431
+ success && /* @__PURE__ */ jsx("div", { style: {
5432
+ padding: "12px 16px",
5433
+ marginBottom: "20px",
5434
+ backgroundColor: colors.successBg,
5435
+ color: colors.successText,
5436
+ border: `1px solid ${colors.successBorder}`,
5437
+ borderRadius: "8px",
5438
+ fontSize: "14px"
5439
+ }, children: success }),
5440
+ /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
5441
+ /* @__PURE__ */ jsx("label", { htmlFor: "email", style: {
5442
+ display: "block",
5443
+ marginBottom: "8px",
5444
+ fontWeight: 500,
5445
+ color: colors.textSecondary,
5446
+ fontSize: "14px"
5447
+ }, children: "Email Address" }),
5448
+ /* @__PURE__ */ jsx(
5449
+ "input",
5450
+ {
5451
+ id: "email",
5452
+ type: "email",
5453
+ value: email,
5454
+ onChange: (e) => setEmail(e.target.value),
5455
+ onFocus: (e) => {
5456
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
5457
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
5458
+ },
5459
+ onBlur: (e) => {
5460
+ e.currentTarget.style.borderColor = colors.borderSecondary;
5461
+ e.currentTarget.style.outline = "none";
5462
+ },
5463
+ required: true,
5464
+ disabled: isLoading,
5465
+ autoComplete: "email",
5466
+ style: {
5467
+ width: "100%",
5468
+ padding: "12px 16px",
5469
+ border: `1px solid ${colors.borderSecondary}`,
5470
+ borderRadius: "8px",
5471
+ fontSize: "16px",
5472
+ boxSizing: "border-box",
5473
+ backgroundColor: colors.bgSecondary,
5474
+ color: colors.textPrimary,
5475
+ transition: "all 0.2s ease",
5476
+ WebkitTextFillColor: colors.textPrimary,
5477
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
5478
+ ...appearance?.elements?.formFieldInput
5479
+ },
5480
+ placeholder: "admin@example.com"
5481
+ }
5482
+ )
5483
+ ] }),
5484
+ /* @__PURE__ */ jsxs("div", { style: { marginBottom: "24px", position: "relative" }, children: [
5485
+ /* @__PURE__ */ jsx("label", { htmlFor: "password", style: {
5486
+ display: "block",
5487
+ marginBottom: "8px",
5488
+ fontWeight: 500,
5489
+ color: colors.textSecondary,
5490
+ fontSize: "14px"
5491
+ }, children: "Password" }),
5492
+ /* @__PURE__ */ jsx(
5493
+ "input",
5494
+ {
5495
+ id: "password",
5496
+ type: showPassword ? "text" : "password",
5497
+ value: password,
5498
+ onChange: (e) => setPassword(e.target.value),
5499
+ onFocus: (e) => {
5500
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
5501
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
5502
+ },
5503
+ onBlur: (e) => {
5504
+ e.currentTarget.style.borderColor = colors.borderSecondary;
5505
+ e.currentTarget.style.outline = "none";
5506
+ },
5507
+ required: true,
5508
+ disabled: isLoading,
5509
+ autoComplete: "current-password",
5510
+ style: {
5511
+ width: "100%",
5512
+ padding: "12px 16px",
5513
+ paddingRight: "60px",
5514
+ border: `1px solid ${colors.borderSecondary}`,
5515
+ borderRadius: "8px",
5516
+ fontSize: "16px",
5517
+ boxSizing: "border-box",
5518
+ backgroundColor: colors.bgSecondary,
5519
+ color: colors.textPrimary,
5520
+ transition: "all 0.2s ease",
5521
+ WebkitTextFillColor: colors.textPrimary,
5522
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
5523
+ ...appearance?.elements?.formFieldInput
5524
+ },
5525
+ placeholder: "Enter your password"
5526
+ }
5527
+ ),
5528
+ /* @__PURE__ */ jsx(
5529
+ "button",
5530
+ {
5531
+ type: "button",
5532
+ onClick: () => setShowPassword(!showPassword),
5533
+ style: {
5534
+ position: "absolute",
5535
+ right: "12px",
5536
+ top: "38px",
5537
+ background: "none",
5538
+ border: "none",
5539
+ cursor: "pointer",
5540
+ color: colors.textTertiary,
5541
+ fontSize: "14px",
5542
+ padding: "4px 8px"
5543
+ },
5544
+ children: showPassword ? "Hide" : "Show"
5545
+ }
5546
+ )
5547
+ ] }),
5548
+ /* @__PURE__ */ jsx(
5549
+ "button",
5550
+ {
5551
+ type: "submit",
5552
+ disabled: isLoading || !email || !password,
5553
+ onMouseEnter: (e) => {
5554
+ if (!isLoading && email && password) {
5555
+ e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
5556
+ }
5557
+ },
5558
+ onMouseLeave: (e) => {
5559
+ e.currentTarget.style.backgroundColor = colors.buttonPrimary;
5560
+ },
5561
+ style: {
5562
+ width: "100%",
5563
+ padding: "14px",
5564
+ backgroundColor: colors.buttonPrimary,
5565
+ color: "white",
5566
+ border: "none",
5567
+ borderRadius: "8px",
5568
+ fontSize: "16px",
5569
+ fontWeight: 600,
5570
+ cursor: isLoading || !email || !password ? "not-allowed" : "pointer",
5571
+ opacity: isLoading || !email || !password ? 0.6 : 1,
5572
+ transition: "all 0.2s ease",
5573
+ ...appearance?.elements?.formButtonPrimary
5574
+ },
5575
+ children: isLoading ? "Signing in..." : "Sign In"
5576
+ }
5577
+ ),
5578
+ /* @__PURE__ */ jsx("div", { style: {
5579
+ marginTop: "20px",
5580
+ padding: "12px",
5581
+ backgroundColor: colors.bgSecondary,
5582
+ borderRadius: "8px",
5583
+ textAlign: "center"
5584
+ }, children: /* @__PURE__ */ jsxs("p", { style: {
5585
+ color: colors.textTertiary,
5586
+ fontSize: "12px",
5587
+ margin: 0
5588
+ }, children: [
5589
+ "\u{1F512} This portal is restricted to Super Admin users only.",
5590
+ /* @__PURE__ */ jsx("br", {}),
5591
+ "Contact your system administrator if you need access."
5592
+ ] }) })
5593
+ ] })
5594
+ }
5595
+ );
5596
+ };
5136
5597
  var AvatarManager = ({
5137
5598
  open,
5138
5599
  onOpenChange,
@@ -5406,6 +5867,6 @@ var useNextAuth = (config) => {
5406
5867
  };
5407
5868
  };
5408
5869
 
5409
- export { AuthFlow, AuthProvider, AuthService, AuthThemeProvider, AvatarManager, AvatarUploader, ChangePassword, EmailVerificationPage, ForgotPassword, HttpClient, LoginForm, OtpForm, PhoneInput, ProtectedRoute, PublicRoute, RegisterForm, ResetPassword, SignIn, SignOut, SignUp, UserButton, UserProfile, VerifyEmail, useAuth2 as useAuth, useAuth as useAuthLegacy, useAuthTheme, useNextAuth };
5870
+ export { AuthFlow, AuthProvider, AuthService, AuthThemeProvider, AvatarManager, AvatarUploader, ChangePassword, EmailVerificationPage, ForgotPassword, HttpClient, LoginForm, OtpForm, PhoneInput, ProtectedRoute, PublicRoute, RegisterForm, ResetPassword, SignIn, SignOut, SignUp, SuperAdminSignIn, UserButton, UserProfile, VerifyEmail, useAuth2 as useAuth, useAuth as useAuthLegacy, useAuthTheme, useNextAuth };
5410
5871
  //# sourceMappingURL=index.next.mjs.map
5411
5872
  //# sourceMappingURL=index.next.mjs.map