-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathSelectionToolbar.tsx
61 lines (57 loc) · 1.77 KB
/
SelectionToolbar.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { Trash } from '@osrd-project/ui-icons';
import { useTranslation } from 'react-i18next';
import { AiFillCheckCircle } from 'react-icons/ai';
import { MdOutlineDeselect } from 'react-icons/md';
import { useModal } from 'common/BootstrapSNCF/ModalSNCF';
import DeleteItemsModal from 'modules/project/components/DeleteItemsModal';
type SelectionToolbarProps = {
selectedItemCount: number;
onDeselectAll: () => void;
onDelete: () => void;
translationKey: string;
translationNameSpace: string;
dataTestId: string;
};
const SelectionToolbar = ({
selectedItemCount,
onDeselectAll,
onDelete,
translationKey,
translationNameSpace,
dataTestId,
}: SelectionToolbarProps) => {
const { t } = useTranslation(translationNameSpace);
const { openModal } = useModal();
return (
<div className="selection-toolbar">
<AiFillCheckCircle />
<span className="ml-0">
{t(`${translationNameSpace}:${translationKey}`, { count: selectedItemCount })}
</span>
<button className="btn btn-sm btn-secondary" type="button" onClick={onDeselectAll}>
<MdOutlineDeselect />
<span className="ml-2">{t(`${translationNameSpace}:unselectAll`)}</span>
</button>
<button
data-testid={dataTestId}
className="btn btn-sm btn-danger"
type="button"
onClick={() =>
openModal(
<DeleteItemsModal
handleDeleteItems={onDelete}
translationKey={t(`${translationNameSpace}:confirmDeleteMessage`, {
count: selectedItemCount,
})}
/>,
'sm'
)
}
>
<Trash />
<span className="ml-2">{t(`${translationNameSpace}:deleteItems`)}</span>
</button>
</div>
);
};
export default SelectionToolbar;