mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
cf2dfc6bf1
[SettingsPage] Integration Branch GitOrigin-RevId: 5a3c26b2a02d716c4ae3981e3f08b811ae307725
68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
import { useTranslation } from 'react-i18next'
|
|
import {
|
|
SSOProvider,
|
|
useSSOContext,
|
|
SSOSubscription,
|
|
} from '../context/sso-context'
|
|
import { SSOLinkingWidget } from './sso-linking/widget'
|
|
|
|
function SSOLinkingSection() {
|
|
const { t } = useTranslation()
|
|
|
|
return (
|
|
<SSOProvider>
|
|
<h3 className="text-capitalize">{t('linked_accounts')}</h3>
|
|
<p>{t('linked_accounts_explained')}</p>
|
|
<SSOLinkingWidgets />
|
|
</SSOProvider>
|
|
)
|
|
}
|
|
|
|
function SSOLinkingWidgets() {
|
|
const { subscriptions } = useSSOContext()
|
|
|
|
return (
|
|
<div className="settings-widgets-container">
|
|
{Object.values(subscriptions).map((subscription, subscriptionIndex) => (
|
|
<SSOLinkingWidgetContainer
|
|
key={subscription.providerId}
|
|
subscription={subscription}
|
|
isLast={subscriptionIndex === Object.keys(subscriptions).length - 1}
|
|
/>
|
|
))}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
type SSOLinkingWidgetContainerProps = {
|
|
subscription: SSOSubscription
|
|
isLast: boolean
|
|
}
|
|
|
|
function SSOLinkingWidgetContainer({
|
|
subscription,
|
|
isLast,
|
|
}: SSOLinkingWidgetContainerProps) {
|
|
const { t } = useTranslation()
|
|
const { unlink } = useSSOContext()
|
|
|
|
return (
|
|
<>
|
|
<SSOLinkingWidget
|
|
providerId={subscription.providerId}
|
|
title={subscription.provider.name}
|
|
description={t(
|
|
subscription.provider.descriptionKey,
|
|
subscription.provider.descriptionOptions
|
|
)}
|
|
helpPath={subscription.provider.descriptionOptions?.link}
|
|
linked={subscription.linked}
|
|
linkPath={subscription.provider.linkPath}
|
|
onUnlink={() => unlink(subscription.providerId)}
|
|
/>
|
|
{isLast ? null : <hr />}
|
|
</>
|
|
)
|
|
}
|
|
|
|
export default SSOLinkingSection
|