initial commit

This commit is contained in:
Jose Selesan
2026-05-28 14:33:16 -03:00
commit 7bc3d9f898
211 changed files with 161253 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import { getQuotes, fetchQuotes, getQuoteHistory, getDailyMinMax, getDailyQuotes } from "./api";
export const quoteKeys = {
all: ["quotes"] as const,
history: (type: string, startDate: string, endDate: string) =>
["quotes", type, "history", startDate, endDate] as const,
minMax: (type: string, startDate: string, endDate: string) =>
["quotes", type, "minMax", startDate, endDate] as const,
daily: (type: string, startDate: string, endDate: string) =>
["quotes", type, "daily", startDate, endDate] as const,
};
export function useQuotes() {
return useQuery({
queryKey: quoteKeys.all,
queryFn: getQuotes,
staleTime: 30_000,
refetchInterval: 60_000,
});
}
export function useFetchQuotes() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: fetchQuotes,
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: quoteKeys.all });
},
});
}
export function useQuoteHistory(type: string, startDate: string, endDate: string) {
return useQuery({
queryKey: quoteKeys.history(type, startDate, endDate),
queryFn: () => getQuoteHistory(type, startDate, endDate),
staleTime: 30_000,
refetchInterval: 60_000,
});
}
export function useDailyMinMax(type: string, startDate: string, endDate: string) {
return useQuery({
queryKey: quoteKeys.minMax(type, startDate, endDate),
queryFn: () => getDailyMinMax(type, startDate, endDate),
staleTime: 30_000,
refetchInterval: 60_000,
});
}
export function useDailyQuotes(type: string, startDate: string, endDate: string) {
return useQuery({
queryKey: quoteKeys.daily(type, startDate, endDate),
queryFn: () => getDailyQuotes(type, startDate, endDate),
staleTime: 30_000,
refetchInterval: 60_000,
});
}