mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
feat: add top tracks report
This commit is contained in:
parent
60dc25f15e
commit
51fd78f6d9
11 changed files with 230 additions and 0 deletions
|
|
@ -4,11 +4,13 @@ import {
|
|||
getRecentListens,
|
||||
getTopAlbums,
|
||||
getTopArtists,
|
||||
getTopTracks,
|
||||
} 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 { TopTracksOptions } from "../api/entities/top-tracks-options";
|
||||
import { useApiClient } from "./use-api-client";
|
||||
import { useAsync } from "./use-async";
|
||||
|
||||
|
|
@ -81,3 +83,19 @@ export const useTopAlbums = (options: TopAlbumsOptions) => {
|
|||
|
||||
return { topAlbums, isLoading, error };
|
||||
};
|
||||
|
||||
export const useTopTracks = (options: TopTracksOptions) => {
|
||||
const { client } = useApiClient();
|
||||
|
||||
const fetchData = useMemo(() => () => getTopTracks(options, client), [
|
||||
options,
|
||||
client,
|
||||
]);
|
||||
|
||||
const { value: topTracks, pending: isLoading, error } = useAsync(
|
||||
fetchData,
|
||||
INITIAL_EMPTY_ARRAY
|
||||
);
|
||||
|
||||
return { topTracks, isLoading, error };
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue