refactor: replace useQuery with useAuthQuery for improved authentication handling

- Updated multiple components to utilize useAuthQuery instead of useQuery for fetching user-related data, enhancing authentication management.
- Adjusted balance and subscription queries across various components including InitUser, ManageSubscription, PricingCards, CreditDisplay, and others to ensure consistent authentication checks.
- Improved overall code maintainability by centralizing authentication logic in the new hook.
This commit is contained in:
Matthias
2026-03-27 18:35:12 +01:00
parent 2f89465e82
commit 6e38e2d270
9 changed files with 48 additions and 25 deletions

View File

@@ -1,6 +1,6 @@
"use client";
import { useQuery } from "convex/react";
import { useAuthQuery } from "@/hooks/use-auth-query";
import { ExternalLink } from "lucide-react";
import { Badge } from "@/components/ui/badge";
@@ -19,7 +19,7 @@ const TIER_LABELS: Record<keyof typeof TIER_MONTHLY_CREDITS, string> = {
};
export function ManageSubscription() {
const subscription = useQuery(api.credits.getSubscription);
const subscription = useAuthQuery(api.credits.getSubscription);
const tier = normalizeTier(subscription?.tier);
return (