Units are isolated per company; article detail exposes full unit shape, and unused units can be deleted safely via FK NO ACTION.
20 lines
571 B
JavaScript
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);
|
|
};
|
|
}
|