This commit is contained in:
seb
2026-07-31 07:00:04 +02:00
parent 724f873bfe
commit 9dac151854
11 changed files with 715 additions and 61 deletions

View File

@@ -94,6 +94,55 @@ export const article = {
},
};
export const company = {
async list() {
try {
return await http('/api/company');
} catch {
return { companies: [] };
}
},
/** Uses GET /api/company until a dedicated endpoint exists. */
async getById(companyId) {
const data = await http('/api/company');
const found = data.companies?.find((item) => item.id === companyId);
if (!found) throw new Error('Unternehmen nicht gefunden.');
return { company: found };
},
create({ name, iso639, taxrate, reducedtaxrate }) {
return http('/api/company', {
method: 'POST',
body: { name, iso639, taxrate, reducedtaxrate },
});
},
/**
* Backend suggestion (not implemented yet):
*
* PUT /api/company/:companyId
* Body: { name, iso639, taxrate, reducedtaxrate }
* Response: { company: { id, name, iso639, taxrate, reducedtaxrate, ... } }
* Auth: session cookie; user must be allowed to edit that company.
*
* Optional: add iso639 to GET /api/company list items (today only languageId).
*/
update(companyId, { name, iso639, taxrate, reducedtaxrate }) {
return http(`/api/company/${companyId}`, {
method: 'PUT',
body: { name, iso639, taxrate, reducedtaxrate },
});
},
select(companyId) {
return http('/api/auth/selected-company', {
method: 'PUT',
body: { companyId },
});
},
};
export const auth = {
async me() {
try {
@@ -145,4 +194,4 @@ export const auth = {
},
};
export default { auth, article };
export default { auth, article, company };