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:
2025-11-08 09:48:12 -03:00
parent 3a32f5e4eb
commit 28107b4050
2 changed files with 232 additions and 169 deletions

View File

@@ -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 };
},
});