diff --git a/README.md b/README.md
index 04ed462..55f5215 100644
--- a/README.md
+++ b/README.md
@@ -48,9 +48,15 @@
- ##### **subscriptionStarted**: _String_
- ##### **subscriptionDue**: _String_
- ##### **categories**: [String]
- - ##### **lunchMenu**: [*mongoose.Types.ObjectId*]
- - ##### **dishes**: [*mongoose.Types.ObjectId*]
-
+
+- ##### **lunchHours**: String
+- ##### **lunchMenu**:
+ - ##### **lunchSetName**: _String_
+ - ##### **lunchSetPrice**: _String_
+ - ##### **lunchSetDishes**: [mongoose.Types.ObjectId]
+- ##### **dishes**: [*mongoose.Types.ObjectId*]
+
+
- ### **Dish**
@@ -58,11 +64,11 @@
- ##### **restaurantId**: _mongoose.Types.ObjectId_
- ##### **name**: _String_ (max: 128, required)
- ##### **category**: _String_ (max: 64, required)
- - ##### **price**: _Number_ (required)
+ - ##### **price**: String (required)
- ##### **notes**: _String_ (max: 128)
- ##### **imgUrl**: _String_ (required)
- ##### **hidden**: _Boolean_
- - ##### **weight**: _Number_
+ - ##### **weight**: String
- ##### **allergens**
- ##### **gluten**: _Boolean_
- ##### **lactose**: _Boolean_
@@ -71,7 +77,7 @@
- ##### **seaFood**: _Boolean_
- ##### **peanuts**: _Boolean_
- ##### **sesame**: _Boolean_
- - ##### **ingredients**: [*String*]
+ - ##### **ingredients**: String
- ##### **glicemicIndex**: String
- ##### **kCal**: String
- ##### **vegan**: _Boolean_
diff --git a/models/dish.js b/models/dish.js
index b43ace8..f551930 100644
--- a/models/dish.js
+++ b/models/dish.js
@@ -14,19 +14,19 @@ const dishSchema = mongoose.Schema({
required: true,
},
price: {
- type: Number,
+ type: String,
required: true,
},
notes: {
type: String,
- maxlength: 128,
+ maxlength: 200,
},
imgUrl: {
type: String,
required: true,
},
hidden: Boolean,
- weight: Number,
+ weight: String,
allergens: {
gluten: Boolean,
lactose: Boolean,
@@ -36,9 +36,7 @@ const dishSchema = mongoose.Schema({
peanuts: Boolean,
sesame: Boolean,
},
- ingredients: {
- type: [String],
- },
+ ingredients: String,
glicemicIndex: String,
kCal: String,
vegan: Boolean,
diff --git a/models/restaurant.js b/models/restaurant.js
index 96eb84b..6e580b3 100644
--- a/models/restaurant.js
+++ b/models/restaurant.js
@@ -64,7 +64,14 @@ const restaurantSchema = mongoose.Schema({
subscriptionStarted: Date,
subscriptionDue: Date,
categories: [String],
- lunchMenu: [mongoose.Types.ObjectId],
+ lunchHours: String,
+ lunchMenu: [
+ {
+ lunchSetName: String,
+ lunchSetPrice: String,
+ lunchSetDishes: [mongoose.Types.ObjectId],
+ },
+ ],
dishes: [mongoose.Types.ObjectId],
});
diff --git a/routes/routeDish.js b/routes/routeDish.js
index 0491c91..f0e9f63 100644
--- a/routes/routeDish.js
+++ b/routes/routeDish.js
@@ -33,7 +33,7 @@ router.post("/", async (req, res) => {
await validateRestaurant(req.body.restaurantId);
const token = req.headers["x-auth-token"];
validateUserToken(token);
- const dish = createDish(req.body.dish, req.body.restaurantId, true);
+ const dish = await createDish(req.body, req.body.restaurantId, true);
await dish.save();
await addDishToRestaurant(req.body.restaurantId, dish._id);
res.status(201).send(dish._id);
diff --git a/services/dataPrepServices.js b/services/dataPrepServices.js
index 5a86f32..9f7e403 100644
--- a/services/dataPrepServices.js
+++ b/services/dataPrepServices.js
@@ -116,7 +116,7 @@ export async function prepareSafeUser(user) {
export async function createDish(dish, restaurantId, generateId) {
try {
if (generateId) {
- const img = await saveImage(dish.imgUrl);
+ const img = await handleImageUpdate(dish);
const newDish = new Dish({
_id: new mongoose.Types.ObjectId(),
restaurantId: restaurantId,
@@ -143,13 +143,14 @@ export async function createDish(dish, restaurantId, generateId) {
});
return newDish;
} else {
+ const img = "";
const newDish = new Dish({
restaurantId: restaurantId,
name: sanitizer.sanitize.keepUnicode(dish.name),
category: dish.category,
price: dish.price,
notes: sanitizer.sanitize.keepUnicode(dish.notes),
- imgUrl: dish.imgUrl,
+ imgUrl: img,
weight: dish.weight,
allergens: {
gluten: dish.allergens.gluten,
@@ -169,6 +170,7 @@ export async function createDish(dish, restaurantId, generateId) {
return newDish;
}
} catch (e) {
+ console.log(e);
throw newError("Cannot create dish", 500);
}
}