Files
dashlibstorage/src/store/unit/list.js
seb 12e83a7ffb 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.
2026-08-01 06:12:24 +02:00

20 lines
571 B
JavaScript

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);
};
}