Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions server/controllers/placeOrderController.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class placeOrderHandler {
const presentLocation = "Jos";
const total = (quantity * price) + parcelTypeCost(parcelType);
const status = 'pending';
const id = placeOrders.length;
const id = placeOrder.length;
const trackingID = uuidv5(`${senderName}${new Date()}${id}`, uuidv5.URL)
const sendOrder = {
email,
Expand All @@ -55,8 +55,8 @@ class placeOrderHandler {
placeOrder.push(sendOrder);
return response.status(201)
.json({
message: "Your delivery order is booked successfully",
sendOrder
message: "Your delivery order is booked successfully"
// sendOrder
});
}

Expand Down
22 changes: 3 additions & 19 deletions server/middlewares/placeOrderValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class placeOrderValidators {
if (!validEmail.test(email)) {
return response.status(400)
.json({
status: "!Unsuccessful",
status: "Unsuccessful!",
message: "You are sending invalid email format"
});
}
Expand Down Expand Up @@ -167,7 +167,7 @@ class placeOrderValidators {
}

weight = parseFloat(weight);
if (weight < 0 || weight > 1000) {
if (weight <= 0 || weight > 1000) {
return response.status(400)
.json({
status: "Unsuccessful!",
Expand Down Expand Up @@ -269,7 +269,7 @@ class placeOrderValidators {
});
}

if (quantity.length < 1 || quantity.length > 2) {
if (quantity.length > 2) {
return response.status(400)
.json({
status: "Unsuccessful!",
Expand Down Expand Up @@ -302,15 +302,6 @@ class placeOrderValidators {
message: "Wrong format, please enter parcelType as 'delicate' or 'non-delicate'"
});
}

if (parcelType.length < 8 || parcelType.length > 11) {
return response.status(400)
.json({
status: "Unsuccessful!",
message: "parcelType should be 8 to 12 characters long"
});
}

request.body.senderName = senderName;
request.body.receiverName = receiverName
request.body.senderPhone = senderPhone;
Expand Down Expand Up @@ -343,13 +334,6 @@ class placeOrderValidators {

static getSpecificOrderValidator(request, response, next) {
let {parcelId} = request.params;
if (!(parcelId)) {
return response.status(400)
.json({
status: 'Unsuccessful!',
message: 'Sorry! this is an invalid URL'
});
}
const isExistOrder = placeOrder.find(placeOrder => placeOrder.trackingID === (parcelId));
if (!isExistOrder) {
return response.status(404)
Expand Down
Loading