mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
feat: introduce new report "Top Albums"
This commit is contained in:
parent
09858076bf
commit
9896ea31ff
16 changed files with 246 additions and 9 deletions
|
|
@ -1,7 +1,13 @@
|
|||
import { useMemo, useState } from "react";
|
||||
import { getListensReport, getRecentListens, getTopArtists } from "../api/api";
|
||||
import { useMemo } from "react";
|
||||
import {
|
||||
getListensReport,
|
||||
getRecentListens,
|
||||
getTopAlbums,
|
||||
getTopArtists,
|
||||
} from "../api/api";
|
||||
import { ListenReportOptions } from "../api/entities/listen-report-options";
|
||||
import { PaginationOptions } from "../api/entities/pagination-options";
|
||||
import { TopAlbumsOptions } from "../api/entities/top-albums-options";
|
||||
import { TopArtistsOptions } from "../api/entities/top-artists-options";
|
||||
import { useApiClient } from "./use-api-client";
|
||||
import { useAsync } from "./use-async";
|
||||
|
|
@ -59,3 +65,19 @@ export const useTopArtists = (options: TopArtistsOptions) => {
|
|||
|
||||
return { topArtists, isLoading, error };
|
||||
};
|
||||
|
||||
export const useTopAlbums = (options: TopAlbumsOptions) => {
|
||||
const { client } = useApiClient();
|
||||
|
||||
const fetchData = useMemo(() => () => getTopAlbums(options, client), [
|
||||
options,
|
||||
client,
|
||||
]);
|
||||
|
||||
const { value: topAlbums, pending: isLoading, error } = useAsync(
|
||||
fetchData,
|
||||
INITIAL_EMPTY_ARRAY
|
||||
);
|
||||
|
||||
return { topAlbums, isLoading, error };
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue