Skip to content

Commit 6cbcc24

Browse files
committed
add default food batch
1 parent be04535 commit 6cbcc24

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

  • services/hexathons/src/routes

services/hexathons/src/routes/team.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { FilterQuery, isValidObjectId, Types } from "mongoose";
55
import { Team, TeamModel } from "../models/team";
66
import { HexathonUser, HexathonUserModel } from "../models/hexathonUser";
77
import { validateEmail } from "../common/util";
8+
import { FoodBatchModel } from "src/models/foodBatch";
89

910
export const teamRoutes = express.Router();
1011

@@ -100,7 +101,7 @@ teamRoutes.route("/:id").get(
100101
teamRoutes.route("/").post(
101102
checkAbility("create", "Team"),
102103
asyncHandler(async (req, res) => {
103-
const { name, hexathon, email, description, publicTeam, batch } = req.body;
104+
const { name, hexathon, email, description, publicTeam } = req.body;
104105

105106
const hexathonUser = await HexathonUserModel.findOne({
106107
hexathon: { $eq: hexathon },
@@ -122,13 +123,15 @@ teamRoutes.route("/").post(
122123
throw new BadRequestError("User is already in a team for this event!");
123124
}
124125

126+
const foodBatch = await FoodBatchModel.findOne({}); // TODO: change this one food-batches are actually implemented.
127+
125128
const newTeam = await TeamModel.create({
126129
name,
127130
hexathon,
128131
members: [hexathonUser.id],
129132
description,
130133
public: publicTeam,
131-
batch,
134+
batch: foodBatch ? foodBatch.id : undefined,
132135
});
133136

134137
await HexathonUserModel.findByIdAndUpdate(hexathonUser.id, {

0 commit comments

Comments
 (0)