feat: add add new config strategy to frontend

This commit is contained in:
Elias Schneider
2022-11-28 17:50:36 +01:00
parent 1b5e53ff7e
commit 493705e4ef
20 changed files with 183 additions and 102 deletions

View File

@@ -0,0 +1,23 @@
import Config from "../types/config.type";
import api from "./api.service";
const getAll = async (): Promise<Config[]> => {
return (await api.get("/configs")).data;
};
const get = (key: string, configVariables: Config[]): any => {
const configVariable = configVariables.filter(
(variable) => variable.key == key
)[0];
if (!configVariable) throw new Error(`Config variable ${key} not found`);
if (configVariable.type == "number") return parseInt(configVariable.value);
if (configVariable.type == "boolean") return configVariable.value == "true";
if (configVariable.type == "string") return configVariable.value;
};
export default {
getAll,
get,
};