diff --git a/apps/app/src/client/services/create-page/create-page.ts b/apps/app/src/client/services/create-page/create-page.ts new file mode 100644 index 00000000000..aa6f4a4dfb4 --- /dev/null +++ b/apps/app/src/client/services/create-page/create-page.ts @@ -0,0 +1,7 @@ +import { apiv3Post } from '~/client/util/apiv3-client'; +import type { IApiv3PageCreateParams, IApiv3PageCreateResponse } from '~/interfaces/apiv3'; + +export const createPage = async(params: IApiv3PageCreateParams): Promise => { + const res = await apiv3Post('/page', params); + return res.data; +}; diff --git a/apps/app/src/client/services/create-page/index.ts b/apps/app/src/client/services/create-page/index.ts index 140966f93cf..7de6ef62de4 100644 --- a/apps/app/src/client/services/create-page/index.ts +++ b/apps/app/src/client/services/create-page/index.ts @@ -1,2 +1,3 @@ +export * from './create-page'; export * from './use-create-page-and-transit'; export * from './use-create-template-page'; diff --git a/apps/app/src/client/services/create-page/use-create-page-and-transit.tsx b/apps/app/src/client/services/create-page/use-create-page-and-transit.tsx index 08f4b1fd775..c9cb02b40c5 100644 --- a/apps/app/src/client/services/create-page/use-create-page-and-transit.tsx +++ b/apps/app/src/client/services/create-page/use-create-page-and-transit.tsx @@ -2,12 +2,14 @@ import { useCallback, useState } from 'react'; import { useRouter } from 'next/router'; -import { createPage, exist } from '~/client/services/page-operation'; +import { exist } from '~/client/services/page-operation'; import type { IApiv3PageCreateParams } from '~/interfaces/apiv3'; import { useCurrentPagePath } from '~/stores/page'; import { EditorMode, useEditorMode } from '~/stores/ui'; import loggerFactory from '~/utils/logger'; +import { createPage } from './create-page'; + const logger = loggerFactory('growi:Navbar:GrowiContextualSubNavigation'); /** diff --git a/apps/app/src/client/services/page-operation.ts b/apps/app/src/client/services/page-operation.ts index 33dcbf376a3..8ba63c70a8e 100644 --- a/apps/app/src/client/services/page-operation.ts +++ b/apps/app/src/client/services/page-operation.ts @@ -4,9 +4,6 @@ import type { IPageHasId } from '@growi/core'; import { SubscriptionStatusType } from '@growi/core'; import urljoin from 'url-join'; -import type { - IApiv3PageCreateParams, IApiv3PageCreateResponse, IApiv3PageUpdateParams, IApiv3PageUpdateResponse, -} from '~/interfaces/apiv3'; import { useEditingMarkdown, usePageTagsForEditors } from '~/stores/editor'; import { useCurrentPageId, useSWRMUTxCurrentPage, useSWRxTagsInfo } from '~/stores/page'; import { useSetRemoteLatestPageData } from '~/stores/remote-latest-page'; @@ -91,11 +88,6 @@ export const resumeRenameOperation = async(pageId: string): Promise => { await apiv3Post('/pages/resume-rename', { pageId }); }; -export const createPage = async(params: IApiv3PageCreateParams): Promise => { - const res = await apiv3Post('/page', params); - return res.data; -}; - export type UpdateStateAfterSaveOption = { supressEditingMarkdownMutation: boolean, } diff --git a/apps/app/src/components/TreeItem/NewPageInput/use-new-page-input.tsx b/apps/app/src/components/TreeItem/NewPageInput/use-new-page-input.tsx index 0ba48de954c..33fe701fc3a 100644 --- a/apps/app/src/components/TreeItem/NewPageInput/use-new-page-input.tsx +++ b/apps/app/src/components/TreeItem/NewPageInput/use-new-page-input.tsx @@ -2,8 +2,8 @@ import React, { useState, type FC, useCallback } from 'react'; import { Origin } from '@growi/core'; -import { createPage } from '~/client/services/page-operation'; -import { useSWRxPageChildren, mutatePageTree } from '~/stores/page-listing'; +import { createPage } from '~/client/services/create-page'; +import { mutatePageTree } from '~/stores/page-listing'; import { usePageTreeDescCountMap } from '~/stores/ui'; import { shouldCreateWipPage } from '../../../utils/should-create-wip-page'; @@ -58,8 +58,6 @@ export const useNewPageInput = (): UseNewPageInput => { const { itemNode, stateHandlers } = props; const { page, children } = itemNode; - const { mutate: mutateChildren } = useSWRxPageChildren(stateHandlers?.isOpen ? page._id : null); - const { getDescCount } = usePageTreeDescCountMap(); const descendantCount = getDescCount(page._id) || page.descendantCount || 0;