f3a4d8ec66
- Emails should point to the correct server
60 lines
1.0 KiB
JavaScript
60 lines
1.0 KiB
JavaScript
class FoodObj {
|
|
|
|
constructor(limit) {
|
|
this.srcURL = 'https://menu.silvrtree.co.uk';
|
|
this.limit = limit;
|
|
this.store = [];
|
|
this.soup = {};
|
|
this.types = [0, 0, 0, 0, 0, 0, 0];
|
|
}
|
|
|
|
get () {
|
|
return this.store;
|
|
}
|
|
|
|
getFirstFive() {
|
|
return (this.store.slice(0, 5));
|
|
}
|
|
|
|
getFirstFiveIDs() {
|
|
const outVal = this.store.slice(0, 5).map((item) => {
|
|
return item._id;
|
|
});
|
|
|
|
return (outVal);
|
|
}
|
|
|
|
add(item) {
|
|
// console.log('>>', item);
|
|
item.url = `${this.srcURL}/view/${item.short}`;
|
|
if (this.types[item.meat] < this.limit) {
|
|
this.store.push(item);
|
|
this.types[item.meat]++;
|
|
}
|
|
}
|
|
|
|
addSoup(item) {
|
|
item.url = `${this.srcURL}/view/${item.short}`;
|
|
this.soup = item;
|
|
}
|
|
|
|
soupID() {
|
|
return this.soup._id || null;
|
|
}
|
|
|
|
count() {
|
|
return (this.store.slice(0, 5).length);
|
|
}
|
|
|
|
forPug() {
|
|
const output = { 'menu':null, 'soup':null };
|
|
|
|
output.menu = [...this.getFirstFive()];
|
|
output.soup = this.soup;
|
|
|
|
return output;
|
|
}
|
|
}
|
|
|
|
module.exports = FoodObj;
|