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

GitOrigin-RevId: fc29e152ffd3bf97c00ee817abb07086f6cdfe17
This commit is contained in:
M Fahru 2022-12-27 13:16:19 -07:00 committed by Copybot
parent 30c32713c6
commit b6b6b9c4b1

View file

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