1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 13:19:44 +02:00
planka/client/src/components/UsersModal/UsersModal.jsx

76 lines
2.2 KiB
React
Raw Normal View History

2019-08-31 04:07:25 +05:00
import React, { useCallback } from 'react';
import PropTypes from 'prop-types';
import { useTranslation } from 'react-i18next';
import { Button, Modal, Table } from 'semantic-ui-react';
2019-08-31 04:07:25 +05:00
import AddUserPopupContainer from '../../containers/AddUserPopupContainer';
import Item from './Item';
const UsersModal = React.memo(({ items, onUpdate, onDelete, onClose }) => {
2019-08-31 04:07:25 +05:00
const [t] = useTranslation();
const handleUpdate = useCallback(
(id, data) => {
onUpdate(id, data);
},
[onUpdate],
);
const handleDelete = useCallback(
2020-03-25 00:15:47 +05:00
(id) => {
2019-08-31 04:07:25 +05:00
onDelete(id);
},
[onDelete],
);
return (
<Modal open closeIcon size="large" centered={false} onClose={onClose}>
<Modal.Header>
{t('common.users', {
context: 'title',
})}
</Modal.Header>
2019-08-31 04:07:25 +05:00
<Modal.Content>
<Table basic="very">
<Table.Header>
<Table.Row>
2020-04-03 00:35:25 +05:00
<Table.HeaderCell width={4}>{t('common.name')}</Table.HeaderCell>
<Table.HeaderCell width={4}>{t('common.username')}</Table.HeaderCell>
<Table.HeaderCell width={4}>{t('common.email')}</Table.HeaderCell>
2019-08-31 04:07:25 +05:00
<Table.HeaderCell>{t('common.administrator')}</Table.HeaderCell>
<Table.HeaderCell />
</Table.Row>
</Table.Header>
<Table.Body>
2020-03-25 00:15:47 +05:00
{items.map((item) => (
2019-08-31 04:07:25 +05:00
<Item
key={item.id}
name={item.name}
2020-04-03 00:35:25 +05:00
username={item.username}
2019-08-31 04:07:25 +05:00
email={item.email}
isAdmin={item.isAdmin}
2020-03-25 00:15:47 +05:00
onUpdate={(data) => handleUpdate(item.id, data)}
2019-08-31 04:07:25 +05:00
onDelete={() => handleDelete(item.id)}
/>
))}
</Table.Body>
</Table>
</Modal.Content>
<Modal.Actions>
<AddUserPopupContainer>
<Button positive content={t('action.addUser')} />
</AddUserPopupContainer>
</Modal.Actions>
2019-08-31 04:07:25 +05:00
</Modal>
);
});
UsersModal.propTypes = {
items: PropTypes.array.isRequired, // eslint-disable-line react/forbid-prop-types
onUpdate: PropTypes.func.isRequired,
onDelete: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
};
export default UsersModal;