Add company-scoped unit list/upsert/delete and article unit patches.

Units are isolated per company; article detail exposes full unit shape, and unused units can be deleted safely via FK NO ACTION.
This commit is contained in:
seb
2026-08-01 06:12:24 +02:00
parent 54700a145e
commit 12e83a7ffb
16 changed files with 519 additions and 44 deletions

19
src/store/unit/list.js Normal file
View File

@@ -0,0 +1,19 @@
import { LIST_BY_COMPANY } from '../../sql/unit.js';
import resolveCompanyAccess from '../companyuser/resolveCompanyAccess.js';
import shapeUnit from './shapeUnit.js';
export default function list(pool) {
const access = resolveCompanyAccess(pool);
return async (googleAuthId, companyId) => {
const { languageId } = await access(googleAuthId, companyId);
const result = await pool
.request()
.input('companyId', companyId)
.input('languageId', languageId)
.query(LIST_BY_COMPANY);
return result.recordset.map(shapeUnit);
};
}