import { useCallback, useState, ReactNode } from 'react' import { useTranslation } from 'react-i18next' import AccessibleModal from '../../../../shared/components/accessible-modal' import { Modal } from 'react-bootstrap' type IntegrationLinkingWidgetProps = { logo: ReactNode title: string description: string helpPath: string hasFeature?: boolean statusIndicator?: ReactNode linked?: boolean linkPath: string unlinkPath: string unlinkConfirmationTitle: string unlinkConfirmationText: string } export function IntegrationLinkingWidget({ logo, title, description, helpPath, hasFeature, statusIndicator, linked, linkPath, unlinkPath, unlinkConfirmationTitle, unlinkConfirmationText, }: IntegrationLinkingWidgetProps) { const { t } = useTranslation() const [showModal, setShowModal] = useState(false) const handleUnlinkClick = useCallback(() => { setShowModal(true) }, []) const handleModalHide = useCallback(() => { setShowModal(false) }, []) return (
{logo}

{title}

{!hasFeature && ( {t('premium_feature')} )}

{description}{' '} {t('learn_more')}

{linked && statusIndicator}
) } type ActionButtonProps = { hasFeature?: boolean upgradePath: string linked?: boolean handleUnlinkClick: () => void linkPath: string } function ActionButton({ hasFeature, upgradePath, linked, handleUnlinkClick, linkPath, }: ActionButtonProps) { const { t } = useTranslation() if (!hasFeature) { return ( {t('upgrade')} ) } else if (linked) { return ( ) } else { return ( {t('link')} ) } } type UnlinkConfirmModalProps = { show: boolean title: string content: string unlinkPath: string handleHide: () => void } function UnlinkConfirmationModal({ show, title, content, unlinkPath, handleHide, }: UnlinkConfirmModalProps) { const { t } = useTranslation() return ( {title}

{content}

{t('unlink')}
) }