made changes in supplier and delivery

master
varun 3 years ago
commit fe6e6825ac

2
.gitignore vendored

@ -0,0 +1,2 @@
src/api-docs/api.html
src/config/swagger.js

@ -10,7 +10,7 @@ const saltRounds = 10;
//Get the data models
const { Supplier ,ProfilePicture, generateSupplierId} = require('../models/supplier');
const { Supplier ,ProfilePicture, generateSupplierId, DeliveryBoy} = require('../models/supplier');
async function bcryptPassword(password) {
@ -55,6 +55,29 @@ exports.loginSupplier = async (req) => {
//DeliveryBoy Login Controller
exports.loginDeliveryBoy = async (req) => {
try {
const phone = req.body.phone;
const delivery = await DeliveryBoy.findOne({ phone: phone });
if (delivery) {
return { same: true, delivery: delivery };
} else {
return { same: false };
}
} catch (err) {
throw boom.boomify(err);
}
};
exports.addSupplier = async (req, reply) => {
try {
// await resetCounter();//to set customer id back to 0
@ -80,6 +103,8 @@ exports.loginSupplier = async (req) => {
office_adress: req.body.office_adress,
zip: req.body.zip,
},
latitude: req.body.latitude,
longitude: req.body.longitude
};
var supplier = new Supplier(s_data);
@ -87,7 +112,7 @@ exports.loginSupplier = async (req) => {
//password is not at the top level in the collection.
supplierpass = req.body.password;
// If fields are sent via form encoding , capture the fields and assign them to the user Object.
// If fields are sent via form encoding , capture the fields and assign them to the supplier Object.
checkFormEncoding = isSupplierFormUrlEncoded(req);
if (checkFormEncoding.isSupplierFormUrlEncoded) {
@ -102,6 +127,8 @@ exports.loginSupplier = async (req) => {
supplier.supplierId = suppliertobeInserted.supplier_id;
supplier.office_adress = suppliertobeInserted.office_adress;
supplier.alternativeContactNumber = suppliertobeInserted.alternativeContactNumber;
supplier.latitude = suppliertobeInserted.latitude;
supplier.longitude = suppliertobeInserted.longitude;
}
@ -137,6 +164,8 @@ exports.loginSupplier = async (req) => {
},
],
profile: insertedSupplier.profile,
latitude: insertedSupplier.latitude,
longitude: insertedSupplier.longitude
},
status_code: 200,
};
@ -148,3 +177,62 @@ exports.loginSupplier = async (req) => {
throw boom.boomify(err);
}
};
exports.editCuurentSupplierInfo = async (req, reply) => {
try {
const { supplierId } = req.params;
const supplierInfo = await Supplier.findOne({ supplierId: supplierId.toString() });
const updateData = req.body;
if (updateData.firstName) supplierInfo.profile.firstName = updateData.firstName;
if (updateData.lastName) supplierInfo.profile.lastName = updateData.lastName;
if (updateData.suppliername) supplierInfo.suppliername = updateData.suppliername;
if (updateData.phone) supplierInfo.profile.contactNumber = updateData.phone;
if (updateData.office_address) supplierInfo.profile.office_address = updateData.office_address;
if (updateData.alternativeContactNumber) supplierInfo.profile.alternativeContactNumber = updateData.alternativeContactNumber;
if (updateData.city) supplierInfo.profile.city = updateData.city;
if (updateData.state) supplierInfo.profile.state = updateData.state;
if (updateData.country) supplierInfo.profile.country = updateData.country;
if (updateData.zip) supplierInfo.profile.zip = updateData.zip;
if (updateData.phone) supplierInfo.phone = updateData.phone;
if (updateData.emails) supplierInfo.emails = updateData.emails;
console.log(supplierInfo.emails[0].email)
if (updateData.role) supplierInfo.profile.role = updateData.role;
if (updateData.phone) {
const phoneNumber = updateData.phone //libphonenumberjs.parsePhoneNumber(updateData.phone);
if (phoneNumber) {
// access returned collection
if (!phoneNumber) { //if (!phoneNumber.isValid()) {
error = {
armintatankdata: {
error: true,
code: 10002,
message:
"10002 - Phone # " +
updateData.phone +
" is not a valid phone number",
},
};
req.body.regError = error;
reply.status(406).send(error);
}
}
}
if (supplierInfo.phone == updateData.phone) {
console.log("IF++++++++++++++=");
supplierInfo.phone = updateData.phone;
supplierInfo.phoneVerified = true;
} else {
console.log("Ilse++++++++++++++=");
supplierInfo.phone = updateData.phone;
supplierInfo.phoneVerified = false;
}
const supplier = await supplierInfo.save();
return supplier;
} catch (err) {
throw boom.boomify(err);
}
};

@ -9,8 +9,6 @@ const fastify = require("fastify")({
const { Tanker, Tankerbooking,Bore,GovtPipeLine } = require('../models/tankers')
exports.orderNow = async (req, reply) => {
try {
@ -33,7 +31,6 @@ exports.orderNow = async (req, reply) => {
booking_info.delivery_agent_alternative_mobile = agent_alternative_mobile
booking_info.price = price
}
else {
booking_info.orderStatus = "rejected"
@ -61,8 +58,6 @@ exports.orderNow = async (req, reply) => {
// const userInfo = await User.findOne({ username: username.toString() });
// const updateData = req.body;
// console.log("This is the reply in the handler after the validations", reply);
deliveryData = {
supplierId: supplierId,
@ -73,7 +68,7 @@ exports.orderNow = async (req, reply) => {
city:req.body.city,
state:req.body.state,
zip:req.body.zip,
status:req.body.status,
};
var agent_mobile = req.body.phone
@ -98,9 +93,11 @@ exports.orderNow = async (req, reply) => {
agent.city = usertobeInserted.city
agent.state = usertobeInserted.state
agent.zip = usertobeInserted.zip
agent.status = usertobeInserted.status
}
}
const insertedagent = await agent.save();
return insertedagent;
@ -111,6 +108,84 @@ exports.orderNow = async (req, reply) => {
}
};
<<<<<<< HEAD
=======
exports.getactiveDeliveryboys = async (req, reply) => {
try {
await DeliveryBoy.find({supplierId: req.params.supplierId,status:"active"})
.exec()
.then((docs) => {
reply.send({ status_code: 200, data: docs, count: docs.length });
})
.catch((err) => {
console.log(err);
reply.send({ error: err });
});
} catch (err) {
throw boom.boomify(err);
}
};
exports.verifyPhone = async (req, reply) => {
console.log("-------------------------------------------------");
try {
phone = req.body.phone;
phoneVerificationCode = req.body.phoneVerificationCode;
// check if user exists in the system. If user exists , display message that
// username is not available
console.log(
"this is the phone and verification code",
phone,
phoneVerificationCode
);
userExists = await Supplier.findOne({
phone: phone,
phoneVerified: false,
phoneVerificationCode: phoneVerificationCode,
});
console.log(userExists);
if (userExists) {
// update the phoneVerified flag to true.
const filter = {
phone: phone,
phoneVerificationCode: phoneVerificationCode,
};
const update = { phoneVerified: true };
const doc = await Supplier.findOneAndUpdate(filter, update);
updatedUser = await Supplier.findOne({ phone: phone });
if (updatedUser.phoneVerified) {
reply.send('{"armintatankdata":{"error":false,"verified": true}}');
} else {
error = {
armintatankdata: {
error: true,
code: 10005,
message: "10005 - Verification code entered cannot be validated.",
},
};
req.body.regError = error;
reply.send(error);
}
} else {
error = {
armintatankdata: {
error: true,
code: 10005,
message: "10005 - Verification code entered cannot be validated.",
},
};
req.body.regError = error;
reply.send(error);
}
} catch (err) {
throw boom.boomify(err);
}
};
>>>>>>> 60bf11771a70cdf5e9aebea6b1d85864dc4d8918
exports.getbookingsofsupplier = async (req, reply) => {
try {
@ -146,3 +221,7 @@ exports.getbookingsofdeliveryboy = async (req, reply) => {
throw boom.boomify(err);
}
};
<<<<<<< HEAD
=======
>>>>>>> 60bf11771a70cdf5e9aebea6b1d85864dc4d8918

@ -1,7 +1,8 @@
const { Tanker, Tankerbooking,Bore,GovtPipeLine } = require('../models/tankers')
const { User,Counter, generateBookingId,resetCounter,generateCustomerId } = require('../models/User')
const { Tank } = require('../models/tanks')
const { FriendRequest } = require('../models/supplier')
//const User = require("../models/User");
const boom = require("boom");
@ -193,6 +194,8 @@ exports.tankerBooking = async (req, reply) => {
else {
bookingsData = {
tankname:req.body.tankname,
tankLocation:req.body.tankLocation,
tankerName:tankerName,
customerId:customerId,
bookingid : bookingId,
@ -212,6 +215,8 @@ exports.tankerBooking = async (req, reply) => {
usertobeInserted = checkFormEncoding.tankersBookingData;
console.log("thsi true url string");
tankersBookingData.customerId = customerId;
tankersBookingData.tankname = usertobeInserted.tankname;
tankersBookingData.tankLocation = usertobeInserted.tankLocation;
tankersBookingData.tankerName = tankerName;
tankersBookingData.bookingid = bookingId;
tankersBookingData.capacity = usertobeInserted.capacity;
@ -527,3 +532,269 @@ exports.status = async (req, reply) => {
}
};
exports.connectionStatus = async (req, reply) => {
try {
// query the database to check if the customer and supplier are connected
const isConnected = await User.findOne({ customerId: req.query.customerId })
.populate('supplier', null, { supplierId: req.query.supplierId })
.exec()
.then(customer => customer.supplier !== null);
console.log("isconne..", isConnected)
if (isConnected) {
// if customer and supplier are connected, return list of tankers
const tankers = await Tanker.find({ }).exec();
console.log("tankers..", tankers)
reply.send({ tankers });
} else {
// if customer and supplier are not connected, return error
reply.status(403).send({ error: 'Forbidden' });
}
//res.send({ tankers });
} catch (err) {
console.error(err);
reply.status(500).send({ error: 'Internal server error' });
}
}
exports.connectstatus = async (req, reply) => {
try {
const customerId = req.params.customerId;
const supplierId = req.query.supplierId;
console.log(req.params.customerId)
console.log(req.query.supplierId)
const data = await FriendRequest.findOne({ customerId: customerId, supplierId: supplierId });
let connection_status = "not requested";
if (data) {
connection_status = data.status;
}
reply.send({ status_code: 200, customerId: customerId, supplierId: supplierId, status: connection_status });
} catch (err) {
throw boom.boomify(err);
}
};
exports.deliveryboystart = async (req, reply) => {
try {
//let start_time,stop_time
const customerId = req.params.customerId;
const tankLocation = req.body.tankLocation;
const action = req.body.action
const receiver_tank = req.body.tankname
const receiver_tank_info = await Tank.findOne({ customerId ,tankName:receiver_tank,tankLocation:tankLocation.toLowerCase()});
const receiver_capacity = parseInt((receiver_tank_info.capacity).replace(/,/g, ''), 10)
const desired_water_percentage = parseInt((req.body.percentage).replace(/,/g, ''), 10)
const intervals = {};
if(action === "start"){
start_time = new Date().toLocaleString('en-US', {timeZone: 'Asia/Kolkata'})
const supplier_tank = req.body.from
const supplier_tank_type = (req.body.from_type).toLowerCase()
const receiver_type = (req.body.to_type).toLowerCase()
console.log(supplier_tank)
if(supplier_tank_type==="sump" && receiver_type === "overhead"){
await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:receiver_type}, { $set: { motor_status: "1" } });
const supplier_tank_info1 = await Tank.findOne({ customerId ,tankName:supplier_tank,tankLocation:supplier_tank_type});
//console.log(supplier_tank_info1)
//const initial_update = parseInt(supplier_tank_info1.waterlevel.replace(/,/g, ''), 10)-200;
// await Tank.findOneAndUpdate({customerId, tankName: supplier_tank,tankLocation:supplier_tank_type}, { $set: { waterlevel: initial_update } });
const supplier_tank_info = await Tank.findOne({ customerId ,tankName:supplier_tank,tankLocation:supplier_tank_type});
// await changingfrom_tankwaterlevel(customerId,initial_update,supplier_tank_info);
let supplier_waterlevel = parseInt(supplier_tank_info.waterlevel.replace(/,/g, ''), 10)
// console.log(supplier_waterlevel)
let receiver_waterlevel = parseInt(receiver_tank_info.waterlevel.replace(/,/g, ''), 10)
intervals[receiver_tank] = setInterval(async function () {
// Calculate new water levels
const supplier_tank_info2 = await Tank.findOne({ customerId ,tankName:supplier_tank,tankLocation:supplier_tank_type});
const rcvr_info = await Tank.findOne({ customerId ,tankName:receiver_tank,tankLocation:receiver_type});
const newWaterLevel = receiver_waterlevel + 350//Math.floor(supplier_waterlevel * 0.1);
const newSupplierWaterLevel = supplier_waterlevel//Math.floor(supplier_waterlevel * 0.1);
const supplier_capacity = parseInt(supplier_tank_info.capacity.replace(/,/g, ''), 10)
console.log((newSupplierWaterLevel/supplier_capacity)*100)
// Check if updating should stop
if ((newSupplierWaterLevel/supplier_capacity)*100 <= 5 || (newWaterLevel/receiver_capacity)*100 >= 95 || (newWaterLevel/receiver_capacity)*100 >= desired_water_percentage || rcvr_info.motor_status === "0") {
clearInterval(intervals[receiver_tank]); // Clear the interval for this tank
delete intervals[receiver_tank];
await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:receiver_type}, { $set: { motor_status: "0" } });
console.log("end for"+receiver_tank);
} else {
// Update water levels in database
//supplier_waterlevel = newSupplierWaterLevel;
receiver_waterlevel = newWaterLevel;
console.log((newSupplierWaterLevel/supplier_capacity)*100)
// console.log((newWaterLevel/receiver_capacity)*100)
console.log(receiver_tank+""+newWaterLevel+""+"bore to sump")
await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:receiver_type}, { $set: { waterlevel: newWaterLevel } })
if (supplier_tank_info2.motor_status==="0"){
supplier_waterlevel = parseInt(supplier_tank_info2.waterlevel.replace(/,/g, ''), 10)-350
console.log(supplier_tank+""+newSupplierWaterLevel+""+"s to oh")
await Tank.findOneAndUpdate({customerId, tankName: supplier_tank,tankLocation:supplier_tank_type}, { $set: { waterlevel: supplier_waterlevel } })
}
}
}, 2000);
}
// if(supplier_tank_type==="sump" && receiver_type === "overhead"){
// await Tank.findOneAndUpdate({customerId, tankName: receiver_tank}, { $set: { motor_status: 1 } });
// // console.log(rcvr_info.motor_status)
// const supplier_tank_info1 = await Tank.findOne({ customerId ,tankName:supplier_tank});
// initial_update = parseInt(supplier_tank_info1.capacity.replace(/,/g, ''), 10)/2;
// await Tank.findOneAndUpdate({customerId, tankName: supplier_tank}, { $set: { waterlevel: initial_update } });
// const supplier_tank_info = await Tank.findOne({ customerId ,tankName:supplier_tank});
// let supplier_waterlevel = parseInt(supplier_tank_info.waterlevel.replace(/,/g, ''), 10)
// let receiver_waterlevel = parseInt(receiver_tank_info.waterlevel.replace(/,/g, ''), 10)
// intervalId = setInterval(async function () {
// const rcvr_info = await Tank.findOne({ customerId ,tankName:receiver_tank});
// const supplier_capacity = parseInt(supplier_tank_info.capacity.replace(/,/g, ''), 10)
// // Calculate new water levels
// const newWaterLevel = receiver_waterlevel + 200//Math.floor(supplier_waterlevel * 0.1);
// const newSupplierWaterLevel = Math.min(supplier_capacity, supplier_waterlevel + 350);// Math.floor(supplier_waterlevel * 0.15));
// // console.log(newWaterLevel)
// // console.log(newSupplierWaterLevel)
// // console.log(rcvr_info.motor_status)
// // console.log(rcvr_info.tankName)
// // Check if updating should stop
// if ( (newWaterLevel/receiver_capacity)*100 >= 95 || (newWaterLevel/receiver_capacity)*100 >= desired_water_percentage || rcvr_info.motor_status === 0) {
// clearInterval(intervalId)
// await Tank.findOneAndUpdate({customerId, tankName: receiver_tank}, { $set: { motor_status: 0 } });
// console.log("end");
// } else {
// // Update water levels in database
// supplier_waterlevel = newSupplierWaterLevel;
// receiver_waterlevel = newWaterLevel;
// // console.log((newSupplierWaterLevel/supplier_capacity)*100)
// // console.log((newWaterLevel/receiver_capacity)*100)
// await Promise.all([
// Tank.findOneAndUpdate({customerId, tankName: receiver_tank}, { $set: { waterlevel: newWaterLevel } }),
// Tank.findOneAndUpdate({customerId, tankName: supplier_tank}, { $set: { waterlevel: newSupplierWaterLevel } })
// ]);
// }
// }, 2000);
// }
if(supplier_tank_type==="bore" && receiver_type === "sump"){
const receiver_capacity = parseInt(receiver_tank_info.capacity.replace(/,/g, ''), 10)
// console.log(receiver_capacity,"0",receiver_tank_info.tankName)
await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:receiver_type}, { $set: { motor_status: "1" } });
let receiver_waterlevel = parseInt(receiver_tank_info.waterlevel.replace(/,/g, ''), 10)
// console.log(receiver_waterlevel,"1")
intervals[receiver_tank] = setInterval(async function () {
// Calculate new water levels
const rcvr_info = await Tank.findOne({ customerId ,tankName:receiver_tank,tankLocation:receiver_type});
//console.log(rcvr_info)
//console.log(rcvr_info.motor_status)
const newWaterLevel = receiver_waterlevel+450;
//console.log(newWaterLevel,"2",receiver_tank_info.tankName)
// Check if updating should stop
if ((newWaterLevel/receiver_capacity)*100 >= 97 || (newWaterLevel/receiver_capacity)*100 >= desired_water_percentage || rcvr_info.motor_status === "0" ) {
await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:receiver_type}, { $set: { motor_status: "0" } });
clearInterval(intervals[receiver_tank]); // Clear the interval for this tank
delete intervals[receiver_tank];
console.log("end for" + receiver_tank);
} else {
// Update water levels in database
receiver_waterlevel = newWaterLevel;
console.log(receiver_tank+""+newWaterLevel+""+"bore to sump")
//console.log((newWaterLevel/receiver_capacity)*100,"4",receiver_tank_info.tankName)
await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:receiver_type}, { $set: { waterlevel: newWaterLevel } })
}
}, 2000);
}
// console.log(customerId,req.body.from,req.body.from_type,receiver_tank,req.body.to_type,)
motorData = {
customerId:customerId,
supplierTank : req.body.from,
supplier_type: req.body.from_type,
receiverTank: receiver_tank,
receiver_type: req.body.to_type,
startTime: req.body.startTime,
stopTime: req.body.stopTime,
};
var motorData = new MotorData(motorData);
checkFormEncoding = isUserFormUrlEncoded(req);
if (checkFormEncoding.isUserFormUrlEncoded) {
usertobeInserted = checkFormEncoding.motorData;
console.log("thsi true url string");
motorData.customerId = customerId;
motorData.supplierTank = req.body.from;
motorData.receiverTank = receiver_tank;
motorData.supplier_type = req.body.from_type;
motorData.receiver_type = req.body.to_type;
motorData.startTime = usertobeInserted.startTime;
motorData.stopTime = usertobeInserted.stopTime;
}
const motor_data = await motorData.save();
// reply.send({ status_code: 200, data: motor_data });
reply.send({ status_code: 200, "start time": start_time, data: motor_data});
console.log(start_time)
return motor_data
}
else if (action === "stop") {
stop_time = new Date().toLocaleString('en-US', {timeZone: 'Asia/Kolkata'})
// console.log(stop_time)
// clearInterval(intervalId);
await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:(req.body.to_type).toLowerCase()}, { $set: { motor_status: "0" } });
reply.send({ status_code: 200, "stop time": stop_time});
} else {
throw new Error("Invalid action");
}
return { message: 'Water level updates started' };
} catch (err) {
throw new Error(`Failed to start/stop water level updates: ${err.message}`);
};
};

