Files
honeyDueWeb/src/lib/hooks/use-auth.ts
T
Trey t 5a50d77515 feat: complete Phase 3 — advanced features for Casera web app
Adds sharing (residence share codes, join, user management, .casera file
export/import), subscription status with feature comparison, notification
preferences with bell icon, profile settings (edit info, change password,
theme picker, delete account), onboarding wizard with create/join paths,
enhanced dashboard with stats cards, Recharts completion chart, recent
activity feed, and task report PDF download.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 09:31:29 -06:00

28 lines
643 B
TypeScript

"use client";
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import * as authApi from '@/lib/api/auth';
import { useRouter } from 'next/navigation';
export function useCurrentUser() {
return useQuery({
queryKey: ['auth', 'user'],
queryFn: () => authApi.getCurrentUser(),
retry: false,
staleTime: 5 * 60 * 1000, // 5 minutes
});
}
export function useLogout() {
const queryClient = useQueryClient();
const router = useRouter();
return useMutation({
mutationFn: () => authApi.logout(),
onSuccess: () => {
queryClient.clear();
router.push('/login');
},
});
}