This commit is contained in:
seb
2026-10-10 02:08:10 +02:00
parent d4e2b05cb0
commit 7f8661be3e
43 changed files with 3312 additions and 2339 deletions

View File

@@ -1,5 +1,7 @@
import * as db from '../../db/customergroup.js';
// #region Helpers
/** Implicit groups created by the system — name locked. */
const LOCKED_NAMES = new Set(['POS', 'Lieferanten']);
@@ -31,6 +33,8 @@ function withEditable(row) {
};
}
// #endregion
/**
* Registers customergroup routes for the authenticated user's selected company.
* @param {import('express').Application} app
@@ -143,6 +147,8 @@ export function register(app, basePath = '') {
* schema:
* $ref: '#/components/schemas/Error'
*/
// #region GET /customergroup
app.get(`${basePath}/customergroup`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -159,6 +165,10 @@ export function register(app, basePath = '') {
}
});
// #endregion
// #region POST /customergroup
app.post(`${basePath}/customergroup`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -177,6 +187,8 @@ export function register(app, basePath = '') {
}
});
// #endregion
/**
* @openapi
* /customergroup/order:
@@ -241,6 +253,8 @@ export function register(app, basePath = '') {
* schema:
* $ref: '#/components/schemas/Error'
*/
// #region PUT /customergroup/order
app.put(`${basePath}/customergroup/order`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -270,6 +284,8 @@ export function register(app, basePath = '') {
}
});
// #endregion
/**
* @openapi
* /customergroup/{id}:
@@ -383,6 +399,8 @@ export function register(app, basePath = '') {
* schema:
* $ref: '#/components/schemas/Error'
*/
// #region PATCH /customergroup/:id
app.patch(`${basePath}/customergroup/:id`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -406,6 +424,10 @@ export function register(app, basePath = '') {
}
});
// #endregion
// #region DELETE /customergroup/:id
app.delete(`${basePath}/customergroup/:id`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -426,4 +448,6 @@ export function register(app, basePath = '') {
res.status(status).json({ error: error.message });
}
});
// #endregion
}