mirror of
https://github.com/sergeyyarkov/educt-client.git
synced 2026-10-11 10:19:22 +03:00
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import React from 'react';
|
|
import { Button, Menu, MenuButton, MenuList, MenuItem } from '@chakra-ui/react';
|
|
import { ChevronDownIcon, DeleteIcon } from '@chakra-ui/icons';
|
|
import { MdRemove, MdImportExport } from 'react-icons/md';
|
|
|
|
import type { ICourse } from '@educt/interfaces';
|
|
|
|
type BulkActionsMenuPropsType = {
|
|
selected: ICourse['students'];
|
|
rows: ICourse['students'];
|
|
setRows: React.Dispatch<React.SetStateAction<ICourse['students']>>;
|
|
};
|
|
|
|
const BulkActionsMenu: React.FC<BulkActionsMenuPropsType> = ({ selected, rows, setRows }) => {
|
|
const handleDetach = async () => {
|
|
console.log(
|
|
`Detaching from course: `,
|
|
selected.map(s => s.id)
|
|
);
|
|
setRows(rows.filter(r => selected.every(s => s.id !== r.id)));
|
|
};
|
|
const handleDelete = async () => {};
|
|
const handleExport = async () => {};
|
|
|
|
return (
|
|
<Menu isLazy>
|
|
<MenuButton as={Button} mr='3' ml='auto' rightIcon={<ChevronDownIcon />}>
|
|
Bulk Actions
|
|
</MenuButton>
|
|
<MenuList>
|
|
<MenuItem onClick={handleDetach} icon={<MdRemove />}>
|
|
Remove from course
|
|
</MenuItem>
|
|
<MenuItem onClick={handleExport} icon={<MdImportExport />} isDisabled>
|
|
Export
|
|
</MenuItem>
|
|
<MenuItem onClick={handleDelete} icon={<DeleteIcon />} color='red' isDisabled>
|
|
Delete
|
|
</MenuItem>
|
|
</MenuList>
|
|
</Menu>
|
|
);
|
|
};
|
|
|
|
export default BulkActionsMenu;
|