mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-09 15:05:48 +01:00
✨ Add functionallity to remove modal
This commit is contained in:
@@ -2,9 +2,11 @@ import React from 'react';
|
|||||||
import { Button, Group, Stack, Text } from '@mantine/core';
|
import { Button, Group, Stack, Text } from '@mantine/core';
|
||||||
import { ContextModalProps } from '@mantine/modals';
|
import { ContextModalProps } from '@mantine/modals';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
|
import { useConfigContext } from '../../../../config/provider';
|
||||||
|
import { useConfigStore } from '../../../../config/store';
|
||||||
|
|
||||||
export type WidgetsRemoveModalInnerProps = {
|
export type WidgetsRemoveModalInnerProps = {
|
||||||
integration: string;
|
widgetId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const WidgetsRemoveModal = ({
|
export const WidgetsRemoveModal = ({
|
||||||
@@ -12,9 +14,15 @@ export const WidgetsRemoveModal = ({
|
|||||||
id,
|
id,
|
||||||
innerProps,
|
innerProps,
|
||||||
}: ContextModalProps<WidgetsRemoveModalInnerProps>) => {
|
}: 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 = () => {
|
const handleDeletion = () => {
|
||||||
// TODO: remove tile
|
updateConfig(configName, (prev) => ({
|
||||||
|
...prev,
|
||||||
|
widgets: prev.widgets.filter((w) => w.id !== innerProps.widgetId),
|
||||||
|
}));
|
||||||
context.closeModal(id);
|
context.closeModal(id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user