import React from 'react'; import { pathUtils } from '@growi/core/dist/utils'; import { useTranslation } from 'next-i18next'; import PropTypes from 'prop-types'; import { Modal, ModalHeader, ModalBody } from 'reactstrap'; import urljoin from 'url-join'; const CreateTemplateModal = (props) => { const { t } = useTranslation(); const { path } = props; const parentPath = pathUtils.addTrailingSlash(path); function generateUrl(label) { return encodeURI(urljoin(parentPath, label, '#edit')); } /** * @param {string} target Which hierarchy to create [children, decendants] */ function renderTemplateCard(target, label) { return (
{ t(`template.${target}.label`) }

{label}

{t(`template.${target}.desc`) }

{ t('Edit') }
); } return ( {t('template.modal_label.Create/Edit Template Page')}
{renderTemplateCard('children', '_template')}
{renderTemplateCard('decendants', '__template')}
); }; CreateTemplateModal.propTypes = { path: PropTypes.string.isRequired, isOpen: PropTypes.bool.isRequired, onClose: PropTypes.func.isRequired, }; export default CreateTemplateModal;