From 0e4222cf2c93cdb37c5b08f87a85b5e7396558d5 Mon Sep 17 00:00:00 2001 From: Killerrekt Date: Sat, 16 Mar 2024 00:14:38 +0530 Subject: [PATCH] feat: update team route have been made --- internal/controllers/team_controller.go | 13 ++++++++++--- internal/models/team_model.go | 3 +-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/internal/controllers/team_controller.go b/internal/controllers/team_controller.go index 8fd1a45..0d66844 100644 --- a/internal/controllers/team_controller.go +++ b/internal/controllers/team_controller.go @@ -112,7 +112,14 @@ 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{ @@ -120,9 +127,9 @@ func UpdateTeamName(ctx echo.Context) error { "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(), diff --git a/internal/models/team_model.go b/internal/models/team_model.go index 3d91d40..00c537e 100644 --- a/internal/models/team_model.go +++ b/internal/models/team_model.go @@ -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 {