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

@@ -9,7 +9,8 @@ import {
type NodeProps,
type Node,
} from "@xyflow/react";
import { useMutation, useAction, useQuery } from "convex/react";
import { useMutation, useAction } from "convex/react";
import { useAuthQuery } from "@/hooks/use-auth-query";
import { api } from "@/convex/_generated/api";
import type { Id } from "@/convex/_generated/dataModel";
import BaseNodeWrapper from "./base-node-wrapper";
@@ -108,7 +109,7 @@ export default function PromptNode({
const dataRef = useRef(data);
dataRef.current = data;
const balance = useQuery(api.credits.getBalance);
const balance = useAuthQuery(api.credits.getBalance);
const creditCost = getModel(DEFAULT_MODEL_ID)?.creditCost ?? 4;
const availableCredits =