diff --git a/classes/Auth.js b/classes/Auth.js index e69de29..aecfabc 100644 --- a/classes/Auth.js +++ b/classes/Auth.js @@ -0,0 +1,19 @@ +const Customer = require('./Customer'); + +class Auth { + constructor() { + this.customers = []; + } + + register(name, email, shippingAddress) { + const newCustomer = new Customer(name, email, shippingAddress); + this.customers.push(newCustomer); + return newCustomer; + } + + login(email) { + return this.customers.find(cust => cust.email === email) || null; + } +} + +module.exports = Auth; diff --git a/classes/Customer.js b/classes/Customer.js index e69de29..33166ec 100644 --- a/classes/Customer.js +++ b/classes/Customer.js @@ -0,0 +1,15 @@ +class Customer { + constructor(name, email, shippingAddress) { + this.name = name; + this.email = email; + this.shippingAddress = shippingAddress; + this.orderHistory = []; + } + + addToOrderHistory(cart) { + this.orderHistory.push(cart); + } + } + + module.exports = Customer; + \ No newline at end of file diff --git a/index.js b/index.js index efad601..9e6b55f 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,14 @@ // Import Classes Here +// Import Classes Here +const Product = require('./classes/Product'); +const Cart = require('./classes/Cart'); +const Customer = require('./classes/Customer'); +const Auth = require('./classes/Auth'); + + +// Example usage for manual testing