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, }, }) }