Initial setup for new frontend.

This commit is contained in:
baldo 2022-02-22 15:39:39 +01:00
parent 7671bfd4d3
commit 59f7897d8e
33 changed files with 2594 additions and 12 deletions
frontend/src/stores

View file

@ -0,0 +1,38 @@
import { defineStore } from "pinia";
import { isObject, isVersion, type Version } from "@/types";
import { api } from "@/utils/Api";
interface VersionResponse {
version: Version;
}
function isVersionResponse(arg: unknown): arg is VersionResponse {
return isObject(arg) && isVersion((arg as VersionResponse).version);
}
interface VersionStoreState {
version: Version | null;
}
export const useVersionStore = defineStore({
id: "version",
state(): VersionStoreState {
return {
version: null,
};
},
getters: {
getVersion(state: VersionStoreState): Version | null {
return state.version;
},
},
actions: {
async refresh(): Promise<void> {
const response = await api.get<VersionResponse>(
"version",
isVersionResponse
);
this.version = response.version;
},
},
});