chore: refreshed project

This commit is contained in:
2024-08-02 02:02:31 +02:00
parent a10f12e568
commit 03e4330ab5
27 changed files with 2977 additions and 1104 deletions
+53
View File
@@ -0,0 +1,53 @@
import { defineStore } from 'pinia';
import { API } from '../typings/api';
import http from '../http';
export enum DataStatus {
LOADING = 0,
LOADED = 1,
ERROR = 2
}
export const useApiStore = defineStore('api', {
state() {
return {
activeData: undefined as API.ActiveData.Response | undefined,
stationData: undefined as API.Sceneries.Response | undefined,
dataStatuses: {
activeData: DataStatus.LOADING,
stationData: DataStatus.LOADING
}
};
},
actions: {
async fetchActiveData() {
try {
const response = (await http.get<API.ActiveData.Response | undefined>('api/getActiveData'))
.data;
this.dataStatuses.activeData = DataStatus.LOADED;
this.activeData = response;
} catch (error) {
this.dataStatuses.activeData = DataStatus.ERROR;
console.error('Wystąpił błąd podczas pobierania danych:', error);
}
},
async fetchSceneriesData() {
try {
const response = (await http.get<API.Sceneries.Response | undefined>('api/getSceneries'))
.data;
this.dataStatuses.stationData = DataStatus.LOADED;
this.stationData = response;
} catch (error) {
this.dataStatuses.stationData = DataStatus.ERROR;
console.error('Wystąpił błąd podczas pobierania danych:', error);
}
}
}
});