mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-11 05:42:19 +00:00
lint: enforce api-fetch wrapper across src/lib/queries
Add src/lib/queries/ to the api-fetch-required ENFORCED_ROOTS so the rule matches its own header comment, then route the two flagged query hooks through apiGet instead of hand-rolling the envelope unwrap.
This commit is contained in:
1 parent
234c43e4da
commit
320c33b918
3 files changed
+18
-21
No files matched your search
@@ -3,6 +3,7 @@
|
||||
import { useQuery, type UseQueryResult } from "@tanstack/react-query";
|
||||
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
import { apiGet } from "@/lib/api/api-fetch";
|
||||
import { queryKeys } from "@/lib/query-keys";
|
||||
import type {
|
||||
AchievementMetrics,
|
||||
@@ -65,13 +66,8 @@ export interface UseAchievementsQueryOptions {
|
||||
refetchInterval?: number | false;
|
||||
}
|
||||
|
||||
async function fetchAchievements(): Promise<AchievementsPayload> {
|
||||
const res = await fetch("/api/gamification/achievements");
|
||||
if (!res.ok) {
|
||||
throw new Error(`Failed to load achievements (${res.status})`);
|
||||
}
|
||||
const json = (await res.json()) as { data: AchievementsPayload };
|
||||
return json.data;
|
||||
function fetchAchievements(): Promise<AchievementsPayload> {
|
||||
return apiGet<AchievementsPayload>("/api/gamification/achievements");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { useQuery, type UseQueryResult } from "@tanstack/react-query";
|
||||
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
import { apiGet } from "@/lib/api/api-fetch";
|
||||
import { queryKeys } from "@/lib/query-keys";
|
||||
import { DASHBOARD_REFETCH_INTERVAL_MS } from "@/lib/queries/refetch-interval";
|
||||
import type { DataSummary } from "@/lib/analytics/trends";
|
||||
@@ -114,18 +115,10 @@ export interface UseAnalyticsQueryOptions {
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
async function fetchAnalytics(
|
||||
slice: AnalyticsSlice,
|
||||
): Promise<AnalyticsRawPayload> {
|
||||
const res =
|
||||
slice === "summaries"
|
||||
? await fetch("/api/analytics?slice=summaries")
|
||||
: await fetch("/api/analytics");
|
||||
if (!res.ok) {
|
||||
throw new Error(`Failed to load analytics (${res.status})`);
|
||||
}
|
||||
const json = (await res.json()) as { data: AnalyticsRawPayload };
|
||||
return json.data;
|
||||
function fetchAnalytics(slice: AnalyticsSlice): Promise<AnalyticsRawPayload> {
|
||||
return apiGet<AnalyticsRawPayload>(
|
||||
slice === "summaries" ? "/api/analytics?slice=summaries" : "/api/analytics",
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user