30 lines
898 B
JavaScript
30 lines
898 B
JavaScript
'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 };
|