* Update Reconfirm Affiliation (Pug) in Portal page Change the notification so it directs users to the settings page instead of triggering an email confirmation with token-link * Update Reconfirm Affiliation (React) in Settings page Update the component so it sends the 6-digits code and opens the modal to enter it * Update Reconfirm Affiliation (React) in Projects page Update the component so it sends the 6-digits code and opens the modal to enter it * `cleanup_unused_locales` * `bin/run web npm run extract-translations` * Update tests * Minor updates in tests * Update Pug notifications with the notification mixin * De-center the "reconfirmed notification" * Update "Learn more" links to "Learn more about institutional email reconfirmation" * Update tests GitOrigin-RevId: cb65623e209217614786eec56f7f5d28b9e8cec5
102 lines
3.1 KiB
TypeScript
102 lines
3.1 KiB
TypeScript
import { useState } from 'react'
|
|
import { UserEmailData } from '../../../../../../types/user-email'
|
|
import getMeta from '../../../../utils/meta'
|
|
import ReconfirmationInfoSuccess from './reconfirmation-info/reconfirmation-info-success'
|
|
import ReconfirmationInfoPromptText from './reconfirmation-info/reconfirmation-info-prompt-text'
|
|
import OLRow from '@/features/ui/components/ol/ol-row'
|
|
import OLCol from '@/features/ui/components/ol/ol-col'
|
|
import OLNotification from '@/features/ui/components/ol/ol-notification'
|
|
import { useUserEmailsContext } from '@/features/settings/context/user-email-context'
|
|
import { ssoAvailableForInstitution } from '@/features/settings/utils/sso'
|
|
import { useTranslation } from 'react-i18next'
|
|
import { useLocation } from '@/shared/hooks/use-location'
|
|
import OLButton from '@/features/ui/components/ol/ol-button'
|
|
import ResendConfirmationCodeModal from '@/features/settings/components/emails/resend-confirmation-code-modal'
|
|
|
|
type ReconfirmationInfoProps = {
|
|
userEmailData: UserEmailData
|
|
}
|
|
|
|
function ReconfirmationInfo({ userEmailData }: ReconfirmationInfoProps) {
|
|
const reconfirmedViaSAML = getMeta('ol-reconfirmedViaSAML')
|
|
const affiliation = userEmailData.affiliation
|
|
const { t } = useTranslation()
|
|
const { samlInitPath } = getMeta('ol-ExposedSettings')
|
|
const {
|
|
state,
|
|
setLoading: setUserEmailsContextLoading,
|
|
getEmails,
|
|
} = useUserEmailsContext()
|
|
const [isPending, setIsPending] = useState(false)
|
|
const location = useLocation()
|
|
const ssoAvailable = Boolean(
|
|
ssoAvailableForInstitution(affiliation?.institution ?? null)
|
|
)
|
|
|
|
if (!affiliation) {
|
|
return null
|
|
}
|
|
|
|
if (
|
|
userEmailData.samlProviderId &&
|
|
userEmailData.samlProviderId === reconfirmedViaSAML
|
|
) {
|
|
return (
|
|
<OLRow>
|
|
<OLCol lg={12}>
|
|
<OLNotification
|
|
type="info"
|
|
content={
|
|
<ReconfirmationInfoSuccess
|
|
institution={affiliation.institution}
|
|
/>
|
|
}
|
|
/>
|
|
</OLCol>
|
|
</OLRow>
|
|
)
|
|
}
|
|
|
|
if (!affiliation.inReconfirmNotificationPeriod) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<OLNotification
|
|
type="info"
|
|
content={
|
|
<ReconfirmationInfoPromptText
|
|
institutionName={affiliation.institution.name}
|
|
primary={userEmailData.default}
|
|
/>
|
|
}
|
|
action={
|
|
affiliation?.institution && ssoAvailable ? (
|
|
<OLButton
|
|
variant="secondary"
|
|
disabled={isPending}
|
|
onClick={() => {
|
|
setIsPending(true)
|
|
location.assign(
|
|
`${samlInitPath}?university_id=${affiliation.institution.id}&reconfirm=/user/settings`
|
|
)
|
|
}}
|
|
>
|
|
{t('confirm_affiliation')}
|
|
</OLButton>
|
|
) : (
|
|
<ResendConfirmationCodeModal
|
|
email={userEmailData.email}
|
|
setGroupLoading={setUserEmailsContextLoading}
|
|
groupLoading={state.isLoading}
|
|
onSuccess={getEmails}
|
|
triggerVariant="secondary"
|
|
/>
|
|
)
|
|
}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export default ReconfirmationInfo
|