import { useAuthStore } from '@/store/auth.store'
import { useRouter } from 'expo-router'

export function useAuth() {
  const { session, signOut } = useAuthStore()
  const router = useRouter()

  async function handleSignOut() {
    await signOut()
    router.replace('/(auth)/login')
  }

  return {
    session,
    isAuthenticated: !!session,
    signOut: handleSignOut,
  }
}
