Skip to content

Commit

Permalink
feat: update team route have been made
Browse files Browse the repository at this point in the history
  • Loading branch information
Killerrekt committed Mar 15, 2024
1 parent 7e9f4a8 commit 0e4222c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
13 changes: 10 additions & 3 deletions internal/controllers/team_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,24 @@ func UpdateTeamName(ctx echo.Context) error {
})
}

team, err := services.FindTeamByTeamID(payload.ID)
if user.TeamID == uuid.Nil {
return ctx.JSON(http.StatusNotFound, map[string]string{
"message": "user not in a team",
"status": "fail",
})
}

/*team, err := services.FindTeamByTeamID(payload.ID)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
return ctx.JSON(http.StatusNotFound, map[string]string{
"message": "user not found",
"status": "fail",
})
}
}
}*/

err = services.UpdateTeamName(payload.Name, team.ID)
err := services.UpdateTeamName(payload.Name, user.TeamID)
if err != nil {
return ctx.JSON(http.StatusInternalServerError, map[string]string{
"message": err.Error(),
Expand Down
3 changes: 1 addition & 2 deletions internal/models/team_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ type Team struct {
}

type CreateTeamRequest struct {
ID uuid.UUID `json:"id" validate:"required,uuid"`
Name string `json:"name" validate:"required,min=1,max=50"`
Name string `json:"name" validate:"required,min=1,max=50"`
}

type JoinTeamRequest struct {
Expand Down

0 comments on commit 0e4222c

Please sign in to comment.