@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.
@@ -12,12 +12,16 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
12
  var axios__default = /*#__PURE__*/_interopDefault(axios);
13
13
  var React__default = /*#__PURE__*/_interopDefault(React);
14
14
 
15
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
16
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
17
- }) : x)(function(x) {
18
- if (typeof require !== "undefined") return require.apply(this, arguments);
19
- throw Error('Dynamic require of "' + x + '" is not supported');
20
- });
15
+ var ERROR_MESSAGES = {
16
+ NETWORK_ERROR: "Unable to connect to the server. Please check your internet connection and try again.",
17
+ TIMEOUT: "The request took too long. Please try again.",
18
+ SERVER_ERROR: "Something went wrong on our end. Please try again later.",
19
+ UNAUTHORIZED: "Your session has expired. Please log in again.",
20
+ FORBIDDEN: "You do not have permission to perform this action.",
21
+ NOT_FOUND: "The requested resource was not found.",
22
+ RATE_LIMITED: "Too many requests. Please wait a moment and try again.",
23
+ UNKNOWN: "An unexpected error occurred. Please try again."
24
+ };
21
25
  var HttpClient = class {
22
26
  constructor(baseUrl, defaultHeaders = {}) {
23
27
  this.csrfToken = null;
@@ -52,7 +56,7 @@ var HttpClient = class {
52
56
  }
53
57
  return config;
54
58
  },
55
- (error) => Promise.reject(error)
59
+ (error) => Promise.reject(this.createUserFriendlyError(error))
56
60
  );
57
61
  this.axiosInstance.interceptors.response.use(
58
62
  (response) => response,
@@ -67,18 +71,71 @@ var HttpClient = class {
67
71
  }
68
72
  return this.axiosInstance(originalRequest);
69
73
  } catch (refreshError) {
70
- return Promise.reject(refreshError);
74
+ return Promise.reject(this.createUserFriendlyError(refreshError));
71
75
  }
72
76
  }
73
- if (error.response && error.response.data && error.response.data.message) {
74
- const customError = new Error(error.response.data.message);
75
- customError.response = error.response;
76
- return Promise.reject(customError);
77
- }
78
- return Promise.reject(error);
77
+ return Promise.reject(this.createUserFriendlyError(error));
79
78
  }
80
79
  );
81
80
  }
