/**
* Represents a reservation made by a customer.
*/
class Reservation {
/**
* Creates a new Reservation.
* @param {string} reservationId - Unique identifier for the reservation.
* @param {string} customerName - Name of the customer.
* @param {string} customerContact - Customer's contact details.
* @param {string|Date} reservationDateTime - Date and time of the reservation.
* @param {number} numberOfGuests - Total number of guests.
* @param {string|null} [tableId=null] - Assigned table ID (optional at creation).
* @param {string} [status="Pending"] - Status of the reservation (Pending, Confirmed, Completed, Cancelled).
* @param {string} [specialRequests=""] - Any special customer requests.
* @param {Date} [createdAt=new Date()] - Timestamp when the reservation was created.
* @param {Date} [updatedAt=new Date()] - Timestamp when the reservation was last updated.
*/
constructor(reservationId, customerName, customerContact, reservationDateTime, numberOfGuests, tableId = null, status = "Pending", specialRequests = "", createdAt = new Date(), updatedAt = new Date()) {
this.reservationId = reservationId; // Unique identifier for the reservation
this.customerName = customerName; // Name of the customer
this.customerContact = customerContact; // Customer's contact details
this.reservationDateTime = new Date(reservationDateTime); // Date and time of the reservation
this.numberOfGuests = numberOfGuests; // Total number of guests
this.tableId = tableId; // Assigned table ID (optional at creation)
this.status = status; // Status of the reservation (Pending, Confirmed, Completed, Cancelled)
this.specialRequests = specialRequests; // Any special customer requests
this.createdAt = createdAt; // Timestamp when the reservation was created
this.updatedAt = updatedAt; // Timestamp when the reservation was last updated
}
/**
* Updates the reservation details.
* @param {string} customerName - Updated name of the customer.
* @param {string} customerContact - Updated contact details.
* @param {string|Date} reservationDateTime - Updated date and time of the reservation.
* @param {number} numberOfGuests - Updated total number of guests.
* @param {string} tableId - Updated table ID.
* @param {string} status Updated status of the reservation.
* @param {string} specialRequests - Updated special requests.
*/
updateDetails(customerName, customerContact, reservationDateTime, numberOfGuests, tableId, status, specialRequests) {
this.customerName = customerName;
this.customerContact = customerContact;
this.reservationDateTime = new Date(reservationDateTime);
this.numberOfGuests = numberOfGuests;
this.tableId = tableId;
this.status = status;
this.specialRequests = specialRequests;
this.updatedAt = new Date();
}
/**
* Assigns a table to the reservation and updates the status to "Confirmed".
* @param {string} tableId - The ID of the table to assign.
*/
assignTable(tableId) {
this.tableId = tableId;
this.status = "Confirmed";
this.updatedAt = new Date();
}
/**
* Changes the status of the reservation.
* @param {string} newStatus - The new status (Pending, Confirmed, Completed, Cancelled).
*/
changeStatus(newStatus) {
this.status = newStatus;
this.updatedAt = new Date();
}
/**
* Checks if the reservation is for a future date and time.
* @returns {boolean} True if the reservation is upcoming, otherwise false.
*/
isUpcoming() {
return this.reservationDateTime > new Date();
}
}
module.exports = Reservation;