Skip to content

Commit

Permalink
changed it back to multiple food items
Browse files Browse the repository at this point in the history
  • Loading branch information
anirvinv committed Apr 16, 2024
1 parent 5435e8c commit cd859c0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
5 changes: 2 additions & 3 deletions backend/public/routes/order_route.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@ router.get("/:id", [auth_1.default, roles_1.default.volunteer], (req, res) => {
});
});
router.post("/", [auth_1.default, roles_1.default.admin], (req, res) => {
const { client, deliverBy, foodItem, } = req.body;
const { client, brand, weight, } = req.body;
const order = new order_schema_1.default({
client: new mongoose_1.default.Types.ObjectId(client),
createdOn: new Date(),
deliverBy,
foodItem,
foodItems: [{ brand, weight }],
stauts: "pending"
});
order.save()
Expand Down
2 changes: 1 addition & 1 deletion backend/public/schemas/order_schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const orderSchema = new mongoose_1.default.Schema({
client: { type: Types.ObjectId, ref: "Client", required: true },
createdOn: { type: Date },
deliverBy: { type: Date },
foodItem: foodItemSchema,
foodItems: [foodItemSchema],
status: { type: String, enum: ["pending", "successful", "failed"], default: "pending" },
});
const orderModel = mongoose_1.default.model("order", orderSchema);
Expand Down
7 changes: 3 additions & 4 deletions backend/routes/order_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,14 @@ router.get("/:id", [auth, roles.volunteer], (req: Request, res: Response) => {
router.post("/", [auth, roles.admin], (req: Request, res: Response) => {
const {
client,
deliverBy,
foodItem,
brand,
weight,
} = req.body;
const order = new Order(
{
client: new mongoose.Types.ObjectId(client),
createdOn: new Date(),
deliverBy,
foodItem,
foodItems: [{ brand, weight }],
stauts: "pending"
});
order.save()
Expand Down
2 changes: 1 addition & 1 deletion backend/schemas/order_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const orderSchema = new mongoose.Schema(
client: { type: Types.ObjectId, ref: "Client", required: true },
createdOn: { type: Date },
deliverBy: { type: Date },
foodItem: foodItemSchema,
foodItems: [foodItemSchema],
status: { type: String, enum: ["pending", "successful", "failed"], default: "pending" },
});

Expand Down

0 comments on commit cd859c0

Please sign in to comment.