Add functionallity to remove modal

This commit is contained in:
Meierschlumpf
2022-12-19 19:01:50 +01:00
parent e723c1d374
commit 25fd3a1594

View File

@@ -2,9 +2,11 @@ import React from 'react';
import { Button, Group, Stack, Text } from '@mantine/core';
import { ContextModalProps } from '@mantine/modals';
import { useTranslation } from 'next-i18next';
import { useConfigContext } from '../../../../config/provider';
import { useConfigStore } from '../../../../config/store';
export type WidgetsRemoveModalInnerProps = {
integration: string;
widgetId: string;
};
export const WidgetsRemoveModal = ({
@@ -12,9 +14,15 @@ export const WidgetsRemoveModal = ({
id,
innerProps,
}: ContextModalProps<WidgetsRemoveModalInnerProps>) => {
const { t } = useTranslation([`modules/${innerProps.integration}`, 'common']);
const { t } = useTranslation([`modules/${innerProps.widgetId}`, 'common']);
const { name: configName } = useConfigContext();
if (!configName) return null;
const updateConfig = useConfigStore((x) => x.updateConfig);
const handleDeletion = () => {
// TODO: remove tile
updateConfig(configName, (prev) => ({
...prev,
widgets: prev.widgets.filter((w) => w.id !== innerProps.widgetId),
}));
context.closeModal(id);
};