import { Modal, Button, Group, Text, Select, Switch, Divider, } from "@mantine/core"; import { exportPage } from "@/features/page/services/page-service.ts"; import { useState } from "react"; import { ExportFormat } from "@/features/page/types/page.types.ts"; import { notifications } from "@mantine/notifications"; import { exportSpace } from "@/features/space/services/space-service"; import { useTranslation } from "react-i18next"; interface ExportModalProps { id: string; type: "space" | "page"; open: boolean; onClose: () => void; } export default function ExportModal({ id, type, open, onClose, }: ExportModalProps) { const [format, setFormat] = useState(ExportFormat.Markdown); const [includeChildren, setIncludeChildren] = useState(false); const [includeAttachments, setIncludeAttachments] = useState(true); const { t } = useTranslation(); const handleExport = async () => { try { if (type === "page") { await exportPage({ pageId: id, format, includeChildren }); } if (type === "space") { await exportSpace({ spaceId: id, format, includeAttachments }); } setIncludeChildren(false); setIncludeAttachments(true); onClose(); } catch (err) { notifications.show({ message: "Export failed:" + err.response?.data.message, color: "red", }); console.error("export error", err); } }; const handleChange = (format: ExportFormat) => { setFormat(format); }; return ( e.stopPropagation()} > {t(`Export ${type}`)}
{t("Format")}
{type === "page" && ( <>
{t("Include subpages")}
setIncludeChildren(event.currentTarget.checked) } checked={includeChildren} />
)} {type === "space" && ( <>
{t("Include attachments")}
setIncludeAttachments(event.currentTarget.checked) } checked={includeAttachments} />
)}
); } interface ExportFormatSelection { format: ExportFormat; onChange: (value: string) => void; } function ExportFormatSelection({ format, onChange }: ExportFormatSelection) { const { t } = useTranslation(); return (