overleaf/services/web/frontend/js/features/settings/components/emails/institution-and-role.tsx
Tim Down e0d5cf4b42 Merge pull request #7509 from overleaf/ii-7155-display-institution
Display the institution and role if applicable

GitOrigin-RevId: e00b07f0118e7f3ab8ec0b0f01b2b3e52fcc1cd2
2022-04-15 08:03:17 +00:00

50 lines
1.3 KiB
TypeScript

import { useTranslation } from 'react-i18next'
import { UserEmailData } from '../../../../../../types/user-email'
import { Button } from 'react-bootstrap'
type InstitutionAndRoleProps = {
userEmailData: UserEmailData
}
function InstitutionAndRole({ userEmailData }: InstitutionAndRoleProps) {
const { t } = useTranslation()
const { affiliation } = userEmailData
const handleAddRoleDepartment = () => {
console.log('TODO: add role department')
}
const handleChangeAffiliation = () => {
console.log('TODO: change affiliation')
}
if (!affiliation?.institution) {
return null
}
return (
<>
<div>{affiliation.institution.name}</div>
{!affiliation.department && !affiliation.role && (
<div className="small">
<Button className="btn-inline-link" onClick={handleAddRoleDepartment}>
{t('add_role_and_department')}
</Button>
</div>
)}
{(affiliation.role || affiliation.department) && (
<div className="small">
{[affiliation.role, affiliation.department]
.filter(Boolean)
.join(', ')}
<br />
<Button className="btn-inline-link" onClick={handleChangeAffiliation}>
{t('change')}
</Button>
</div>
)}
</>
)
}
export default InstitutionAndRole