@ -101,6 +101,7 @@ exports.orderNow = async (req, reply) => {
}
}
const insertedagent = await agent . save ( ) ;
return insertedagent ;
@ -110,3 +111,80 @@ exports.orderNow = async (req, reply) => {
throw boom . boomify ( err ) ;
}
} ;
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 ) ;
}
} ;