Przeglądaj źródła

Rename "rootDoc_id" to "rootDocId" before sending it to server

GitOrigin-RevId: fc29e152ffd3bf97c00ee817abb07086f6cdfe17
M Fahru 3 lat temu
rodzic
commit
b6b6b9c4b1

+ 21 - 1
services/web/frontend/js/features/editor-left-menu/utils/api.ts

@@ -39,14 +39,34 @@ export type ProjectSettingsScope = {
   spellCheckLanguage: string
 }
 
+// server asks for "rootDocId" but client has "rootDoc_id"
+type ProjectSettingsRequestBody = Partial<
+  Omit<ProjectSettingsScope, 'rootDoc_id'> & {
+    rootDocId: string
+  }
+>
+
 export const saveProjectSettings = async (
   projectId: string,
   data: Partial<ProjectSettingsScope>
 ) => {
+  let reqData: ProjectSettingsRequestBody = {}
+
+  if (data.rootDoc_id) {
+    const val = data.rootDoc_id
+    delete data.rootDoc_id
+    reqData = {
+      ...data,
+      rootDocId: val,
+    }
+  } else {
+    reqData = data
+  }
+
   await postJSON<never>(`/project/${projectId}/settings`, {
     body: {
       _csrf: window.csrfToken,
-      ...data,
+      ...reqData,
     },
   })
 }