@sanvika/auth 1.0.25 → 1.0.27

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.
Files changed (2) hide show
  1. package/dist/index.js +23 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -29,13 +29,19 @@ function SanvikaAuthProvider({ children }) {
29
29
  if (storedToken && storedUser) {
30
30
  setToken(storedToken);
31
31
  setUser(JSON.parse(storedUser));
32
- console.log("[SanvikaAuthProvider] User loaded:", JSON.parse(storedUser).firstName);
32
+ console.log(
33
+ "[SanvikaAuthProvider] User loaded:",
34
+ JSON.parse(storedUser).firstName
35
+ );
33
36
  }
34
37
  } catch (e) {
35
38
  console.error("[SanvikaAuth] Failed to load from localStorage:", e);
36
39
  } finally {
37
40
  setLoading(false);
38
- console.log("[SanvikaAuthProvider] Loading complete, isAuthenticated:", !!user);
41
+ console.log(
42
+ "[SanvikaAuthProvider] Loading complete, isAuthenticated:",
43
+ !!user
44
+ );
39
45
  }
40
46
  }, []);
41
47
  const login = async ({ mobile, password, deviceId, deviceName }) => {
@@ -86,6 +92,11 @@ function SanvikaAuthProvider({ children }) {
86
92
  login,
87
93
  logout
88
94
  };
95
+ console.log("[SanvikaAuthProvider] Providing context value:", {
96
+ user: (user == null ? void 0 : user.firstName) || null,
97
+ loading,
98
+ isAuthenticated: !!user
99
+ });
89
100
  return /* @__PURE__ */ jsx(SanvikaAuthContext.Provider, { value, children });
90
101
  }
91
102
  function useSanvikaAuth() {
@@ -225,15 +236,22 @@ function SanvikaAccountButtonContent({
225
236
  return () => document.removeEventListener("mousedown", handleOutside);
226
237
  }, [dropdownOpen]);
227
238
  if (!auth) {
239
+ console.log("[SanvikaAccountButton] Auth is null, showing guest button");
228
240
  return /* @__PURE__ */ jsxs(
229
241
  "button",
230
242
  {
231
243
  className: `snvk-guestBtn ${className}`,
232
- onClick: () => {
244
+ onClick: (e) => {
245
+ console.log("[SanvikaAccountButton] \u2705\u2705\u2705 BUTTON CLICKED!");
246
+ console.log("[SanvikaAccountButton] Event target:", e.target);
247
+ console.log("[SanvikaAccountButton] Current URL:", window.location.href);
233
248
  if (onLoginClick) {
249
+ console.log("[SanvikaAccountButton] Calling custom onLoginClick");
234
250
  onLoginClick();
235
251
  } else {
236
- window.location.href = "https://accounts.sanvikaproduction.com";
252
+ console.log("[SanvikaAccountButton] Redirecting to /authorize...");
253
+ console.log("[SanvikaAccountButton] Target URL:", window.location.origin + "/authorize");
254
+ window.location.href = "/authorize";
237
255
  }
238
256
  },
239
257
  "aria-label": "Login or Sign Up",
@@ -344,7 +362,7 @@ function SanvikaAccountButtonContent({
344
362
  /* @__PURE__ */ jsxs(
345
363
  "a",
346
364
  {
347
- href: "https://accounts.sanvikaproduction.com/dashboard",
365
+ href: "/dashboard",
348
366
  className: "snvk-dropdownItem",
349
367
  role: "menuitem",
350
368
  onClick: () => setDropdownOpen(false),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanvika/auth",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "description": "Sanvika Auth SDK — React components and hooks for Sanvika SSO integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",