refactor: enhance Sidebar component with Better Auth integration
- Replaced the use of `useConvexClient` with `useQuery` for fetching the current user. - Updated avatar URL retrieval to utilize the current user data from Better Auth. - Refactored login and logout functions to use the new `authClient` methods for improved authentication flow. - Cleaned up the component structure and styling for better readability and maintainability. - Adjusted sidebar and footer styles for consistency with the new design system.
This commit is contained in:
@@ -50,10 +50,21 @@ export const getCurrentUser = query({
|
||||
.query("usuarios")
|
||||
.withIndex("authId", (q) => q.eq("authId", authUser._id))
|
||||
.unique();
|
||||
|
||||
if (!user) {
|
||||
return;
|
||||
}
|
||||
return user;
|
||||
|
||||
if (!user.roleId) {
|
||||
return { ...user, role: null };
|
||||
}
|
||||
|
||||
const role = await ctx.db
|
||||
.query("roles")
|
||||
.withIndex("by_id", (q) => q.eq("_id", user.roleId))
|
||||
.unique();
|
||||
|
||||
return { ...user, role };
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user