feat: Simplify proposals events and add warehouse events
This commit is contained in:
29
v1/src/lib/Handlers/Events/Proposals/onAccepted.js
Normal file
29
v1/src/lib/Handlers/Events/Proposals/onAccepted.js
Normal file
@@ -0,0 +1,29 @@
|
||||
'user strict';
|
||||
const { getModel } = require( '../../../Models' );
|
||||
const warehouseEvents = require('../Warehouse');
|
||||
const notificationsModel = getModel('notifications');
|
||||
|
||||
/**
|
||||
* Send a platform notification to the
|
||||
* @param {*} proposal
|
||||
* @param {*} shipper
|
||||
* @param {*} vehicle
|
||||
* @param {*} load
|
||||
*/
|
||||
async function sendNotification( proposal, load ){
|
||||
const notification = new notificationsModel({
|
||||
"owner": proposal.bidder,
|
||||
"title": `Your proposal has been accepted!`,
|
||||
"description": `${load.shipment_code}`,
|
||||
"tag":"accepted_proposal",
|
||||
"deleted":false
|
||||
});
|
||||
|
||||
await notification.save();
|
||||
}
|
||||
|
||||
async function sendWarehouseEmail( warehouse, load, carrier, product, vehicle, driver ){
|
||||
await warehouseEvents.onProposalAccepted( warehouse, load, carrier, product, vehicle, driver );
|
||||
}
|
||||
|
||||
module.exports = { sendNotification, sendWarehouseEmail };
|
||||
Reference in New Issue
Block a user