@@ -5,6 +5,7 @@ import { FilterQuery, isValidObjectId, Types } from "mongoose";
55import { Team , TeamModel } from "../models/team" ;
66import { HexathonUser , HexathonUserModel } from "../models/hexathonUser" ;
77import { validateEmail } from "../common/util" ;
8+ import { FoodBatchModel } from "src/models/foodBatch" ;
89
910export const teamRoutes = express . Router ( ) ;
1011
@@ -100,7 +101,7 @@ teamRoutes.route("/:id").get(
100101teamRoutes . 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