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:
19
src/store/unit/list.js
Normal file
19
src/store/unit/list.js
Normal 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);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user