/**
* Represent a category of products in the system.
*/
class Category {
/**
* Creates a new Category instance.
* @param {string} categoryId - Unique identifier for the category.
* @param {string} name - Name of the category.
* @param {string} imageUrl - URL for the category image.
* @param {string} type - Type of category (e.g., Food , Drink).
* @param {boolean} isRecommended - Indicates if the category is recommended.
* @param {string} description - description of the category.
* @param {boolean} availabilityStatus - New availabbility status.
* @param {string[]} popularItems - New List of popular items.
* @param {Category} parentCategory - New parent category, if applicable.
*/
constructor(categoryId, name, imageUrl, type, isRecommended = false, description = "", availabilityStatus = true, popularItems = [], parentCategory = null, rank = 0) {
this.categoryId = categoryId;
this.name = name;
this.imageUrl = imageUrl;
this.type = type;
this.isRecommended = isRecommended;
this.description = description;
this.availabilityStatus = availabilityStatus;
this.popularItems = popularItems;
this.parentCategory = parentCategory;
this.rank = rank;
this.createdAt = new Date();
this.updatedAt = new Date();
}
/**
* Sets the recommendation status for the category.
* @param {boolean} status = New recommendation status.
*/
setRecommendation(status) {
this.isRecommended = status;
this.updatedAt = new Date();
}
/**
* Updates the category details.
* @param {string} name - New name for the category.
* @param {string} imageUrl - New image URL for the category.
* @param {string} type - New type for the category.
* @param {string} description - New description for the category.
*/
updateDetails(name, imageUrl, type, description) {
this.name = name;
this.imageUrl = imageUrl;
this.type = type;
this.description = description;
this.rank = rank;
this.updatedAt = new Date();
}
}
export default Category;