overleaf/services/web/frontend/js/features/subscription/components/group-invites/group-invites.tsx
M Fahru 0639f266d8 Merge pull request #14756 from overleaf/mf-group-invite-new-user-redirection
[web] Redirect to invite screen if new user register with a pending group invitations

GitOrigin-RevId: 39aeffd65b9d793c87e53398a700ad140794594e
2023-11-10 09:04:23 +00:00

34 lines
952 B
TypeScript

import { useEffect } from 'react'
import { Col, Row } from 'react-bootstrap'
import { useTranslation } from 'react-i18next'
import getMeta from '@/utils/meta'
import { useLocation } from '@/shared/hooks/use-location'
import GroupInvitesItem from './group-invites-item'
import type { TeamInvite } from '../../../../../../types/team-invite'
function GroupInvites() {
const { t } = useTranslation()
const teamInvites: TeamInvite[] = getMeta('ol-teamInvites')
const location = useLocation()
useEffect(() => {
if (teamInvites.length === 0) {
location.assign('/project')
}
}, [teamInvites, location])
return (
<div className="container">
<Row>
<Col md={8} mdOffset={2}>
<h1>{t('group_invitations')}</h1>
</Col>
</Row>
{teamInvites.map(teamInvite => (
<GroupInvitesItem teamInvite={teamInvite} key={teamInvite._id} />
))}
</div>
)
}
export default GroupInvites