Add company-scoped delivery store on manifest
This commit is contained in:
20
src/store/delivery/getById.js
Normal file
20
src/store/delivery/getById.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import resolveCompanyAccess from '../companyuser/resolveCompanyAccess.js';
|
||||
import { loadDelivery } from './helpers.js';
|
||||
|
||||
export default function getById(pool) {
|
||||
const access = resolveCompanyAccess(pool);
|
||||
|
||||
return async (googleAuthId, companyId, id) => {
|
||||
if (!Number.isFinite(id)) {
|
||||
throw new Error('Delivery not found');
|
||||
}
|
||||
|
||||
await access(googleAuthId, companyId);
|
||||
|
||||
const delivery = await loadDelivery(pool, null, companyId, id);
|
||||
if (!delivery) {
|
||||
throw new Error('Delivery not found');
|
||||
}
|
||||
return delivery;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user