2025-12-26 08:11:41 +00:00
|
|
|
import { useAuthStore } from '../store/authStore';
|
2025-12-16 19:40:16 +00:00
|
|
|
import { TokenStorage } from '@/services/tokenStorage';
|
state-ownership: replace all useAuthStore().user with useUser() hook
- Migrated all hooks: useAuth, useChat, useLogin
- Migrated all components: Header, ProfileForm, FollowButton, LikeButton, PlaylistFollowButton, ChatMessage, ChatMessages, CommentThread, CommentSection, PlaylistList, ChatSidebar, SettingsPage, DashboardPage
- Updated storeSelectors.ts useAuthUser() to use React Query
- All production code now uses useUser() hook instead of Zustand store
- Action 4.1.1.3 and 4.1.1.4 complete
2026-01-14 00:45:42 +00:00
|
|
|
import { useUser } from './useUser';
|
2025-12-03 21:56:50 +00:00
|
|
|
|
|
|
|
|
export const useAuth = () => {
|
state-ownership: replace all useAuthStore().user with useUser() hook
- Migrated all hooks: useAuth, useChat, useLogin
- Migrated all components: Header, ProfileForm, FollowButton, LikeButton, PlaylistFollowButton, ChatMessage, ChatMessages, CommentThread, CommentSection, PlaylistList, ChatSidebar, SettingsPage, DashboardPage
- Updated storeSelectors.ts useAuthUser() to use React Query
- All production code now uses useUser() hook instead of Zustand store
- Action 4.1.1.3 and 4.1.1.4 complete
2026-01-14 00:45:42 +00:00
|
|
|
const { isAuthenticated, logout: storeLogout } = useAuthStore();
|
|
|
|
|
const { data: user } = useUser();
|
2025-12-03 21:56:50 +00:00
|
|
|
|
|
|
|
|
const logout = async () => {
|
2025-12-16 19:40:16 +00:00
|
|
|
// Le store gère déjà le logout via la méthode logout
|
|
|
|
|
await storeLogout();
|
2025-12-03 21:56:50 +00:00
|
|
|
};
|
|
|
|
|
|
2025-12-16 19:40:16 +00:00
|
|
|
const accessToken = TokenStorage.getAccessToken();
|
2025-12-03 21:56:50 +00:00
|
|
|
|
|
|
|
|
return {
|
state-ownership: replace all useAuthStore().user with useUser() hook
- Migrated all hooks: useAuth, useChat, useLogin
- Migrated all components: Header, ProfileForm, FollowButton, LikeButton, PlaylistFollowButton, ChatMessage, ChatMessages, CommentThread, CommentSection, PlaylistList, ChatSidebar, SettingsPage, DashboardPage
- Updated storeSelectors.ts useAuthUser() to use React Query
- All production code now uses useUser() hook instead of Zustand store
- Action 4.1.1.3 and 4.1.1.4 complete
2026-01-14 00:45:42 +00:00
|
|
|
user: user ?? null,
|
2025-12-16 19:40:16 +00:00
|
|
|
accessToken: accessToken || null,
|
|
|
|
|
refreshToken: TokenStorage.getRefreshToken() || null,
|
2025-12-03 21:56:50 +00:00
|
|
|
isAuthenticated,
|
|
|
|
|
logout,
|
|
|
|
|
};
|
2025-12-13 02:34:34 +00:00
|
|
|
};
|