Add facilities, contracts, orders, value lists, audit log, and desktop app modules
Extends omsorgCore with full CRUD for Facility/Contract/Order plus configurable value lists and an audit trail, and wires the omsorgapp frontend up to the new facilities, settings, and audit-log modules; includes a sidebar active-nav-item highlight. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
ee74ed65f5
commit
e9e96a57dc
@@ -0,0 +1,34 @@
|
||||
const { Configuration } = require('omsorgcore-client-ts');
|
||||
const { API_BASE } = require('./config.cjs');
|
||||
|
||||
// Baut die Configuration für eine generierte *Api-Klasse (omsorgcore-client-ts).
|
||||
// Einzige Stelle, die API_BASE mit dem generierten Client verbindet.
|
||||
function configFor(accessToken) {
|
||||
return new Configuration({ basePath: API_BASE, accessToken });
|
||||
}
|
||||
|
||||
// Wandelt den Aufruf einer generierten `...Raw()`-Methode in denselben
|
||||
// Vertrag um, den vorher httpClient.request(...) lieferte: { ok, status, data, error? }.
|
||||
// Generierte Clients werfen bei Nicht-2xx eine ResponseError-Exception statt ein
|
||||
// Ergebnisobjekt zurückzugeben - das fangen wir hier zentral ab.
|
||||
async function callApi(rawPromise) {
|
||||
try {
|
||||
const response = await rawPromise;
|
||||
const data = await response.value();
|
||||
return { ok: true, status: response.raw.status, data: data === undefined ? null : data };
|
||||
} catch (err) {
|
||||
if (err && err.name === 'ResponseError') {
|
||||
const status = err.response.status;
|
||||
let data = null;
|
||||
try {
|
||||
data = await err.response.json();
|
||||
} catch {
|
||||
data = null;
|
||||
}
|
||||
return { ok: false, status, data };
|
||||
}
|
||||
return { ok: false, status: 0, data: null, error: err && err.message };
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { configFor, callApi };
|
||||
Reference in New Issue
Block a user