mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-02 13:10:20 -05:00
ed40a87cdc
* Rename manage group entry point * Migrate group management root page to React * Add cypress tests for the group management react page * Fix linting * Add checkbox labels for screen-readers + remove unused classes * Await on add/remove members calls * Display the export CSV link for a full group * Display error message when group is full * Sort locales * Handle the managers management page in React version * Fix missing type in GroupMemberRow * Split members and managers React pages * Build API paths on frontend side + add cypress tests for each page * Fix linting * Update unit tests * Review improvements * Type API errors GitOrigin-RevId: d124a9d24cbf33de8aacc5d69e9d46e7bcda93c5
81 lines
2 KiB
TypeScript
81 lines
2 KiB
TypeScript
import moment from 'moment'
|
|
import { useCallback } from 'react'
|
|
import { Col, Row } from 'react-bootstrap'
|
|
import { useTranslation } from 'react-i18next'
|
|
import { User } from '../../../../../types/group-management/user'
|
|
|
|
type GroupMemberRowProps = {
|
|
user: User
|
|
selectUser: (user: User) => void
|
|
unselectUser: (user: User) => void
|
|
selected: boolean
|
|
}
|
|
|
|
export default function GroupMemberRow({
|
|
user,
|
|
selectUser,
|
|
unselectUser,
|
|
selected,
|
|
}: GroupMemberRowProps) {
|
|
const { t } = useTranslation()
|
|
|
|
const handleSelectUser = useCallback(
|
|
(event, user) => {
|
|
if (event.target.checked) {
|
|
selectUser(user)
|
|
} else {
|
|
unselectUser(user)
|
|
}
|
|
},
|
|
[selectUser, unselectUser]
|
|
)
|
|
|
|
return (
|
|
<li key={`user-${user.email}`}>
|
|
<Row>
|
|
<Col xs={4}>
|
|
<label htmlFor={`select-user-${user.email}`} className="sr-only">
|
|
{t('select_user')}
|
|
</label>
|
|
<input
|
|
className="select-item"
|
|
id={`select-user-${user.email}`}
|
|
type="checkbox"
|
|
checked={selected}
|
|
onChange={e => handleSelectUser(e, user)}
|
|
/>
|
|
<span>{user.email}</span>
|
|
</Col>
|
|
<Col xs={4}>
|
|
{user.first_name} {user.last_name}
|
|
</Col>
|
|
<Col xs={2}>
|
|
{user.last_active_at
|
|
? moment(user.last_active_at).format('Do MMM YYYY')
|
|
: 'N/A'}
|
|
</Col>
|
|
<Col xs={2}>
|
|
{user.invite ? (
|
|
<>
|
|
<i
|
|
className="fa fa-times"
|
|
aria-hidden="true"
|
|
aria-label={t('invite_not_accepted')}
|
|
/>
|
|
<span className="sr-only">t('invite_not_accepted')</span>
|
|
</>
|
|
) : (
|
|
<>
|
|
<i
|
|
className="fa fa-check text-success"
|
|
aria-hidden="true"
|
|
aria-label={t('accepted_invite')}
|
|
/>
|
|
<span className="sr-only">t('accepted_invite')</span>
|
|
</>
|
|
)}
|
|
</Col>
|
|
</Row>
|
|
</li>
|
|
)
|
|
}
|