refactor: use TimeOptions for Listens report

This commit is contained in:
Julian Tölle 2020-07-12 17:17:50 +02:00
parent 5bc76f23d0
commit 67ea28aec7
7 changed files with 51 additions and 59 deletions

View file

@ -79,13 +79,17 @@ export const getRecentListens = async (
export const getListensReport = async (
options: ListenReportOptions
): Promise<ListenReportItem[]> => {
const { timeFrame, timeStart, timeEnd } = options;
const {
timeFrame,
time: { timePreset, customTimeStart, customTimeEnd },
} = options;
const res = await fetch(
`/api/v1/reports/listens?${qs({
timeFrame,
timeStart: formatISO(timeStart),
timeEnd: formatISO(timeEnd),
timePreset,
customTimeStart: formatISO(customTimeStart),
customTimeEnd: formatISO(customTimeEnd),
})}`,
{
headers: getDefaultHeaders(),

View file

@ -1,5 +1,6 @@
import { TimeOptions } from "./time-options";
export interface ListenReportOptions {
timeFrame: "day" | "week" | "month" | "year";
timeStart: Date;
timeEnd: Date;
time: TimeOptions;
}