- Replace hand-coded skeleton CSS/JSX with boneyard-js auto-generated bones - Remove skeleton.css and @keyframes shimmer from base.css - Add <Skeleton> wrappers with fixtures to all 25+ page components - Generate 20 bone captures via boneyard CLI (CDP auth-gated capture) - Refactor data fetching from useEffect+useState to TanStack Query - Extract query hooks into src/admin/lib/queries/ and apiAdapter - Add usePaginatedQuery hook replacing useApiCall/useListData - Fix parseFloat || 0 anti-pattern in OfferDetail and OffersTemplates inputs - Fix customer_id mandatory validation on offer creation - Fix leave-requests comma-separated status filter (Prisma enum in: []) - Add cross-entity cache invalidation for orders/offers/invoices/projects - Make rate limits configurable via env vars (RATE_LIMIT_MAX, RATE_LIMIT_REFRESH, etc.) - Add boneyard.config.json with routes and breakpoints Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { queryOptions } from "@tanstack/react-query";
|
|
import apiFetch from "../../utils/api";
|
|
import { jsonQuery } from "../apiAdapter";
|
|
|
|
export const dashboardOptions = () =>
|
|
queryOptions({
|
|
queryKey: ["dashboard"],
|
|
queryFn: () => jsonQuery<Record<string, unknown>>("/api/admin/dashboard"),
|
|
staleTime: 60_000,
|
|
});
|
|
|
|
export const require2FAOptions = () =>
|
|
queryOptions({
|
|
queryKey: ["settings", "2fa"],
|
|
queryFn: () =>
|
|
jsonQuery<{ require_2fa: boolean }>("/api/admin/totp/required"),
|
|
});
|
|
|
|
export interface Session {
|
|
id: number | string;
|
|
is_current: boolean;
|
|
device_info?: {
|
|
icon?: string;
|
|
browser?: string;
|
|
os?: string;
|
|
};
|
|
ip_address: string;
|
|
created_at: string;
|
|
}
|
|
|
|
export const sessionsOptions = () =>
|
|
queryOptions({
|
|
queryKey: ["sessions"],
|
|
queryFn: async (): Promise<Session[]> => {
|
|
const response = await apiFetch("/api/admin/sessions");
|
|
const data = await response.json();
|
|
if (data.success) {
|
|
return Array.isArray(data.data) ? data.data : data.data?.sessions || [];
|
|
}
|
|
throw new Error(data.error || "Nepodařilo se načíst relace");
|
|
},
|
|
});
|