import { Dispatch, Fragment, SetStateAction, useRef, useState } from 'react' import { useTranslation } from 'next-i18next' import { Dialog, Transition } from '@headlessui/react' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { useClipboard } from 'use-clipboard-copy' import { getBaseUrl } from '../utils/getBaseUrl' import { getStoredToken } from '../utils/protectedRouteHandler' import { getReadablePath } from '../utils/getReadablePath' function LinkContainer({ title, value }: { title: string; value: string }) { const clipboard = useClipboard({ copiedTimeout: 1000 }) return ( <>

{title}

{value}
) } export default function CustomEmbedLinkMenu({ path, menuOpen, setMenuOpen, }: { path: string menuOpen: boolean setMenuOpen: Dispatch> }) { const { t } = useTranslation() const hashedToken = getStoredToken(path) // Focus on input automatically when menu modal opens const focusInputRef = useRef(null) const closeMenu = () => setMenuOpen(false) const readablePath = getReadablePath(path) const filename = readablePath.substring(readablePath.lastIndexOf('/') + 1) const [name, setName] = useState(filename) return (
{/* This element is to trick the browser into centering the modal contents. */}
{t('Customise direct link')} <> {t('Change the raw file direct link to a URL ending with the extension of the file.')}{' '} {t('What is this?')}

{t('Filename')}

setName(e.target.value)} />
) }