Skip to main content
Every order placed through the app moves through a defined lifecycle — from initial processing to final delivery. Customers can monitor this journey from their My Orders page, while restaurant admins drive each status transition from the admin dashboard. The Verify page bridges the gap between Stripe’s payment redirect and the order being confirmed in the database.

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.
Each order row displays: A Track Order button re-calls fetchOrders to pull the latest status on demand.
The My Orders page re-fetches automatically whenever the user navigates to it (the useEffect runs on token change). For live polling, users can also click the Track Order button to refresh the status immediately.

Order Data Model

Order documents in MongoDB follow this Mongoose schema (from backend/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
A status <select> dropdown lets the admin transition an order to any of the three lifecycle states. Changing the dropdown fires:
This calls 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’s payment field is set to true and 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