feat: Simplify proposals events and add warehouse events

This commit is contained in:
Josepablo C
2025-03-20 00:39:15 -06:00
parent 5ba802498f
commit 1d3c9bd443
9 changed files with 207 additions and 76 deletions

View 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 };