Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
najamuslim committed May 19, 2024
1 parent 1c4fa3b commit 0b0c1a1
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/handler/nurse_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ func (h *NurseHandler) UpdateNurse(c *gin.Context) {
c.JSON(404, gin.H{"status": "bad request", "message": "user not found"})
return
}
exists, _ := h.iNurseUsecase.GetNurseByNIP(request.Nip)
if exists {
log.Println("Update bad request ", err)
c.JSON(409, gin.H{"status": "bad request", "message": "nip already exists"})
return
}

// Validate request payload
err = ValidateRegisterNurseRequest(request.Nip, request.Name)
Expand All @@ -185,15 +191,6 @@ func (h *NurseHandler) UpdateNurse(c *gin.Context) {
c.JSON(400, gin.H{"status": "bad request", "message": err.Error()})
return
}

if (user.Nip != request.Nip) {
exists, _ := h.iNurseUsecase.GetNurseByNIP(request.Nip)
if exists {
log.Println("Update bad request ", err)
c.JSON(409, gin.H{"status": "bad request", "message": "nip already exists"})
return
}
}

statusCode := h.iNurseUsecase.UpdateNurse(userId, request)

Expand Down

0 comments on commit 0b0c1a1

Please sign in to comment.