import { Dispatch, Fragment, SetStateAction, useState } from 'react' import toast from 'react-hot-toast' 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' export default function CustomEmbedLinkMenu({ path, menuOpen, setMenuOpen, }: { path: string menuOpen: boolean setMenuOpen: Dispatch> }) { const { t } = useTranslation() const clipboard = useClipboard() const closeMenu = () => setMenuOpen(false) const filename = path.substring(path.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)} />

{t('Default')}

{`${getBaseUrl()}/api?path=${path}&raw=true`}

{t('Customised')}

{`${getBaseUrl()}/api/name/`} {name} {`?path=${path}&raw=true`}
) }