The website can be accessed at:
Git repo:
User Accounts
- User with no admin access: user:
oe@doe.com
password:pw
- User with admin access: user:
bobby.brown@hotmail.ca
password:bobby
listorder.js
is now controlled byAdminController.js
an only accessible by the following URL(need to be authorized to access this page) http://naturly.herokuapp.com/admin/ordersloaddata.js
is now controlled byAdminController.js
an only accessible by the following URL(need to be authorized to access this page) http://naturly.herokuapp.com/admin/connectionroutes.js
handles all the routing of the website whenever a link is clicked or a page is called.controllers/StoreController.js
maintains the store page: http://naturly.herokuapp.com/store , which accesses the database and grabs the products and their corresponding prices/images(implemented by the methodgetProducts
)controllers/ProductController.js
maintains the product page: http://naturly.herokuapp.com/product/{product id} , which accesses the database and grabs the product information(price, category, name, images, description), reviews for the product
- The search function is implemented by the method
getProduct
.controllers/CartController.js
controls the function of adding to the cart: http://naturly.herokuapp.com/cart, displaying items in the cart, and the checkout process.
- Maintains a record of what is in the cart for the session managed by
loadCart
.- Displays the items and total amount of the order throught the method
addProduct
.- When it's time to checkout,
cartCheckout
will prompt the user to login if they aren't and give an error if the cart is empty.- On a successful checkout, an order is placed and
orderproduct
is updated in the db.- Once the order is placed, the cart is emptied so a user may shop again.
controllers/UserController.js
handles the login and logout of a user: http://naturly.herokuapp.com/login.
isEmailValid
checks if the entered email is a valid email addressauthUser
authenticates the user's login credentials and will throw an error if the account doesn't exist in the database or if the password is incorrect.fethCart
stores cart information, so if a user logs out with items in the cart, they will be saved toordersummary
in the database for retrieval on the next login.- Helps in adding to the cart in session.
- Handles validation of customerId is a number and if customerId exists in the database.
- Loads information about the user to http://naturly.herokuapp.com/account
- Allows to modify information about the user http://naturly.herokuapp.com/account/settings
controllers/AdminController.js
can be accessed by going into admin/orders: http://naturly.herokuapp.com/admin, where we can see the sales, shipments, users, orders, and the products in the database.- http://naturly.herokuapp.com/admin/sales - show the total sales and total count of ordered products by day
- http://naturly.herokuapp.com/admin/shipments - show all orders that are waiting to be shipped/processed by the admin
- http://naturly.herokuapp.com/admin/shipments/{shipment id} - show the order to be processed and confirmation to be shipped
- To use the admin function you need to be authorized as an admin
- Email:
bobby.brown@hotmail.ca
- Password:
bobby
controllers/CartController.js
prompts the user to login if they aren't and orders can't be placed without logging into the website.- Page header updated to have links in the header to Home, Store, Account, and Administrator.
- Filter by category implemented with a quick drop down box for faster catergorial filtering.
- Cart page improved formatting with ProductId, Product Name, Quantity, and the Price of each item. The Order Total, Shipping Total(10%) and the Subtotal is visible large and clear for easy reading.
ProductController.js
implements the methoddisplayProduct
which is used to show the products when their name is clicked (For example:http://naturly.herokuapp.com/product/1)
- The id is used to to retrieve and display product information.
- the image is displayed using both the HTML tag based on
productImageUrl
while also from the binary fieldproductImage
.- add cart and back to store are both available, also with reviews.
AdminController.js
controls all admin features and checks authorization before allowing a user to view the Admin page http://naturly.herokuapp.com/admin
- To use the admin function you need to be authorized as an admin
- Email:
bobby.brown@hotmail.ca
- Password:
bobby
- The
validate
function will check if the entered email is valid and if the password is valid.- On the admin page we can check the database connection, sales, shipments, users, and the orders.
- Total sales:http://naturly.herokuapp.com/admin/sales, are listed by the order date, the total amount of that day, and the number of orders .
- The logged in user is visible from the main page on top of the my account button at anytime.
- The user account page: http://naturly.herokuapp.com/account will automatically redirect to the login page if a user isn't logged in.
- If user is logged in,
getUserSettings
inUserController.js
will display personal information when the user clicks onMy Account
: http://naturly.herokuapp.com/account
AdminController.js
also handles all the shipment throughloadShipment
and ship by verifying that there are enough products to ship the order, then if there are no conflicts, inserts the shipment into the database. The inventory is then updateded in theproductinventory
table. If there is insufficient inventory, a rollback is performed and quantity is updated inproductinventory
.