1 Commits

Author SHA1 Message Date
cccb4604fd fixes for latest openapi spec changes 2026-05-23 17:22:30 +05:30
3 changed files with 16 additions and 13 deletions

View File

@@ -30,13 +30,13 @@ export function useResource<T = any>(config: ResourceConfig | undefined) {
}); });
// --- READ ONE --- // --- READ ONE ---
const useRead = (id: string | null) => const useRead = (id: string, params?: any | null) =>
useQuery({ useQuery({
queryKey: [name, "detail", id], queryKey: [name, "detail", id, params],
queryFn: async () => { queryFn: async () => {
if (!id || !endpoint) return null; if (!id || !endpoint) return null;
// @ts-ignore // @ts-ignore
const res = await api.get<T>(`${endpoint}/${id}`); const res = await api.get<T>(`${endpoint}/${id}`, params ? { params } : undefined);
return res.data; return res.data;
}, },
enabled: !!id && !!endpoint, enabled: !!id && !!endpoint,

View File

@@ -50,10 +50,10 @@ export default function Dashboard() {
}); });
React.useEffect(() => { React.useEffect(() => {
if (report.data?.data) { if (report.data) {
setLoadedPayees(prev => { setLoadedPayees(prev => {
const pSet = new Set<string>(prev); const pSet = new Set<string>(prev);
report.data.data.buckets.forEach((b: any) => { report.data.buckets.forEach((b: any) => {
Object.values(b.periods).forEach((periodArray: any) => { Object.values(b.periods).forEach((periodArray: any) => {
periodArray?.forEach((p: any) => { periodArray?.forEach((p: any) => {
p.metric?.transactions?.forEach((t: any) => { p.metric?.transactions?.forEach((t: any) => {
@@ -67,7 +67,7 @@ export default function Dashboard() {
setLoadedTags(prev => { setLoadedTags(prev => {
const tSet = new Set<string>(prev); const tSet = new Set<string>(prev);
report.data.data.buckets.forEach((b: any) => { report.data.buckets.forEach((b: any) => {
Object.values(b.periods).forEach((periodArray: any) => { Object.values(b.periods).forEach((periodArray: any) => {
periodArray?.forEach((p: any) => { periodArray?.forEach((p: any) => {
p.metric?.transactions?.forEach((t: any) => { p.metric?.transactions?.forEach((t: any) => {
@@ -79,7 +79,7 @@ export default function Dashboard() {
return Array.from(tSet).sort(); return Array.from(tSet).sort();
}); });
} }
}, [report.data?.data]); }, [report.data]);
const toggleFlow = const toggleFlow =
React.useCallback(() => { React.useCallback(() => {
@@ -219,7 +219,7 @@ export default function Dashboard() {
return null; return null;
} }
const data = prepareReport(report.data.data); const data = prepareReport(report.data);
return ( return (
<Box> <Box>
<Container> <Container>

View File

@@ -9,10 +9,13 @@ export interface ReportParams {
} }
export function useReport(params: ReportParams) { export function useReport(params: ReportParams) {
const { useList } = useResourceByName("reports"); const { useRead } = useResourceByName("reports");
return useList({ return useRead(
params.snapshot_id ? params.snapshot_id : "latest",
{
...params, ...params,
periods: params.periods, periods: params.periods,
}); }
);
} }