68 lines
1.8 KiB
JavaScript
68 lines
1.8 KiB
JavaScript
import { request } from '../lib/apiClient'
|
|
|
|
/** Organisation settings — backend/org_settings/app.py. Batch upsert; one Save per tab. */
|
|
|
|
export function list({ category } = {}) {
|
|
return request('/org-settings/fetch', { params: { category } })
|
|
}
|
|
|
|
export function update(settings) {
|
|
return request('/org-settings/update', { method: 'PUT', body: { settings } })
|
|
}
|
|
|
|
export function listUniversities() {
|
|
return request('/org-settings/exclude-university/fetch')
|
|
}
|
|
|
|
export function createUniversity(body) {
|
|
return request('/org-settings/exclude-university/create', { method: 'POST', body })
|
|
}
|
|
|
|
export function updateUniversity(recordId, body) {
|
|
return request('/org-settings/exclude-university/update', {
|
|
method: 'PATCH',
|
|
params: { record_id: recordId },
|
|
body,
|
|
})
|
|
}
|
|
|
|
export function removeUniversity(recordId) {
|
|
return request('/org-settings/exclude-university/delete', {
|
|
method: 'DELETE',
|
|
params: { record_id: recordId },
|
|
})
|
|
}
|
|
|
|
export function listCompanies() {
|
|
return request('/org-settings/exclude-company/fetch')
|
|
}
|
|
|
|
export function createCompany(body) {
|
|
return request('/org-settings/exclude-company/create', { method: 'POST', body })
|
|
}
|
|
|
|
export function updateCompany(recordId, body) {
|
|
return request('/org-settings/exclude-company/update', {
|
|
method: 'PATCH',
|
|
params: { record_id: recordId },
|
|
body,
|
|
})
|
|
}
|
|
|
|
export function removeCompany(recordId) {
|
|
return request('/org-settings/exclude-company/delete', {
|
|
method: 'DELETE',
|
|
params: { record_id: recordId },
|
|
})
|
|
}
|
|
|
|
/** Flatten `{data:[{key,value,category}]}` into a key → value map. */
|
|
export function toMap(res) {
|
|
const rows = Array.isArray(res?.data) ? res.data : []
|
|
const map = {}
|
|
for (const row of rows) {
|
|
if (row?.key) map[row.key] = row.value
|
|
}
|
|
return map
|
|
}
|