Migrace na OpenAPI - TypeScript typy
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { WeeklyStats, DayData, Locations, DailyStats, LocationKey } from "../../types";
|
||||
import { DailyStats, LunchChoice, WeeklyStats } from "../../types";
|
||||
import { getStatsMock } from "./mock";
|
||||
import { getClientData } from "./service";
|
||||
import getStorage from "./storage";
|
||||
import { formatDate } from "./utils";
|
||||
|
||||
@@ -32,10 +33,14 @@ export async function getStats(startDate: string, endDate: string): Promise<Week
|
||||
date: `${String(date.getDate()).padStart(2, "0")}.${String(date.getMonth() + 1).padStart(2, "0")}.`,
|
||||
locations: {}
|
||||
}
|
||||
const data: DayData = await storage.getData(formatDate(date));
|
||||
const data = await getClientData(date);
|
||||
if (data?.choices) {
|
||||
Object.keys(data.choices).forEach(locationKey => {
|
||||
locationsStats.locations[locationKey as LocationKey] = Object.keys(data.choices[locationKey as LocationKey]!).length;
|
||||
if (!locationsStats.locations) {
|
||||
locationsStats.locations = {}
|
||||
}
|
||||
// TODO dořešit, tohle je zmatek a té hlášce Sonaru nerozumím
|
||||
locationsStats.locations[locationKey as keyof typeof LunchChoice] = Object.keys(data.choices[locationKey as keyof typeof LunchChoice]!).length;
|
||||
})
|
||||
}
|
||||
result.push(locationsStats);
|
||||
|
||||
Reference in New Issue
Block a user