import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { UncontrolledTooltip } from 'reactstrap';
import { withTranslation } from 'react-i18next';
import { withUnstatedContainers } from '../UnstatedUtils';
import AppContainer from '../../services/AppContainer';
import PageContainer from '../../services/PageContainer';
import OutsideShareLinkModal from '../OutsideShareLinkModal';
import { toastError } from '../../util/apiNotification';
import ArchiveCreateModal from '../ArchiveCreateModal';
const PageShareManagement = (props) => {
const { t, appContainer, pageContainer } = props;
const { path, pageId } = pageContainer.state;
const { currentUser } = appContainer;
const [isOutsideShareLinkModalShown, setIsOutsideShareLinkModalShown] = useState(false);
const [isArchiveCreateModalShown, setIsArchiveCreateModalShown] = useState(false);
const [archiveData, setArchiveData] = useState(null);
const [errorMessage, setErrorMessage] = useState(null);
function openOutsideShareLinkModalHandler() {
setIsOutsideShareLinkModalShown(true);
}
function closeOutsideShareLinkModalHandler() {
setIsOutsideShareLinkModalShown(false);
}
async function getExportPageFile(type) {
try {
const res = await appContainer.apiv3Get('/pages/export', { pageId, type });
return res;
}
catch (err) {
toastError(Error(t('export_bulk.failed_to_export')));
}
}
async function getArchivePageData() {
try {
await appContainer.apiv3Get('page/count-children-pages', { pageId });
setArchiveData('ここにページの変更を表示');
}
catch (err) {
setErrorMessage('ページ数の取得に失敗しました');
}
}
function exportPage(exportPageFile) {
// TODO implement
}
function exportPageHundler(type) {
const exportPageFile = getExportPageFile(type);
exportPage(exportPageFile);
}
function openArchiveModalHandler() {
setIsArchiveCreateModalShown(true);
getArchivePageData();
}
function closeArchiveCreateModalHandler() {
setIsArchiveCreateModalShown(false);
}
function renderModals() {
return (
<>