mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
refactor(stats): moved fetching daily stats data to store
This commit is contained in:
+19
-1
@@ -9,7 +9,8 @@ export const useApiStore = defineStore('apiStore', {
|
||||
dataStatuses: {
|
||||
connection: Status.Data.Loading,
|
||||
sceneries: Status.Data.Loading,
|
||||
vehicles: Status.Data.Loading
|
||||
vehicles: Status.Data.Loading,
|
||||
dailyStatsData: Status.Data.Loading
|
||||
},
|
||||
|
||||
activeData: undefined as API.ActiveData.Response | undefined,
|
||||
@@ -18,6 +19,8 @@ export const useApiStore = defineStore('apiStore', {
|
||||
donatorsData: [] as API.Donators.Response,
|
||||
sceneryData: [] as StationJSONData[],
|
||||
|
||||
dailyStatsData: null as API.DailyStats.Response | null,
|
||||
|
||||
nextUpdateTime: 0,
|
||||
nextDataCheckTime: 0,
|
||||
|
||||
@@ -119,6 +122,21 @@ export const useApiStore = defineStore('apiStore', {
|
||||
this.dataStatuses.vehicles = Status.Data.Error;
|
||||
console.error('Ups! Wystąpił błąd podczas pobierania informacji o pojazdach:', error);
|
||||
}
|
||||
},
|
||||
|
||||
async fetchDailyStats() {
|
||||
try {
|
||||
const res: API.DailyStats.Response = await (
|
||||
await this.client!.get('api/getDailyStats')
|
||||
).data;
|
||||
|
||||
this.dailyStatsData = res;
|
||||
|
||||
this.dataStatuses.dailyStatsData = Status.Data.Loaded;
|
||||
} catch (error) {
|
||||
console.error('Ups! Wystąpił błąd podczas pobierania statystyk rozkładów jazdy...');
|
||||
this.dataStatuses.dailyStatsData = Status.Data.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user