-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathButtonMapInfraErrors.tsx
39 lines (33 loc) · 1.13 KB
/
ButtonMapInfraErrors.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import cx from 'classnames';
import { useTranslation } from 'react-i18next';
import { BsExclamationOctagon } from 'react-icons/bs';
import type { Layer } from 'applications/editor/consts';
import { type EditorState, editorSliceActions } from 'reducers/editor';
import { useAppDispatch } from 'store';
interface ButtonMapInfraErrorsProps {
editorState: EditorState;
}
const ButtonMapInfraErrors = ({ editorState }: ButtonMapInfraErrorsProps) => {
const dispatch = useAppDispatch();
const { t } = useTranslation('translation');
const toggleInfraErrors = () => {
const newSet = new Set<Layer>(editorState.editorLayers);
if (newSet.has('errors')) newSet.delete('errors');
else newSet.add('errors');
dispatch(editorSliceActions.selectLayers(newSet));
};
return (
<button
type="button"
className={cx('editor-btn btn-rounded', {
active: editorState.editorLayers.has('errors'),
})}
aria-label={t('common.toggleInfraErrors')}
title={t('common.toggleInfraErrors')}
onClick={toggleInfraErrors}
>
<BsExclamationOctagon />
</button>
);
};
export default ButtonMapInfraErrors;