Create ClearNodesButton.tsx

This commit is contained in:
mickr777 2023-07-13 14:40:09 +10:00 committed by GitHub
parent 10bb05b753
commit c7dcf1f4a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,41 @@
import { useAppDispatch } from 'app/store/storeHooks';
import { clearNodes } from 'features/nodes/store/nodesSlice';
import { makeToast } from 'app/components/Toaster';
import { addToast } from 'features/system/store/systemSlice';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { FaTrash } from 'react-icons/fa';
import IAIIconButton from 'common/components/IAIIconButton';
const ClearNodesButton = () => {
const { t } = useTranslation();
const dispatch = useAppDispatch();
const handleClearNodes = () => {
const confirmed = window.confirm(t('common.clearNodes'));
if (confirmed) {
dispatch(clearNodes());
dispatch(
addToast(
makeToast({
title: t('toast.nodesCleared'),
status: 'success',
})
)
);
}
};
return (
<IAIIconButton
icon={<FaTrash />}
tooltip={t('nodes.clearNodes')}
aria-label={t('nodes.clearNodes')}
onClick={handleClearNodes}
/>
);
};
export default memo(ClearNodesButton);