🐛 Fixed tile delete handler

This commit is contained in:
Manuel Ruwe
2022-12-31 14:11:30 +01:00
parent 2e463aea53
commit 78bc883667

View File

@@ -1,3 +1,5 @@
import { useConfigContext } from '../../../../config/provider';
import { useConfigStore } from '../../../../config/store';
import { openContextModalGeneric } from '../../../../tools/mantineModalManagerExtensions';
import { AppType } from '../../../../types/app';
import { GenericTileMenu } from '../GenericTileMenu';
@@ -7,6 +9,9 @@ interface TileMenuProps {
}
export const AppMenu = ({ app }: TileMenuProps) => {
const { config, name: configName } = useConfigContext();
const { updateConfig } = useConfigStore();
const handleClickEdit = () => {
openContextModalGeneric<{ app: AppType; allowAppNamePropagation: boolean }>({
modal: 'editApp',
@@ -37,7 +42,16 @@ export const AppMenu = ({ app }: TileMenuProps) => {
});
};
const handleClickDelete = () => {};
const handleClickDelete = () => {
if (configName === undefined) {
return;
}
updateConfig(configName, (previousConfig) => ({
...previousConfig,
apps: previousConfig.apps.filter((a) => a.id !== app.id),
}));
};
return (
<GenericTileMenu