import React, { memo, useCallback } from '../../../lib/teact/teact'; import { getActions, withGlobal } from '../../../global'; import type { FC } from '../../../lib/teact/teact'; import type { ApiUser, ApiWebSession } from '../../../api/types'; import buildClassName from '../../../util/buildClassName'; import useLang from '../../../hooks/useLang'; import useCurrentOrPrev from '../../../hooks/useCurrentOrPrev'; import Modal from '../../ui/Modal'; import Button from '../../ui/Button'; import Avatar from '../../common/Avatar'; import FullNameTitle from '../../common/FullNameTitle'; import styles from './SettingsActiveWebsite.module.scss'; type OwnProps = { isOpen: boolean; hash?: string; onClose: () => void; }; type StateProps = { session?: ApiWebSession; bot?: ApiUser; }; const SettingsActiveWebsite: FC = ({ isOpen, session, bot, onClose, }) => { const { terminateWebAuthorization } = getActions(); const lang = useLang(); const renderingSession = useCurrentOrPrev(session, true); const renderingBot = useCurrentOrPrev(bot, true); const handleTerminateSessionClick = useCallback(() => { terminateWebAuthorization({ hash: session!.hash }); onClose(); }, [onClose, session, terminateWebAuthorization]); if (!renderingSession) { return undefined; } function renderHeader() { return (
{lang('WebSessionsTitle')}
); } return ( {renderingBot && }
{renderingSession?.domain}
{lang('AuthSessions.View.Browser')}
{renderingSession?.browser}
{lang('SessionPreview.Ip')}
{renderingSession?.ip}
{lang('SessionPreview.Location')}
{renderingSession?.region}

{lang('AuthSessions.View.LocationInfo')}

); }; export default memo(withGlobal((global, { hash }): StateProps => { const session = hash ? global.activeWebSessions.byHash[hash] : undefined; const bot = session ? global.users.byId[session.botId] : undefined; return { session, bot, }; })(SettingsActiveWebsite));