81
+ /**
82
+ * Creates a user-friendly error message from an Axios error
83
+ */
84
+ createUserFriendlyError(error) {
85
+ if (error instanceof Error && !error.isAxiosError) {
86
+ return error;
87
+ }
88
+ let message;
89
+ let statusCode;
90
+ if (axios__default.default.isAxiosError(error)) {
91
+ statusCode = error.response?.status;
92
+ const responseData = error.response?.data;
93
+ if (responseData?.message) {
94
+ message = responseData.message;
95
+ } else if (!error.response) {
96
+ if (error.code === "ECONNABORTED" || error.message.includes("timeout")) {
97
+ message = ERROR_MESSAGES.TIMEOUT;
98
+ } else if (error.code === "ERR_NETWORK" || error.message === "Network Error") {
99
+ message = ERROR_MESSAGES.NETWORK_ERROR;
100
+ } else {
101
+ message = ERROR_MESSAGES.NETWORK_ERROR;
102
+ }
103
+ } else {
104
+ switch (statusCode) {
105
+ case 400:
106
+ message = responseData?.message || "Invalid request. Please check your input.";
107
+ break;
108
+ case 401:
109
+ message = responseData?.message || ERROR_MESSAGES.UNAUTHORIZED;
110
+ break;
111
+ case 403:
112
+ message = responseData?.message || ERROR_MESSAGES.FORBIDDEN;
113
+ break;
114
+ case 404:
115
+ message = responseData?.message || ERROR_MESSAGES.NOT_FOUND;
116
+ break;
117
+ case 429:
118
+ message = ERROR_MESSAGES.RATE_LIMITED;
119
+ break;
120
+ case 500:
121
+ case 502:
122
+ case 503:
123
+ case 504:
124
+ message = ERROR_MESSAGES.SERVER_ERROR;
125
+ break;
126
+ default:
127
+ message = responseData?.message || ERROR_MESSAGES.UNKNOWN;
128
+ }
129
+ }
130
+ } else {
131
+ message = error?.message || ERROR_MESSAGES.UNKNOWN;
132
+ }
133
+ const customError = new Error(message);
134
+ customError.response = error?.response;
135
+ customError.statusCode = statusCode;
136
+ customError.originalError = error;
137
+ return customError;
138
+ }
82
139
  async get(endpoint, headers) {
83
140
  const response = await this.axiosInstance.get(endpoint, { headers });
84
141
  return response.data;
@@ -284,6 +341,7 @@ var AuthService = class {
284
341
  if (token) {
285
342
  this.token = token;
286
343
  this.httpClient.setAuthToken(token);
344
+ this.setTokenCookie(token);
287
345
  }
288
346
  } catch (error) {
289
347
  console.warn("Failed to load token from storage:", error);
@@ -294,15 +352,28 @@ var AuthService = class {
294
352
  if (typeof window !== "undefined" && this.config.localStorageKey) {
295
353
  try {
296
354
  localStorage.setItem(this.config.localStorageKey, token);
355
+ this.setTokenCookie(token);
297
356
  } catch (error) {
298
357
  console.warn("Failed to save token to storage:", error);
299
358
  }
300
359
  }
301
360
  }
361
+ setTokenCookie(token) {
362
+ if (typeof window !== "undefined") {
363
+ const maxAge = 7 * 24 * 60 * 60;
364
+ document.cookie = `auth_token=${token}; path=/; max-age=${maxAge}; SameSite=Lax`;
365
+ }
366
+ }
367
+ removeTokenCookie() {
368
+ if (typeof window !== "undefined") {
369
+ document.cookie = "auth_token=; path=/; max-age=0; SameSite=Lax";
370
+ }
371
+ }
302
372
  removeTokenFromStorage() {
303
373
  if (typeof window !== "undefined" && this.config.localStorageKey) {
304
374
  try {
305
375
  localStorage.removeItem(this.config.localStorageKey);
376
+ this.removeTokenCookie();
306
377
  } catch (error) {
307
378
  console.warn("Failed to remove token from storage:", error);
308
379
  }
@@ -1281,14 +1352,6 @@ function useThemeColors() {
1281
1352
  const { theme } = useAuthTheme();
1282
1353
  return theme === "dark" ? darkTheme : lightTheme;
1283
1354
  }
1284
- var PhoneInputWithCountry = null;
1285
- try {
1286
- const module = __require("react-phone-number-input");
1287
- PhoneInputWithCountry = module.default || module;
1288
- __require("react-phone-number-input/style.css");
1289
- } catch (error) {
1290
- console.warn("react-phone-number-input not available, using fallback");
1291
- }
1292
1355
  var CustomPhoneInput = React__default.default.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1293
1356
  "input",
1294
1357
  {
@@ -1309,6 +1372,8 @@ var PhoneInput = ({
1309
1372
  }) => {
1310
1373
  const colors = useThemeColors();
1311
1374
  const [defaultCountry, setDefaultCountry] = React.useState("US");
1375
+ const [PhoneInputComponent, setPhoneInputComponent] = React.useState(null);
1376
+ const [isLoading, setIsLoading] = React.useState(true);
1312
1377
  const styleContent = React.useMemo(() => `
1313
1378
  .PhoneInput {
1314
1379
  display: flex;
@@ -1421,6 +1486,29 @@ var PhoneInput = ({
1421
1486
  opacity: 0.6;
1422
1487
  }
1423
1488
  `, [colors]);
1489
+ React.useEffect(() => {
1490
+ let mounted = true;
1491
+ const loadPhoneInput = async () => {
1492
+ try {
1493
+ const module = await import('react-phone-number-input');
1494
+ if (mounted) {
1495
+ setPhoneInputComponent(() => module.default);
1496
+ }
1497
+ } catch (error) {
1498
+ if (mounted) {
1499
+ setPhoneInputComponent(null);
1500
+ }
1501
+ } finally {
1502
+ if (mounted) {
1503
+ setIsLoading(false);
1504
+ }
1505
+ }
1506
+ };
1507
+ loadPhoneInput();
1508
+ return () => {
1509
+ mounted = false;
1510
+ };
1511
+ }, []);
1424
1512
  React.useEffect(() => {
1425
1513
  const detectCountry = async () => {
1426
1514
  try {
@@ -1473,7 +1561,6 @@ var PhoneInput = ({
1473
1561
  }
1474
1562
  }
1475
1563
  } catch (error) {
1476
- console.log("Country detection failed, using default US");
1477
1564
  }
1478
1565
  };
1479
1566
  detectCountry();
@@ -1481,7 +1568,31 @@ var PhoneInput = ({
1481
1568
  const handleChange = React.useMemo(() => (val) => {
1482
1569
  onChange(val || "");
1483
1570
  }, [onChange]);
1484
- if (!PhoneInputWithCountry) {
1571
+ if (isLoading) {
1572
+ return /* @__PURE__ */ jsxRuntime.jsx(
1573
+ "input",
1574
+ {
1575
+ id,
1576
+ type: "tel",
1577
+ value,
1578
+ onChange: (e) => onChange(e.target.value),
1579
+ disabled,
1580
+ required,
1581
+ placeholder,
1582
+ style: {
1583
+ width: "100%",
1584
+ padding: "12px 16px",
1585
+ border: `1px solid ${colors.borderSecondary}`,
1586
+ borderRadius: "8px",
1587
+ fontSize: "16px",
1588
+ backgroundColor: colors.bgSecondary,
1589
+ color: colors.textPrimary,
1590
+ ...style
1591
+ }
1592
+ }
1593
+ );
1594
+ }
1595
+ if (!PhoneInputComponent) {
1485
1596
  return /* @__PURE__ */ jsxRuntime.jsx(
1486
1597
  "input",
1487
1598
  {
@@ -1515,7 +1626,7 @@ var PhoneInput = ({
1515
1626
  children: [
1516
1627
  /* @__PURE__ */ jsxRuntime.jsx("style", { children: styleContent }),
1517
1628
  /* @__PURE__ */ jsxRuntime.jsx(
1518
- PhoneInputWithCountry,
1629
+ PhoneInputComponent,
1519
1630
  {
1520
1631
  id,
1521
1632
  international: true,
@@ -2013,6 +2124,28 @@ var RegisterForm = ({
2013
2124
  const [error, setError] = React.useState(null);
2014
2125
  const [showPassword, setShowPassword] = React.useState(false);
2015
2126
  const [showConfirmPassword, setShowConfirmPassword] = React.useState(false);
2127
+ const [invitationDetails, setInvitationDetails] = React.useState(null);
2128
+ const [isLoadingInvitation, setIsLoadingInvitation] = React.useState(false);
2129
+ const config = authConfig || {
2130
+ baseUrl: "http://localhost:7000"
2131
+ };
2132
+ React.useEffect(() => {
2133
+ if (invitationToken) {
2134
+ setIsLoadingInvitation(true);
2135
+ fetch(`${config.baseUrl}/api/v1/auth/verify-invitation/${invitationToken}`).then((res) => res.json()).then((data) => {
2136
+ setInvitationDetails(data);
2137
+ if (data.valid && data.email) {
2138
+ setEmail(data.email);
2139
+ }
2140
+ }).catch((err) => {
2141
+ console.error("Failed to verify invitation:", err);
2142
+ setError("Failed to verify invitation. Please try again.");
2143
+ }).finally(() => {
2144
+ setIsLoadingInvitation(false);
2145
+ });
2146
+ }
2147
+ }, [invitationToken, config.baseUrl]);
2148
+ const isEmailDisabled = isLoading || invitationDetails?.valid && !!invitationDetails?.email;
2016
2149
  const getPasswordStrength = (pwd) => {
2017
2150
  if (!pwd) return { strength: "weak", score: 0, label: "" };
2018
2151
  let score = 0;
@@ -2026,9 +2159,6 @@ var RegisterForm = ({
2026
2159
  return { strength: "strong", score, label: "Strong" };
2027
2160
  };
2028
2161
  getPasswordStrength(password);
2029
- const config = authConfig || {
2030
- baseUrl: "http://localhost:7000"
2031
- };
2032
2162
  const { register } = useAuth(config);
2033
2163
  const handleSubmit = async (e) => {
2034
2164
  e.preventDefault();
@@ -2063,6 +2193,25 @@ var RegisterForm = ({
2063
2193
  if (response.ok && data.success) {
2064
2194
  if (typeof window !== "undefined" && data.token) {
2065
2195
  localStorage.setItem("auth_token", data.token);
2196
+ if (data.invitation?.organizationId && data.invitation?.role) {
2197
+ localStorage.setItem("currentOrganizationId", data.invitation.organizationId);
2198
+ 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";
2199
+ try {
2200
+ await fetch(`${backendUrl}/api/auth/sync-with-role`, {
2201
+ method: "POST",
2202
+ headers: {
2203
+ "Content-Type": "application/json",
2204
+ "Authorization": `Bearer ${data.token}`
2205
+ },
2206
+ body: JSON.stringify({
2207
+ organizationId: data.invitation.organizationId,
2208
+ roleName: data.invitation.role
2209
+ })
2210
+ });
2211
+ } catch (syncError) {
2212
+ console.error("Failed to sync user role with backend:", syncError);
2213
+ }
2214
+ }
2066
2215
  }
2067
2216
  onRegisterSuccess?.();
2068
2217
  } else {
@@ -2170,7 +2319,7 @@ var RegisterForm = ({
2170
2319
  value: email,
2171
2320
  onChange: (e) => setEmail(e.target.value),
2172
2321
  required: !phoneNumber,
2173
- disabled: isLoading,
2322
+ disabled: isEmailDisabled,
2174
2323
  style: {
2175
2324
  width: "100%",
2176
2325
  padding: "12px 16px",
@@ -2178,9 +2327,11 @@ var RegisterForm = ({
2178
2327
  borderRadius: "8px",
2179
2328
  fontSize: "16px",
2180
2329
  boxSizing: "border-box",
2181
- color: colors.textPrimary,
2330
+ color: isEmailDisabled ? colors.textSecondary : colors.textPrimary,
2182
2331
  transition: "all 0.2s ease",
2183
- backgroundColor: colors.bgSecondary
2332
+ backgroundColor: isEmailDisabled ? colors.bgHover : colors.bgSecondary,
2333
+ cursor: isEmailDisabled ? "not-allowed" : "text",
2334
+ opacity: isEmailDisabled ? 0.7 : 1
2184
2335
  },
2185
2336
  placeholder: "Enter your email"
2186
2337
  }
@@ -2883,7 +3034,7 @@ var EmailVerificationPage = ({
2883
3034
  } })
2884
3035
  ] }) });
2885
3036
  }
2886
- return /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
3037
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
2887
3038
  maxWidth: "500px",
2888
3039
  margin: "0 auto",
2889
3040
  padding: "30px",
@@ -2892,44 +3043,86 @@ var EmailVerificationPage = ({
2892
3043
  backgroundColor: "#ffffff",
2893
3044
  textAlign: "center",
2894
3045
  border: "1px solid #eaeaea"
2895
- }, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
2896
- padding: "20px"
2897
3046
  }, children: [
2898
- /* @__PURE__ */ jsxRuntime.jsx("h2", { style: { color: "black" }, children: "Email Verification" }),
2899
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2900
- padding: "16px 20px",
2901
- margin: "24px 0",
2902
- borderRadius: "8px",
2903
- fontSize: "15px",
2904
- fontWeight: 500,
2905
- backgroundColor: isSuccess ? "#d4edda" : "#f8d7da",
2906
- color: isSuccess ? "#155724" : "#721c24",
2907
- border: isSuccess ? "1px solid #c3e6cb" : "1px solid #f5c6cb"
2908
- }, children: message }),
2909
- isSuccess && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
2910
- marginTop: "24px"
3047
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
3048
+ padding: "20px"
2911
3049
  }, children: [
2912
- /* @__PURE__ */ jsxRuntime.jsx("p", { style: { color: "black" }, children: "Your email has been successfully verified!" }),
2913
- /* @__PURE__ */ jsxRuntime.jsx(
2914
- "button",
2915
- {
2916
- onClick: () => window.location.href = "/login",
2917
- style: {
2918
- padding: "12px 24px",
2919
- backgroundColor: "#007bff",
2920
- color: "white",
2921
- border: "none",
2922
- borderRadius: "8px",
2923
- fontSize: "16px",
2924
- fontWeight: 600,
2925
- cursor: "pointer",
2926
- transition: "all 0.2s ease"
2927
- },
2928
- children: "Go to Login"
3050
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: { color: "black" }, children: isSuccess ? "\u2713 Email Verified!" : "\u2717 Verification Failed" }),
3051
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
3052
+ padding: "16px 20px",
3053
+ margin: "24px 0",
3054
+ borderRadius: "8px",
3055
+ fontSize: "15px",
3056
+ fontWeight: 500,
3057
+ backgroundColor: isSuccess ? "#d4edda" : "#f8d7da",
3058
+ color: isSuccess ? "#155724" : "#721c24",
3059
+ border: isSuccess ? "1px solid #c3e6cb" : "1px solid #f5c6cb"
3060
+ }, children: message }),
3061
+ isSuccess ? /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginTop: "24px" }, children: [
3062
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: { color: "#666", marginBottom: "16px" }, children: "Redirecting to login..." }),
3063
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
3064
+ border: "3px solid #d4edda",
3065
+ borderTop: "3px solid #28a745",
3066
+ borderRadius: "50%",
3067
+ width: "30px",
3068
+ height: "30px",
3069
+ animation: "spin 1s linear infinite",
3070
+ margin: "0 auto"
3071
+ } })
3072
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginTop: "24px" }, children: [
3073
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: { color: "#666", marginBottom: "16px" }, children: "The verification link may have expired or already been used." }),
3074
+ /* @__PURE__ */ jsxRuntime.jsx(
3075
+ "button",
3076
+ {
3077
+ onClick: () => {
3078
+ const registerPath = process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_REGISTER || process.env.REACT_APP_AUTH_REDIRECT_TO_REGISTER || "/auth/register";
3079
+ window.location.href = registerPath;
3080
+ },
3081
+ style: {
3082
+ padding: "12px 24px",
3083
+ backgroundColor: "#007bff",
3084
+ color: "white",
3085
+ border: "none",
3086
+ borderRadius: "8px",
3087
+ fontSize: "16px",
3088
+ fontWeight: 600,
3089
+ cursor: "pointer",
3090
+ transition: "all 0.2s ease",
3091
+ marginRight: "12px"
3092
+ },
3093
+ children: "Register Again"
3094
+ }
3095
+ ),
3096
+ /* @__PURE__ */ jsxRuntime.jsx(
3097
+ "button",
3098
+ {
3099
+ onClick: () => {
3100
+ const loginPath = process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_TO_LOGIN || "/auth/login";
3101
+ window.location.href = loginPath;
3102
+ },
3103
+ style: {
3104
+ padding: "12px 24px",
3105
+ backgroundColor: "#6c757d",
3106
+ color: "white",
3107
+ border: "none",
3108
+ borderRadius: "8px",
3109
+ fontSize: "16px",
3110
+ fontWeight: 600,
3111
+ cursor: "pointer",
3112
+ transition: "all 0.2s ease"
3113
+ },
3114
+ children: "Go to Login"
3115
+ }
3116
+ )
3117
+ ] })
3118
+ ] }),
3119
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
3120
+ @keyframes spin {
3121
+ 0% { transform: rotate(0deg); }
3122
+ 100% { transform: rotate(360deg); }
2929
3123
  }
2930
- )
2931
- ] })
2932
- ] }) });
3124
+ ` })
3125
+ ] });
2933
3126
  };
2934
3127
  var ThemeWrapper = React.forwardRef(
2935
3128
  ({ children, className = "", style }, ref) => {
@@ -5140,6 +5333,274 @@ var UserProfile = ({
5140
5333
  ] })
5141
5334
  ] });
5142
5335
  };
5336
+ var SuperAdminSignIn = ({ redirectUrl, appearance }) => {
5337
+ const { signIn, isSignedIn, loading: authLoading, user } = useAuth2();
5338
+ const colors = useThemeColors();
5339
+ const [email, setEmail] = React.useState("");
5340
+ const [password, setPassword] = React.useState("");
5341
+ const [showPassword, setShowPassword] = React.useState(false);
5342
+ const [isLoading, setIsLoading] = React.useState(false);
5343
+ const [error, setError] = React.useState(null);
5344
+ const [success, setSuccess] = React.useState(null);
5345
+ React.useEffect(() => {
5346
+ if (isSignedIn && user) {
5347
+ const isSuperAdmin = user.role === "SUPER_ADMIN" || user.role === "SUPERADMIN";
5348
+ if (isSuperAdmin) {
5349
+ const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
5350
+ const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
5351
+ window.location.href = `${baseUrl}${redirect}`;
5352
+ } else {
5353
+ setError("Access denied. Only Super Admin users can access this portal.");
5354
+ document.cookie = "auth_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT";
5355
+ document.cookie = "refresh_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT";
5356
+ }
5357
+ }
5358
+ }, [isSignedIn, user, redirectUrl]);
5359
+ const handleSubmit = async (e) => {
5360
+ e.preventDefault();
5361
+ setIsLoading(true);
5362
+ setError(null);
5363
+ setSuccess(null);
5364
+ try {
5365
+ const response = await signIn({ email, password });
5366
+ if (response.success) {
5367
+ const userRole = response.user?.role;
5368
+ const isSuperAdmin = userRole === "SUPER_ADMIN" || userRole === "SUPERADMIN";
5369
+ if (!isSuperAdmin) {
5370
+ document.cookie = "auth_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT";
5371
+ document.cookie = "refresh_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT";
5372
+ setError("Access denied. Only Super Admin users can access this portal.");
5373
+ return;
5374
+ }
5375
+ setSuccess("Login successful! Redirecting...");
5376
+ } else {
5377
+ setError(response.message || "Login failed. Please check your credentials.");
5378
+ }
5379
+ } catch (err) {
5380
+ setError(err instanceof Error ? err.message : "An error occurred during login.");
5381
+ } finally {
5382
+ setIsLoading(false);
5383
+ }
5384
+ };
5385
+ if (authLoading) {
5386
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", padding: "40px" }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Loading..." }) });
5387
+ }
5388
+ return /* @__PURE__ */ jsxRuntime.jsx(
5389
+ ThemeWrapper,
5390
+ {
5391
+ style: {
5392
+ maxWidth: "400px",
5393
+ margin: "0 auto",
5394
+ padding: "30px",
5395
+ borderRadius: "12px",
5396
+ boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
5397
+ backgroundColor: colors.bgPrimary,
5398
+ border: `1px solid ${colors.borderPrimary}`,
5399
+ ...appearance?.elements?.card
5400
+ },
5401
+ children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
5402
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { textAlign: "center", marginBottom: "24px" }, children: [
5403
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
5404
+ width: "60px",
5405
+ height: "60px",
5406
+ margin: "0 auto 16px",
5407
+ backgroundColor: colors.buttonPrimary + "20",
5408
+ borderRadius: "12px",
5409
+ display: "flex",
5410
+ alignItems: "center",
5411
+ justifyContent: "center"
5412
+ }, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", stroke: colors.buttonPrimary, strokeWidth: "2", children: [
5413
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" }),
5414
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 12l2 2 4-4" })
5415
+ ] }) }),
5416
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
5417
+ color: colors.textPrimary,
5418
+ fontSize: "24px",
5419
+ fontWeight: 600,
5420
+ margin: 0,
5421
+ ...appearance?.elements?.headerTitle
5422
+ }, children: "Super Admin Portal" }),
5423
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: {
5424
+ color: colors.textSecondary,
5425
+ fontSize: "14px",
5426
+ marginTop: "8px"
5427
+ }, children: "Sign in with your administrator credentials" })
5428
+ ] }),
5429
+ error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
5430
+ padding: "12px 16px",
5431
+ marginBottom: "20px",
5432
+ backgroundColor: colors.errorBg,
5433
+ color: colors.errorText,
5434
+ border: `1px solid ${colors.errorBorder}`,
5435
+ borderRadius: "8px",
5436
+ fontSize: "14px"
5437
+ }, children: error }),
5438
+ success && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
5439
+ padding: "12px 16px",
5440
+ marginBottom: "20px",
5441
+ backgroundColor: colors.successBg,
5442
+ color: colors.successText,
5443
+ border: `1px solid ${colors.successBorder}`,
5444
+ borderRadius: "8px",
5445
+ fontSize: "14px"
5446
+ }, children: success }),
5447
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
5448
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", style: {
5449
+ display: "block",
5450
+ marginBottom: "8px",
5451
+ fontWeight: 500,
5452
+ color: colors.textSecondary,
5453
+ fontSize: "14px"
5454
+ }, children: "Email Address" }),
5455
+ /* @__PURE__ */ jsxRuntime.jsx(
5456
+ "input",
5457
+ {
5458
+ id: "email",
5459
+ type: "email",
5460
+ value: email,
5461
+ onChange: (e) => setEmail(e.target.value),
5462
+ onFocus: (e) => {
5463
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
5464
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
5465
+ },
5466
+ onBlur: (e) => {
5467
+ e.currentTarget.style.borderColor = colors.borderSecondary;
5468
+ e.currentTarget.style.outline = "none";
5469
+ },
5470
+ required: true,
5471
+ disabled: isLoading,
5472
+ autoComplete: "email",
5473
+ style: {
5474
+ width: "100%",
5475
+ padding: "12px 16px",
5476
+ border: `1px solid ${colors.borderSecondary}`,
5477
+ borderRadius: "8px",
5478
+ fontSize: "16px",
5479
+ boxSizing: "border-box",
5480
+ backgroundColor: colors.bgSecondary,
5481
+ color: colors.textPrimary,
5482
+ transition: "all 0.2s ease",
5483
+ WebkitTextFillColor: colors.textPrimary,
5484
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
5485
+ ...appearance?.elements?.formFieldInput
5486
+ },
5487
+ placeholder: "admin@example.com"
5488
+ }
5489
+ )
5490
+ ] }),
5491
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "24px", position: "relative" }, children: [
5492
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", style: {
5493
+ display: "block",
5494
+ marginBottom: "8px",
5495
+ fontWeight: 500,
5496
+ color: colors.textSecondary,
5497
+ fontSize: "14px"
5498
+ }, children: "Password" }),
5499
+ /* @__PURE__ */ jsxRuntime.jsx(
5500
+ "input",
5501
+ {
5502
+ id: "password",
5503
+ type: showPassword ? "text" : "password",
5504
+ value: password,
5505
+ onChange: (e) => setPassword(e.target.value),
5506
+ onFocus: (e) => {
5507
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
5508
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
5509
+ },
5510
+ onBlur: (e) => {
5511
+ e.currentTarget.style.borderColor = colors.borderSecondary;
5512
+ e.currentTarget.style.outline = "none";
5513
+ },
5514
+ required: true,
5515
+ disabled: isLoading,
5516
+ autoComplete: "current-password",
5517
+ style: {
5518
+ width: "100%",
5519
+ padding: "12px 16px",
5520
+ paddingRight: "60px",
5521
+ border: `1px solid ${colors.borderSecondary}`,
5522
+ borderRadius: "8px",
5523
+ fontSize: "16px",
5524
+ boxSizing: "border-box",
5525
+ backgroundColor: colors.bgSecondary,
5526
+ color: colors.textPrimary,
5527
+ transition: "all 0.2s ease",
5528
+ WebkitTextFillColor: colors.textPrimary,
5529
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
5530
+ ...appearance?.elements?.formFieldInput
5531
+ },
5532
+ placeholder: "Enter your password"
5533
+ }
5534
+ ),
5535
+ /* @__PURE__ */ jsxRuntime.jsx(
5536
+ "button",
5537
+ {
5538
+ type: "button",
5539
+ onClick: () => setShowPassword(!showPassword),
5540
+ style: {
5541
+ position: "absolute",
5542
+ right: "12px",
5543
+ top: "38px",
5544
+ background: "none",
5545
+ border: "none",
5546
+ cursor: "pointer",
5547
+ color: colors.textTertiary,
5548
+ fontSize: "14px",
5549
+ padding: "4px 8px"
5550
+ },
5551
+ children: showPassword ? "Hide" : "Show"
5552
+ }
5553
+ )
5554
+ ] }),
5555
+ /* @__PURE__ */ jsxRuntime.jsx(
5556
+ "button",
5557
+ {
5558
+ type: "submit",
5559
+ disabled: isLoading || !email || !password,
5560
+ onMouseEnter: (e) => {
5561
+ if (!isLoading && email && password) {
5562
+ e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
5563
+ }
5564
+ },
5565
+ onMouseLeave: (e) => {
5566
+ e.currentTarget.style.backgroundColor = colors.buttonPrimary;
5567
+ },
5568
+ style: {
5569
+ width: "100%",
5570
+ padding: "14px",
5571
+ backgroundColor: colors.buttonPrimary,
5572
+ color: "white",
5573
+ border: "none",
5574
+ borderRadius: "8px",
5575
+ fontSize: "16px",
5576
+ fontWeight: 600,
5577
+ cursor: isLoading || !email || !password ? "not-allowed" : "pointer",
5578
+ opacity: isLoading || !email || !password ? 0.6 : 1,
5579
+ transition: "all 0.2s ease",
5580
+ ...appearance?.elements?.formButtonPrimary
5581
+ },
5582
+ children: isLoading ? "Signing in..." : "Sign In"
5583
+ }
5584
+ ),
5585
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
5586
+ marginTop: "20px",
5587
+ padding: "12px",
5588
+ backgroundColor: colors.bgSecondary,
5589
+ borderRadius: "8px",
5590
+ textAlign: "center"
5591
+ }, children: /* @__PURE__ */ jsxRuntime.jsxs("p", { style: {
5592
+ color: colors.textTertiary,
5593
+ fontSize: "12px",
5594
+ margin: 0
5595
+ }, children: [
5596
+ "\u{1F512} This portal is restricted to Super Admin users only.",
5597
+ /* @__PURE__ */ jsxRuntime.jsx("br", {}),
5598
+ "Contact your system administrator if you need access."
5599
+ ] }) })
5600
+ ] })
5601
+ }
5602
+ );
5603
+ };
5143
5604
  var AvatarManager = ({
5144
5605
  open,
5145
5606
  onOpenChange,
@@ -5433,6 +5894,7 @@ exports.ResetPassword = ResetPassword;
5433
5894
  exports.SignIn = SignIn;
5434
5895
  exports.SignOut = SignOut;
5435
5896
  exports.SignUp = SignUp;
5897
+ exports.SuperAdminSignIn = SuperAdminSignIn;
5436
5898
  exports.UserButton = UserButton;
5437
5899
  exports.UserProfile = UserProfile;
5438
5900
  exports.VerifyEmail = VerifyEmail;