Add check for deletion of default config

This commit is contained in:
Manuel
2023-01-15 22:31:46 +01:00
parent 69199bdc9c
commit 0efc9ebb55
5 changed files with 42 additions and 13 deletions

View File

@@ -27,6 +27,12 @@ export const useConfigStore = create<UseConfigStoreType>((set, get) => ({
}
axios.put(`/api/configs/${name}`, { ...config });
},
removeConfig: (name: string) => {
set((old) => ({
...old,
configs: old.configs.filter((x) => x.value.configProperties.name !== name),
}));
},
updateConfig: async (
name,
updateCallback: (previous: ConfigType) => ConfigType,
@@ -72,6 +78,7 @@ interface UseConfigStoreType {
config: ConfigType,
shouldSaveConfigToFileSystem: boolean
) => Promise<void>;
removeConfig: (name: string) => void;
updateConfig: (
name: string,
updateCallback: (previous: ConfigType) => ConfigType,