import React, { FC } from 'react'; import { DevidedPagePath } from '@growi/core/dist/models'; import { useTranslation } from 'next-i18next'; import { useCurrentPathname } from '~/stores/context'; import { useSWRxPageInfoForList, useSWRxPagesByPath } from '~/stores/page-listing'; import { PageListItemL } from './PageList/PageListItemL'; import styles from './IdenticalPathPage.module.scss'; type IdenticalPathAlertProps = { path? : string | null, } const IdenticalPathAlert : FC = (props: IdenticalPathAlertProps) => { const { path } = props; const { t } = useTranslation(); let _path = '――'; let _pageName = '――'; if (path != null) { const devidedPath = new DevidedPagePath(path); _path = devidedPath.isFormerRoot ? '/' : devidedPath.former; _pageName = devidedPath.latter; } return (
{t('duplicated_page_alert.same_page_name_exists', { pageName: _pageName })}

{t('duplicated_page_alert.same_page_name_exists_at_path', { path: _path, pageName: _pageName })}

{t('duplicated_page_alert.select_page_to_see')}

); }; export const IdenticalPathPage = (): JSX.Element => { const { data: currentPath } = useCurrentPathname(); const { data: pages } = useSWRxPagesByPath(currentPath); const { injectTo } = useSWRxPageInfoForList(null, currentPath, true, true); if (pages == null) { return <>; } const injectedPages = injectTo(pages); return ( <>
    {injectedPages.map((pageWithMeta) => { const pageId = pageWithMeta.data._id; return ( ); })}
); };