import { Trans, t } from "@lingui/macro" import { Box, Button, FileInput, Group, Stack } from "@mantine/core" import { isNotEmpty, useForm } from "@mantine/form" import { client, errorToStrings } from "app/client" import { redirectToSelectedSource } from "app/redirect/thunks" import { useAppDispatch } from "app/store" import { reloadTree } from "app/tree/thunks" import { Alert } from "components/Alert" import { useAsyncCallback } from "react-async-hook" import { TbFileImport } from "react-icons/tb" export function ImportOpml() { const dispatch = useAppDispatch() const form = useForm<{ file: File }>({ validate: { file: isNotEmpty(t`OPML file is required`), }, }) const importOpml = useAsyncCallback(client.feed.importOpml, { onSuccess: () => { dispatch(reloadTree()) dispatch(redirectToSelectedSource()) }, }) return ( <> {importOpml.error && ( )}
await importOpml.execute(v.file))}> OPML file} leftSection={} placeholder={t`OPML file`} description={ An opml file is an XML file containing feed URLs and categories. You can get an OPML file by exporting your data from other feed reading services. } {...form.getInputProps("file")} required accept=".xml,.opml" />
) }