Add company-scoped delivery store on manifest
This commit is contained in:
19
src/store/delivery/list.js
Normal file
19
src/store/delivery/list.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { DELIVERY_TYPE, LIST_DELIVERIES } from '../../sql/delivery.js';
|
||||
import resolveCompanyAccess from '../companyuser/resolveCompanyAccess.js';
|
||||
import { shapeSummary } from './helpers.js';
|
||||
|
||||
export default function list(pool) {
|
||||
const access = resolveCompanyAccess(pool);
|
||||
|
||||
return async (googleAuthId, companyId) => {
|
||||
await access(googleAuthId, companyId);
|
||||
|
||||
const result = await pool
|
||||
.request()
|
||||
.input('companyId', companyId)
|
||||
.input('type', DELIVERY_TYPE)
|
||||
.query(LIST_DELIVERIES);
|
||||
|
||||
return result.recordset.map(shapeSummary);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user