@sanvika/auth 1.0.24 → 1.0.26
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/dist/index.js +17 -4
- 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(
|
|
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(
|
|
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,17 @@ 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
244
|
onClick: () => {
|
|
245
|
+
console.log("[SanvikaAccountButton] Guest button clicked, redirecting to /authorize");
|
|
233
246
|
if (onLoginClick) {
|
|
234
247
|
onLoginClick();
|
|
235
248
|
} else {
|
|
236
|
-
window.location.href = "
|
|
249
|
+
window.location.href = "/authorize";
|
|
237
250
|
}
|
|
238
251
|
},
|
|
239
252
|
"aria-label": "Login or Sign Up",
|
|
@@ -344,7 +357,7 @@ function SanvikaAccountButtonContent({
|
|
|
344
357
|
/* @__PURE__ */ jsxs(
|
|
345
358
|
"a",
|
|
346
359
|
{
|
|
347
|
-
href: "
|
|
360
|
+
href: "/dashboard",
|
|
348
361
|
className: "snvk-dropdownItem",
|
|
349
362
|
role: "menuitem",
|
|
350
363
|
onClick: () => setDropdownOpen(false),
|