From b6b6b9c4b17b66a93ad5a3d71f57d28865e361d0 Mon Sep 17 00:00:00 2001 From: M Fahru Date: Tue, 27 Dec 2022 13:16:19 -0700 Subject: [PATCH] Rename "rootDoc_id" to "rootDocId" before sending it to server GitOrigin-RevId: fc29e152ffd3bf97c00ee817abb07086f6cdfe17 --- .../js/features/editor-left-menu/utils/api.ts | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/services/web/frontend/js/features/editor-left-menu/utils/api.ts b/services/web/frontend/js/features/editor-left-menu/utils/api.ts index c15f27ed8b..b03bd1d75b 100644 --- a/services/web/frontend/js/features/editor-left-menu/utils/api.ts +++ b/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 & { + rootDocId: string + } +> + export const saveProjectSettings = async ( projectId: string, data: Partial ) => { + 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(`/project/${projectId}/settings`, { body: { _csrf: window.csrfToken, - ...data, + ...reqData, }, }) }