@ -6,7 +6,7 @@ const boom = require("boom");
const fastify = require("fastify")({
logger: true,
});
const tanksController = require("./tanksController")
// const tanksController = require("./tanksController")

@ -11,6 +11,7 @@ const libphonenumberjs = require("libphonenumber-js");
const boom = require("boom");
// Get Data Models
const { Supplier, generateSupplierId, FriendRequest,DeliveryBoy} = require("../models/supplier")
const { User,Counter, generateBookingId,resetCounter,generateCustomerId,ProfilePicture} = require('../models/User')
//const User = require("../models/User");
@ -400,7 +401,19 @@ exports.sendSms = async (request, reply) => {
const mobile = request.body.mobileNumbers//'8341426949';
const message = `Welcome to Arminta !!! your OTP is ${code} please use it for login.`//`Welcome to Arminta !!! your OTP is ${code} please use it for login.`;
await User.findOneAndUpdate({phone: mobile}, { $set: {'phoneVerificationCode': code } })
const user = await User.findOne({phone: mobile})
const supplier = await Supplier.findOne({phone: mobile})
const deliveryBoy = await DeliveryBoy.findOne( { phone : mobile})
if(user){
await User.findOneAndUpdate({phone: mobile}, { $set: {'phoneVerificationCode': code } })
}
if(supplier){
await Supplier.findOneAndUpdate({phone: mobile}, { $set: {'phoneVerificationCode': code } })
}
if(deliveryBoy){
await DeliveryBoy.findOneAndUpdate({phone: mobile}, { $set: {'phoneVerificationCode': code } })
}
const apiUrl = `https://smslogin.co/v3/api.php?username=${username}&apikey=${apiKey}&senderid=${senderId}&mobile=${mobile}&message=${encodeURIComponent(message)}`;
const options = {

@ -11,31 +11,41 @@ const fastify = require("fastify")({
// Handle friend request creation
exports.friendRequest = async (request, reply) => {
try {
const { senderId, receiverId } = request.body;
// const { senderId, receiverId } = request.body;
const customerId = request.body.customerId;
const supplierId = request.body.supplierId;
// Check if the sender and receiver exist in the database
const sender = await User.findById(senderId);
const receiver = await Supplier.findById(receiverId);
console.log("sender" , sender)
console.log("receiver" , receiver)
// const sender = await User.findById(senderId);
// const receiver = await Supplier.findById(receiverId);
// console.log("sender" , sender)
// console.log("receiver" , receiver)
const sender = await User.findOne({ customerId : customerId});
const receiver = await Supplier.findOne({ supplierId : supplierId});
console.log("sender" , sender.customerId)
console.log("receiver" , receiver.supplierId)
if (!sender || !receiver) {
throw new Error('Sender or receiver not found');
}
// Check if a friend request already exists between the two users
const existingRequest = await FriendRequest.findOne({ sender: senderId, receiver: receiverId });
// const existingRequest = await FriendRequest.findOne({ sender: senderId, receiver: receiverId });
const existingRequest = await FriendRequest.findOne({ customerId: sender.customerId, supplierId: receiver.supplierId});
console.log(existingRequest, " .. exist")
if (existingRequest) {
throw new Error('Friend request already sent');
}
// Create a new friend request
const friendRequest = new FriendRequest({
sender: senderId,
receiver: receiverId
});
const friendRequest = new FriendRequest({ customerId: sender.customerId, supplierId: receiver.supplierId});
// // Create a new friend request
// const friendRequest = new FriendRequest({
// sender: senderId,
// receiver: receiverId
// });
await friendRequest.save();
console.log("friendRequest", friendRequest)
@ -49,10 +59,11 @@ exports.friendRequest = async (request, reply) => {
// Handle friend request acceptance
exports.friendRequestAccept = async (request, reply) => {
try {
const {friendRequestId} = request.body;
//const {friendRequestId} = request.body;
const {supplierId} = request.body;
// Update the friend request status to 'accepted'
const friendRequest = await FriendRequest.findByIdAndUpdate(friendRequestId, { status: 'accepted' });
// const friendRequest = await FriendRequest.findByIdAndUpdate(friendRequestId, { status: 'accepted' });
const friendRequest = await FriendRequest.findOneAndUpdate({supplierId}, { status: 'accepted' });
console.log("friendRequest....---", friendRequest)
@ -70,10 +81,11 @@ exports.friendRequestAccept = async (request, reply) => {
// Handle friend request rejection
exports.friendRequestReject = async (request, reply) => {
try {
const {friendRequestId} = request.body;
//const {friendRequestId} = request.body;
const {supplierId} = request.body;
// Update the friend request status to 'rejected'
const friendRequest = await FriendRequest.findByIdAndUpdate(friendRequestId, { status: 'rejected' });
// const friendRequest = await FriendRequest.findByIdAndUpdate(friendRequestId, { status: 'rejected' });
const friendRequest = await FriendRequest.findOneAndUpdate({supplierId}, { status: 'rejected' });
console.log("friendRequest....---", friendRequest)

@ -1,6 +1,7 @@
//Get the data models
const { Supplier } = require('../models/supplier');
const { ProfilePicture } = require('../models/User')
const { Supplier, DeliveryBoy } = require('../models/supplier');
const { FriendRequest } = require('../models/supplier')
const { ProfilePicture, User } = require('../models/User')
const supplierController = require("../controllers/supplierController");
const customJwtAuth = require("../customAuthJwt");
const fastify = require("fastify")({
@ -192,6 +193,8 @@ exports.loginSupplier = async(request, reply) =>{
office_address: loginObject.supplier.profile.office_address,
phoneVerified: loginObject.supplier.phoneVerified,
oneTimePasswordSetFlag: loginObject.supplier.oneTimePasswordSetFlag,
latitude: loginObject.supplier.latitude,
longitude: loginObject.supplier.longitude,
type: loginObject.supplier.profile.role,
typeasobj: stringToJsonObject,
},
@ -210,6 +213,8 @@ exports.loginSupplier = async(request, reply) =>{
office_address: loginObject.supplier.profile.office_address,
phoneVerified: loginObject.supplier.phoneVerified,
oneTimePasswordSetFlag: loginObject.supplier.oneTimePasswordSetFlag,
latitude: loginObject.supplier.latitude,
longitude: loginObject.supplier.longitude,
type: loginObject.supplier.profile.role,
typeasobj: stringToJsonObject,
},
@ -230,6 +235,114 @@ exports.loginSupplier = async(request, reply) =>{
}
//Login Delivery Handler
exports.loginDeliveryBoy = async(request, reply) =>{
loginObject = await supplierController.loginDeliveryBoy(request);
console.log("loginObject...",loginObject)
if (loginObject.same) {
const phoneVerified = loginObject.delivery.phoneVerified;
const oneTimePasswordSetFlag = loginObject.delivery.oneTimePasswordSetFlag;
console.log(
"oneTimePasswordSetFlag is ......",
oneTimePasswordSetFlag,
typeof oneTimePasswordSetFlag,
typeof phoneVerified
);
if (!phoneVerified) {
reply.send({
simplydata: {
error: false,
phoneVerified: false,
phone: loginObject.delivery.phone,
oneTimePasswordSetFlag: oneTimePasswordSetFlag,
message: "Please Verify your phone number",
},
});
} else if (oneTimePasswordSetFlag) {
reply.send({
simplydata: {
error: false,
phoneVerified: phoneVerified,
phone: loginObject.delivery.phone,
oneTimePasswordSetFlag: true,
message: "Password must be reset",
},
});
} else {
const token = fastify.jwt.sign(
{
deliveryBoyname: loginObject.delivery.name,
deliveryBoyId: loginObject.delivery._id,
},
//expiresIn: expressed in seconds or a string describing a time span zeit/ms. Eg: 60, "2 days", "10h", "7d".
//A numeric value is interpreted as a seconds count. If you use a string be sure you provide the time units (days, hours, etc),
//otherwise milliseconds unit is used by default ("120" is equal to "120ms").
{ expiresIn: "30d" }
);
console.log(token, "..token")
var d_id = loginObject.delivery._id
console.log(d_id,"deliveryId")
var profilePicture = await ProfilePicture.findOne({ deliveryBoyId:d_id});
// request.session.set('supplierId', loginObject.supplier._id)
if (!profilePicture) {
reply.send({
simplydata: {
error: false,
apiversion: fastify.config.APIVERSION,
access_token: token,
phone: loginObject.delivery.phone,
deliveryBoyId: loginObject.delivery.deliveryBoyId,
deliveryBoyname: loginObject.delivery.name,
address: loginObject.delivery.address,
phoneVerified: loginObject.delivery.phoneVerified,
oneTimePasswordSetFlag: loginObject.delivery.oneTimePasswordSetFlag,
},
});
}if (profilePicture) {
reply.send({
simplydata: {
error: false,
apiversion: fastify.config.APIVERSION,
access_token: token,
picture:profilePicture.picture,
phone: loginObject.delivery.phone,
deliveryBoyId: loginObject.delivery.deliveryBoyId,
deliveryBoyname: loginObject.delivery.name,
address: loginObject.delivery.address,
phoneVerified: loginObject.delivery.phoneVerified,
oneTimePasswordSetFlag: loginObject.delivery.oneTimePasswordSetFlag,
},
});
}
}
} else {
error = {
simplydata: {
error: true,
code: 400,
message: "Invalid Details",
},
};
reply.send(error);
}
}
// Check if all the required fields are supplied by the user
exports.fieldCheck = async (req, reply) => {
@ -522,6 +635,102 @@ exports.logoutsupplier = async (request, reply) => {
};
exports.deliveryBoyVerifyPhone = async (req, reply) => {
console.log("-------------------------------------------------");
try {
phone = req.body.phone;
phoneVerificationCode = req.body.phoneVerificationCode;
// check if user exists in the system. If user exists , display message that
// username is not available
console.log(
"this is the phone and verification code",
phone,
phoneVerificationCode
);
deliveryBoyExists = await DeliveryBoy.findOne({
phone: phone,
phoneVerified: false,
phoneVerificationCode: phoneVerificationCode,
});
console.log(deliveryBoyExists);
if (deliveryBoyExists) {
// update the phoneVerified flag to true.
const filter = {
phone: phone,
phoneVerificationCode: phoneVerificationCode,
};
const update = { phoneVerified: true };
const doc = await DeliveryBoy.findOneAndUpdate(filter, update);
updatedDeliveryBoy = await DeliveryBoy.findOne({ phone: phone });
if (updatedDeliveryBoy.phoneVerified) {
reply.send('{"armintatankdata":{"error":false,"verified": true}}');
} else {
error = {
armintatankdata: {
error: true,
code: 10005,
message: "10005 - Verification code entered cannot be validated.",
},
};
req.body.regError = error;
reply.send(error);
}
} else {
error = {
armintatankdata: {
error: true,
code: 10005,
message: "10005 - Verification code entered cannot be validated.",
},
};
req.body.regError = error;
reply.send(error);
}
} catch (err) {
throw boom.boomify(err);
}
};
//delete selected deliveryboy
exports.deleteDeliveryBoy = async (req, reply) => {
try {
var supplierId = req.params.supplierId;
var phone = req.query.phone;
const delivery = await DeliveryBoy.findOneAndDelete({ phone: phone,supplierId:supplierId });
reply.send({ status_code: 200, data: delivery});
// return tank;
} catch (err) {
throw boom.boomify(err);
}
};
//update selected Delivery Boy Details
exports.updateDeliveryBoy = async (req, reply) => {
try {
var supplierId = req.params.supplierId;
var phone = req.query.phone;
const delivery = req.body;
const { ...updateData } = delivery;
const update = await DeliveryBoy.findOneAndUpdate({ phone: phone,supplierId:supplierId, }, updateData, { new: true });
console.log(update)
//return update;
reply.send({ status_code: 200, data: update });
}
catch (err) {
throw boom.boomify(err);
}
};
// Get current supplier
exports.getCurrentSupplier = async (req, reply) => {
try {
@ -532,13 +741,37 @@ exports.getCurrentSupplier = async (req, reply) => {
throw boom.boomify(err);
}
};
// Get all users
// Get all suppliers
// exports.getSuppliers = async (req, reply) => {
// const limit = parseInt(req.query.limit) || 100;
// const page = parseInt(req.query.page) || 1;
// const startindex = (page - 1) * limit;
// try {
// await Supplier.find()
// .limit(limit)
// .skip(startindex)
// .exec()
// .then((docs) => {
// reply.send({ status_code: 200, data: docs, count: docs.length });
// })
// .catch((err) => {
// console.log(err);
// reply.send({ error: err });
// });
// } catch (err) {
// throw boom.boomify(err);
// }
// };
exports.getSuppliers = async (req, reply) => {
const limit = parseInt(req.query.limit) || 100;
const page = parseInt(req.query.page) || 1;
const startindex = (page - 1) * limit;
const customerId = req.params.customerId; // Assuming you have already authenticated the user and stored their ID in the request object
try {
await Supplier.find()
const friendRequests = await FriendRequest.find({ customerId });
const supplierIdsToExclude = friendRequests.map((request) => request.supplierId);
await Supplier.find({ supplierId: { $nin: supplierIdsToExclude } })
.limit(limit)
.skip(startindex)
.exec()
@ -554,6 +787,7 @@ exports.getSuppliers = async (req, reply) => {
}
};
// Get single user by ID
exports.getSingleSupplier = async (req, reply) => {
try {
@ -564,3 +798,115 @@ exports.getSingleSupplier = async (req, reply) => {
throw boom.boomify(err);
}
};
exports.getConnectedSuppliers = async (req, reply) => {
const limit = parseInt(req.query.limit) || 100;
const page = parseInt(req.query.page) || 1;
const startindex = (page - 1) * limit;
const customerId = req.params.customerId; // Assuming you have already authenticated the user and stored their ID in the request object
try {
const friendRequests = await FriendRequest.find({ customerId, status: "accepted" });
// console.log(friendRequests,customerId)
const supplierIdsToInclude = friendRequests.map((request) => request.supplierId);
await Supplier.find({ supplierId: { $in: supplierIdsToInclude } })
.limit(limit)
.skip(startindex)
.exec()
.then((docs) => {
reply.send({ status_code: 200, data: docs, count: docs.length });
})
.catch((err) => {
console.log(err);
reply.send({ error: err });
});
} catch (err) {
throw boom.boomify(err);
}
};
exports.getPendingSuppliers = async (req, reply) => {
const limit = parseInt(req.query.limit) || 100;
const page = parseInt(req.query.page) || 1;
const startindex = (page - 1) * limit;
const customerId = req.params.customerId; // Assuming you have already authenticated the user and stored their ID in the request object
try {
const friendRequests = await FriendRequest.find({ customerId, status: ["pending","rejected"] });
// console.log(friendRequests,customerId)
const supplierIdsToInclude = friendRequests.map((request) => request.supplierId);
// console.log(supplierIdsToInclude)
await Supplier.find({ supplierId: { $in: supplierIdsToInclude } })
.limit(limit)
.skip(startindex)
.exec()
.then((docs) => {
reply.send({ status_code: 200, data: docs, count: docs.length });
})
.catch((err) => {
console.log(err);
reply.send({ error: err });
});
} catch (err) {
throw boom.boomify(err);
}
};
exports.getPendingCustomers = async (req, reply) => {
const limit = parseInt(req.query.limit) || 100;
const page = parseInt(req.query.page) || 1;
const startindex = (page - 1) * limit;
const supplierId = req.params.supplierId; // Assuming you have already authenticated the user and stored their ID in the request object
try {
const friendRequests = await FriendRequest.find({ supplierId, status: ["pending","rejected"] });
console.log(friendRequests,supplierId, "su....")
const supplierIdsToInclude = friendRequests.map((request) => request.customerId);
console.log(supplierIdsToInclude, "supplierIdsToInclude..")
await User.find({ customerId: { $in: supplierIdsToInclude } })
.limit(limit)
.skip(startindex)
.exec()
.then((docs) => {
reply.send({ status_code: 200, data: docs, count: docs.length });
})
.catch((err) => {
console.log(err);
reply.send({ error: err });
});
} catch (err) {
throw boom.boomify(err);
}
};
exports.getconnectedCustomers = async (req, reply) => {
const limit = parseInt(req.query.limit) || 100;
const page = parseInt(req.query.page) || 1;
const startindex = (page - 1) * limit;
const supplierId = req.params.supplierId; // Assuming you have already authenticated the user and stored their ID in the request object
try {
const friendRequests = await FriendRequest.find({ supplierId, status: ["accepted"] });
console.log(friendRequests,supplierId, "su....")
const supplierIdsToInclude = friendRequests.map((request) => request.customerId);
console.log(supplierIdsToInclude, "supplierIdsToInclude..")
await User.find({ customerId: { $in: supplierIdsToInclude } })
.limit(limit)
.skip(startindex)
.exec()
.then((docs) => {
reply.send({ status_code: 200, data: docs, count: docs.length });
})
.catch((err) => {
console.log(err);
reply.send({ error: err });
});
} catch (err) {
throw boom.boomify(err);
}
};

@ -46,7 +46,7 @@ const userSchema = new mongoose.Schema(
username: { type: String },
phone: { type: String, unique: true, trim: true },
address: String,
customerId: String,
customerId: { type: String },
buildingName: String,
inchargeName: String,
phoneVerified: { type: Boolean, default: false },

@ -48,17 +48,22 @@ const supplierSchema = new mongoose.Schema(
default: 'pending'
},
currentGPS: {
// It's important to define type within type field, because
// mongoose use "type" to identify field's object type.
gpsType: { type: String, default: "Point" },
// Default value is needed. Mongoose pass an empty array to
// array type by default, but it will fail MongoDB's pre-save
// validation.
coordinates: { type: [Number], default: [0, 0] },
},
// currentGPS: {
// // It's important to define type within type field, because
// // mongoose use "type" to identify field's object type.
// gpsType: { type: String, default: "Point" },
// // Default value is needed. Mongoose pass an empty array to
// // array type by default, but it will fail MongoDB's pre-save
// // validation.
// coordinates: { type: [Number], default: [0, 0] },
// },
// location: {
// type: { type: String },
// coordinates: [Number]
// },
longitude: { type : Number},
latitude: {type: Number},
isActive: Boolean,
tenantId: ObjectId,
createdAt: {
@ -94,22 +99,28 @@ const supplierSchema = new mongoose.Schema(
// })
const friendRequestSchema = new mongoose.Schema({
sender: { type: mongoose.Schema.Types.ObjectId, ref: 'user' },
receiver: { type: mongoose.Schema.Types.ObjectId, ref: 'supplier' },
customerId: { type: String, default: null },
supplierId: { type: String, default: null },
status: { type: String, default: "pending" },
timestamp: { type: Date, default: Date.now }
});
const deliveryBoySchema = new mongoose.Schema({
supplierId:{ type: String, default: null },
name: { type: String, default: null },
phone: { type: String, default: null,unique:true },
alternativeContactNumber : { type : String,default: null },
phoneVerified: { type: Boolean, default: false },
phoneVerificationCode: { type: Number, default: 11111 },
passwordResetCode: { type: Number, default: code },
oneTimePasswordSetFlag: { type: Boolean, default: false },
address: { type: String, default: null },
city: { type: String, default: null },
state: { type: String, default: null },
zip: { type: String, default: null },
timestamp: { type: Date, default: Date.now },
status: { type: String, default: "active" },
status: { type: String, default: "Inactive" },
});

@ -21,12 +21,19 @@ const tankersSchema = new mongoose.Schema({
supplier_address: { type: String, default: null },
supplier_name : { type: String, default: null },
status: { type: String}
// price: {
// type: [String],
// default: []
// },
});
const tankersbookingSchema = new mongoose.Schema({
customerId: { type: String, default: null },
tankname:{ type: String, default: null },
tankLocation:{ type: String, default: null },
tankerName: { type: String, default: null },
bookingid: { type: String, default: null,unique: true },
supplierId:{type: String, default: null},
@ -74,6 +81,7 @@ const GovtPipeLineSchema = new mongoose.Schema({
const Tanker = mongoose.model("Tanker", tankersSchema);
const Tankerbooking = mongoose.model("Tankerbooking", tankersbookingSchema);
const Bore = mongoose.model("Bore", boreSchema);

@ -16,8 +16,8 @@ module.exports = function (fastify, opts, next) {
type: "object",
//required: ["customerId"],
properties: {
senderId: { type: "string" },
receiverId : { type : "string"}
customerId: { type: "string" },
supplierId : { type : "string"}
},
},
security: [
@ -40,7 +40,7 @@ module.exports = function (fastify, opts, next) {
body: {
type: "object",
properties: {
friendRequestId: { type: "string" },
supplierId: { type: "string" }
},
},
@ -63,7 +63,7 @@ module.exports = function (fastify, opts, next) {
body: {
type: "object",
properties: {
friendRequestId: { type: "string" },
supplierId: { type: "string" },
},
},

@ -87,6 +87,7 @@ module.exports = function (fastify, opts, next) {
status: { type: "string" },
},
},
security: [
{
@ -105,57 +106,6 @@ module.exports = function (fastify, opts, next) {
fastify.get("/api/getsupplierbookings/:supplierId", {
schema: {
tags: ["Supplier"],
description: "This is for Get supplier bookings Data",
summary: "This is for to Get supplier bookings Data",
params: {
required: ["supplierId"],
type: "object",
properties: {
supplierId: {
type: "string",
description: "supplierId",
},
},
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: supplierOrderController.getbookingsofsupplier,
});
fastify.get("/api/getdeliveryboybookings/:agent_mobile", {
schema: {
tags: ["Supplier"],
description: "This is for Get delivery bookings Data",
summary: "This is for to Get delivery bookings Data",
params: {
required: ["agent_mobile"],
type: "object",
properties: {
agent_mobile: {
type: "string",
description: "agent_mobile",
},
},
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: supplierOrderController.getbookingsofdeliveryboy,
});
next();
}

@ -7,11 +7,21 @@ const validationHandler = require("../handlers/supplierHandler");
module.exports = function (fastify, opts, next) {
fastify.get("/api/suppliers", {
fastify.get("/api/suppliers/:customerId", {
schema: {
tags: ["Supplier-Data"],
description: "This is for Get All Suppliers",
summary: "This is for to Get All Suppliers",
params: {
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
security: [
{
basicAuth: [],
@ -21,6 +31,109 @@ module.exports = function (fastify, opts, next) {
handler: validationHandler.getSuppliers,
});
fastify.get("/api/connectedSuppliers/:customerId", {
schema: {
tags: ["Supplier-Data"],
description: "This is for Get All connected Suppliers",
summary: "This is for to Get All connected Suppliers",
params: {
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
security: [
{
basicAuth: [],
},
],
},
handler: validationHandler.getConnectedSuppliers,
});
fastify.get("/api/pendingSuppliers/:customerId", {
schema: {
tags: ["Supplier-Data"],
description: "This is for Get All pending/rejected Suppliers",
summary: "This is for to Get All pending/rejected Suppliers",
params: {
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
security: [
{
basicAuth: [],
},
],
},
handler: validationHandler.getPendingSuppliers,
});
fastify.get("/api/pendingCustomers/:supplierId", {
schema: {
tags: ["Supplier-Data"],
description: "This is for Get All pending/rejected Customers",
summary: "This is for to Get All pending/rejected Customers",
params: {
type: "object",
properties: {
supplierId: {
type: "string",
description: "supplierId",
},
},
},
security: [
{
basicAuth: [],
},
],
},
handler: validationHandler.getPendingCustomers,
});
fastify.get("/api/connectedCustomers/:supplierId", {
schema: {
tags: ["Supplier-Data"],
description: "This is for Get All connected Customers for Suppliers",
summary: "This is for to Get All connected Customers for suppliers",
params: {
type: "object",
properties: {
supplierId: {
type: "string",
description: "supplierId",
},
},
},
security: [
{
basicAuth: [],
},
],
},
handler: validationHandler.getconnectedCustomers,
});
fastify.post("/api/supplierlogin", {
schema: {
description: "This is for Login Supplier",
@ -39,6 +152,22 @@ module.exports = function (fastify, opts, next) {
});
fastify.post("/api/deliveryboylogin", {
schema: {
description: "This is for Login Delivery Boy",
tags: ["Supplier-Data"],
summary: "This is for Login Delivery Boy",
body: {
type: "object",
required: ["phone"],
properties: {
phone: { type: "string" },
},
},
},
handler: validationHandler.loginDeliveryBoy,
});
fastify.route({
method: "POST",
url: "/api/supplierlogout",
@ -93,6 +222,8 @@ module.exports = function (fastify, opts, next) {
state: { type: "string", default: null },
zip: { type: "string", default: null },
country: { type: "string", default: null },
latitude: { type: 'number' },
longitude: { type: 'number'}
},
},
security: [
@ -137,6 +268,112 @@ module.exports = function (fastify, opts, next) {
});
fastify.route({
method: "POST",
url: "/api/deliveryboyphone",
schema: {
tags: ["Supplier-Data"],
description: "This is for verify Delivery Boy Phone",
summary: "This is to Verify Delivery Boy Phone.",
body: {
type: "object",
required: ["phone"],
properties: {
phoneVerificationCode: { type: "string" },
phone: { type: "string" },
},
},
security: [
{
basicAuth: [],
},
],
},
// preHandler: fastify.auth([fastify.authenticate]),
handler: validationHandler.deliveryBoyVerifyPhone,
});
fastify.route({
method: "PUT",
url: "/api/deletedeliveryboy/:supplierId",
schema: {
tags: ["Supplier-Data"],
summary: "This is for delete delivery boy",
description: "This is for delete delivery boy",
params: {
required: ["supplierId"],
type: "object",
properties: {
supplierId: {
type: "string",
description: "supplierId",
},
},
},
querystring: {
phone: {type: 'string'}
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: validationHandler.deleteDeliveryBoy,
});
fastify.route({
method: "PUT",
url: "/api/updatedeliveryboy/:supplierId",
schema: {
tags: ["Supplier-Data"],
summary: "This is for update deliveryboy details",
params: {
required: ["supplierId"],
type: "object",
properties: {
supplierId: {
type: "string",
description: "supplierId",
},
},
},
querystring: {
phone: {type: 'string'}
},
body: {
type: "object",
// required: ['phone'],
properties: {
name: { type: "string", default: null },
phone: { type: "string", default: null },
alternativeContactNumber: { type: "string" },
address: { type: "string", default: null },
city: { type: "string" , default: null},
state: { type: "string", default: null },
zip: { type: "string", default: null },
},
},
security: [
{
basicAuth: [],
},
],
},
// preHandler: [
// fastify.auth([fastify.operatorAuthenticate]),
// validationHandler.validatePhoneFormat,
// ],
preHandler: fastify.auth([fastify.authenticate]),
handler: validationHandler.updateDeliveryBoy,
});
fastify.route({
method: "POST",
url: "/api/suppliers/:supplierId",
@ -189,6 +426,57 @@ module.exports = function (fastify, opts, next) {
});
fastify.route({
method: "PUT",
url: "/api/update/currentSupplier/:supplierId",
schema: {
tags: ["Supplier-Data"],
summary: "This is for update current supplier",
description: "This is for update current supplier",
params: {
type: "object",
properties: {
supplierId: {
type: "string",
description: "supplierId",
},
},
},
body: {
type: "object",
properties: {
phone: { type: "string" },
firstName: { type: "string" },
lastName: { type: "string" },
suppliername: { type: "string" },
emails: {
type: "array",
maxItems: 2,
items: {
type: "object",
properties: {
email: { type: "string", default: null },
},
},
},
office_address: { type: "string" },
alternativeContactNumber: { type: "string" },
city: { type: "string" },
state: { type: "string" },
country: { type: "string" },
zip: { type: "string" },
},
},
security: [
{
basicAuth: [],
},
],
},
preHandler: [fastify.auth([fastify.authenticate])],
handler: supplierController.editCuurentSupplierInfo,
});
next();
}

@ -53,6 +53,9 @@ module.exports = function (fastify, opts, next) {
},
},
capacity: { type: "string"},
// price: {type : "string"},
// status: {type: "string"}
},
@ -95,10 +98,12 @@ module.exports = function (fastify, opts, next) {
},
body: {
type: "object",
// required: ['phone'],
properties: {
tankerName: { type: "string", default: null },
phoneNumber: { type: "string", default: null },
supplier_name: { type: "string" },
supplier_address:{ type: "string" },
tankerName: { type: "string" },
phoneNumber: { type: "string"},
alternative_phoneNumber: { type: "string"},
typeofwater: {
type: "array",
maxItems: 2500,
@ -110,16 +115,18 @@ module.exports = function (fastify, opts, next) {
},
},
capacity: {
type: "array",
price: {
type: "array",
maxItems: 2500,
items: {
type: "object",
properties: {
capacity: { type: "string", default: null },
},
},
price: { type: "string", default: null },
},
},
},
capacity: { type: "string"},
},
},
@ -197,6 +204,8 @@ module.exports = function (fastify, opts, next) {
capacity: { type: "string" },
address: { type: "string" },
dateOfOrder: { type: "string"},
price: { type: "string"},
supplierId: { type: "string"},
@ -320,6 +329,35 @@ module.exports = function (fastify, opts, next) {
handler: tankersController.getTankersBookingdetails,
});
fastify.get("/api/getAllTankersBookingdetails/:supplierId", {
schema: {
tags: ["Supplier"],
description: "This is for Get All Tanker Booking Data",
summary: "This is for to Get All Tanker Booking Data",
params: {
required: ["supplierId"],
type: "object",
properties: {
supplierId: {
type: "string",
description: "supplierId",
},
},
},
// querystring: {
// tankerName: {type: 'string'}
// },
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.getAllTankersBookingdetails,
});
fastify.get("/api/getBores", {
schema: {
tags: ["Supplier"],
@ -583,8 +621,85 @@ module.exports = function (fastify, opts, next) {
});
fastify.route({
method: 'GET',
url: '/connection-status',
schema: {
tags: ["Supplier"],
description: "This is for Get Tankers Data for status connected or not",
summary: "This is for to Get Tankers Data for status connected or not",
querystring: {
type: 'object',
properties: {
customerId: { type: 'string' },
//supplierId: { type: 'string' }
},
required: ['customerId']
},
security: [
{
basicAuth: [],
},
],
},
handler: tankersController.connectionStatus
});
fastify.get("/api/getConnectStatus/:customerId", {
schema: {
tags: ["Supplier"],
description: "This is to get connect status",
summary: "This is to get connect status",
params: {
required: ["customerId"],
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
querystring: {
supplierId: {type: 'string'}
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.connectstatus,
});
fastify.get("/api/alltankersaccepted/:supplierId", {
schema: {
tags: ["Supplier-Order"],
description: "This is for Get All connected and rejected for Suppliers",
summary: "This is for to Get All connected and rejected for suppliers",
params: {
type: "object",
properties: {
supplierId: {
type: "string",
description: "supplierId",
},
},
},
security: [
{
basicAuth: [],
},
],
},
handler: tankersController.getAllTankersaccepted,
});
next();
}

@ -0,0 +1 @@
Subproject commit 0f11d82f3692b53f67a15af4ad516bf0a1240d70
Loading…
Cancel
Save