Order Lifecycle
Orders progress through three statuses, stored as plain strings in MongoDB:1
Food Processing
The default status assigned when an order is first created. The kitchen has received the order and is preparing the food.
2
Out for delivery
The order has been dispatched and is on its way to the customer’s address.
3
Delivered
The order has been successfully delivered. This is the terminal state.
My Orders Page (Customer)
The/myorders route renders the MyOrders component. On mount (and whenever the token value changes), it calls POST /api/order/userorders — with the JWT token in the request header — to fetch all orders belonging to the logged-in user.
A Track Order button re-calls
fetchOrders to pull the latest status on demand.
Order Data Model
Order documents in MongoDB follow this Mongoose schema (frombackend/models/orderModel.js):
Example Order Object
Admin Order Management
The admin/orders page calls GET /api/order/list on mount to fetch every order across all users. Each order card shows:
- Ordered items (name × quantity, comma-separated)
- Customer full name (
address.firstName + " " + address.lastName) - Delivery address (street, city, state, country, zipcode)
- Customer phone number
- Item count
- Order total
<select> dropdown lets the admin transition an order to any of the three lifecycle states. Changing the dropdown fires:
POST /api/order/status on the backend, which runs findByIdAndUpdate to persist the new status, then the admin page refreshes its order list.
Verify Page (Payment Callback)
After Stripe redirects the customer back to the app, the/verify route handles the result. The page reads success and orderId from the URL query string and immediately calls POST /api/order/verify:
- Payment confirmed (
success=true) → the order’spaymentfield is set totrueand the user is sent to/myorders - Payment cancelled (
success=false) → the order document is deleted from MongoDB and the user is redirected to the home page