ryoji-s преди 2 години
родител
ревизия
0d31fe3b53

+ 1 - 1
apps/app/src/client/services/page-operation.ts

@@ -88,7 +88,7 @@ export const resumeRenameOperation = async(pageId: string): Promise<void> => {
 };
 
 // TODO: define return type
-const createPage = async(pagePath: string, markdown: string, tmpParams: OptionsToSave) => {
+export const createPage = async(pagePath: string, markdown: string, tmpParams: OptionsToSave) => {
   // clone
   const params = Object.assign(tmpParams, {
     path: pagePath,

+ 10 - 6
apps/app/src/components/Sidebar/PageCreateButton.tsx

@@ -2,7 +2,7 @@ import React, { useCallback, useState } from 'react';
 
 import { useRouter } from 'next/router';
 
-import { apiv3Post } from '~/client/util/apiv3-client';
+import { createPage } from '~/client/services/page-operation';
 import { toastError } from '~/client/util/toastr';
 import { useSWRxCurrentPage } from '~/stores/page';
 import loggerFactory from '~/utils/logger';
@@ -35,14 +35,18 @@ export const PageCreateButton = React.memo((): JSX.Element => {
         ? '/'
         : currentPage.path;
 
-      const response = await apiv3Post('/pages/', {
-        path: parentPath,
+      const params = {
+        isSlackEnabled: false,
+        slackChannels: '',
         grant: currentPage?.grant || 1,
-        grantUserGroupId: currentPage?.grantedGroup,
+        pageTags: [],
+        grantUserGroupId: currentPage?.grantedGroup?._id,
         shouldGeneratePath: true,
-      });
+      };
 
-      router.push(`${response.data.page.id}#edit`);
+      const response = await createPage(parentPath, '', params);
+
+      router.push(`${response.page.id}#edit`);
     }
     catch (err) {
       logger.warn(err);

+ 1 - 0
apps/app/src/interfaces/page-operation.ts

@@ -34,4 +34,5 @@ export type OptionsToSave = {
   pageTags: string[] | null;
   grantUserGroupId?: string | null;
   grantUserGroupName?: string | null;
+  shouldGeneratePath?: boolean | null;
 };