import type { FC } from '../../lib/teact/teact'; import { memo, useMemo } from '../../lib/teact/teact'; import { getActions } from '../../global'; import buildClassName from '../../util/buildClassName'; import { copyTextToClipboard } from '../../util/clipboard'; import useAppLayout from '../../hooks/useAppLayout'; import useLang from '../../hooks/useLang'; import useLastCallback from '../../hooks/useLastCallback'; import useOldLang from '../../hooks/useOldLang'; import Button from '../ui/Button'; import DropdownMenu from '../ui/DropdownMenu'; import MenuItem from '../ui/MenuItem'; import styles from './LinkField.module.scss'; type OwnProps = { title?: string; link: string; isDisabled?: boolean; className?: string; withShare?: boolean; onRevoke?: VoidFunction; }; const InviteLink: FC = ({ title, link, isDisabled, className, withShare, onRevoke, }) => { const lang = useLang(); const oldLang = useOldLang(); const { showNotification, openChatWithDraft } = getActions(); const { isMobile } = useAppLayout(); const isOnlyCopy = !onRevoke; const copyLink = useLastCallback(() => { copyTextToClipboard(link); showNotification({ message: { key: 'LinkCopied', }, }); }); const handleCopyClick = useLastCallback(() => { if (isDisabled) return; copyLink(); }); const handleShare = useLastCallback(() => { openChatWithDraft({ text: { text: link } }); }); const PrimaryLinkMenuButton: FC<{ onTrigger: () => void; isOpen?: boolean }> = useMemo(() => { return ({ onTrigger, isOpen }) => ( )} ); }; export default memo(InviteLink);