import { useState, useContext } from 'react' import { useTranslation } from 'next-i18next' import { Popout } from 'shared/components/popout.mjs' import { WebLink } from 'shared/components/web-link.mjs' import { LoadingContext } from 'shared/context/loading-context.mjs' import { useToast } from 'shared/hooks/use-toast.mjs' import { exportTypes, handleExport, ns as exportNs, } from 'shared/components/workbench/exporting/export-handler.mjs' export const ns = ['exporting', exportNs] export const ExportView = ({ settings, ui, design, Design }) => { const [link, setLink] = useState(false) const [format, setFormat] = useState(false) const { startLoading, stopLoading } = useContext(LoadingContext) const toast = useToast() const { t } = useTranslation(ns) const doExport = (format) => { setLink(false) setFormat(format) handleExport({ format, settings, design, t, Design, ui, startLoading, stopLoading, onComplete: (e) => { if (e.data.link) { setLink(e.data.link) } }, onError: (e) => { if (e.data?.error) toast.error(e.data.error.message) }, }) } return (
{t('exportPattern-txt')}
{link && (