diff --git a/app/scenes/Settings/components/ExportDialog.tsx b/app/components/ExportDialog.tsx similarity index 72% rename from app/scenes/Settings/components/ExportDialog.tsx rename to app/components/ExportDialog.tsx index 1ce9a7ac0..00d59681c 100644 --- a/app/scenes/Settings/components/ExportDialog.tsx +++ b/app/components/ExportDialog.tsx @@ -4,23 +4,31 @@ import * as React from "react"; import { Trans, useTranslation } from "react-i18next"; import styled from "styled-components"; import { FileOperationFormat } from "@shared/types"; +import Collection from "~/models/Collection"; import ConfirmationDialog from "~/components/ConfirmationDialog"; import Flex from "~/components/Flex"; import MarkdownIcon from "~/components/Icons/Markdown"; import Text from "~/components/Text"; import useStores from "~/hooks/useStores"; +import useToasts from "~/hooks/useToasts"; type Props = { + collection?: Collection; onSubmit: () => void; }; -function ExportDialog({ onSubmit }: Props) { +function ExportDialog({ collection, onSubmit }: Props) { const [format, setFormat] = React.useState( FileOperationFormat.MarkdownZip ); - const { collections } = useStores(); + const { showToast } = useToasts(); + const { collections, notificationSettings } = useStores(); const { t } = useTranslation(); + React.useEffect(() => { + notificationSettings.fetchPage({}); + }, [notificationSettings]); + const handleFormatChange = React.useCallback( (ev: React.ChangeEvent) => { setFormat(ev.target.value as FileOperationFormat); @@ -28,13 +36,33 @@ function ExportDialog({ onSubmit }: Props) { [] ); - const handleSubmit = React.useCallback(async () => { - await collections.export(format); + const handleSubmit = async () => { + if (collection) { + await collection.export(format); + } else { + await collections.export(format); + } onSubmit(); - }, [collections, format, onSubmit]); + showToast(t("Export started"), { type: "success" }); + }; return ( + {collection && ( + + , + }} + />{" "} + {notificationSettings.getByEvent("emails.export_completed") && + t("You will receive an email when it's complete.")} + + )}