From 4aedbcbc9148354481335223a4db084bd0a3b985 Mon Sep 17 00:00:00 2001 From: NANDO9322 Date: Fri, 12 Dec 2025 11:08:52 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20atualiza=C3=A7=C3=A3o=20de=20pap=C3=A9i?= =?UTF-8?q?s=20no=20registro=20e=20corre=C3=A7=C3=A3o=20de=20integra=C3=A7?= =?UTF-8?q?=C3=A3o=20de=20tipos=20de=20evento=20Backend:=20-=20Atualiza=20?= =?UTF-8?q?endpoint=20/auth/register=20para=20aceitar=20e=20exigir=20'role?= =?UTF-8?q?'=20no=20corpo=20da=20requisi=C3=A7=C3=A3o.=20-=20Atualiza=20ha?= =?UTF-8?q?ndler=20de=20registro=20para=20criar=20perfil=20profissional=20?= =?UTF-8?q?condicionalmente=20baseado=20na=20role.=20-=20Regenera=20docume?= =?UTF-8?q?nta=C3=A7=C3=A3o=20Swagger=20para=20refletir=20novos=20par?= =?UTF-8?q?=C3=A2metros=20de=20registro.=20Frontend:=20-=20Atualiza=20apiS?= =?UTF-8?q?ervice=20para=20usar=20o=20endpoint=20correto=20/api/tipos-even?= =?UTF-8?q?tos.=20-=20Corrige=20EventForm=20para=20renderizar=20objetos=20?= =?UTF-8?q?de=20tipo=20de=20evento=20corretamente=20(usando=20estrutura=20?= =?UTF-8?q?id/nome).=20-=20Corrige=20erro=20de=20sintaxe=20JSX=20no=20comp?= =?UTF-8?q?onente=20EventFiltersBar.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/docs/docs.go | 7 ++++++- backend/docs/swagger.json | 7 ++++++- backend/docs/swagger.yaml | 7 +++++-- backend/internal/auth/handler.go | 20 ++++++++++---------- frontend/components/EventFiltersBar.tsx | 2 +- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/backend/docs/docs.go b/backend/docs/docs.go index 5633619..d5e9cd7 100644 --- a/backend/docs/docs.go +++ b/backend/docs/docs.go @@ -1700,7 +1700,7 @@ const docTemplate = `{ }, "/auth/register": { "post": { - "description": "Register a new user (defaults to 'profissional' role) with email, password, name and phone", + "description": "Register a new user with email, password, name, phone and role", "consumes": [ "application/json" ], @@ -1814,6 +1814,7 @@ const docTemplate = `{ "required": [ "email", "nome", + "role", "senha" ], "properties": { @@ -1823,6 +1824,10 @@ const docTemplate = `{ "nome": { "type": "string" }, + "role": { + "description": "Role is now required", + "type": "string" + }, "senha": { "type": "string", "minLength": 6 diff --git a/backend/docs/swagger.json b/backend/docs/swagger.json index 49bd2ba..5b7f506 100644 --- a/backend/docs/swagger.json +++ b/backend/docs/swagger.json @@ -1694,7 +1694,7 @@ }, "/auth/register": { "post": { - "description": "Register a new user (defaults to 'profissional' role) with email, password, name and phone", + "description": "Register a new user with email, password, name, phone and role", "consumes": [ "application/json" ], @@ -1808,6 +1808,7 @@ "required": [ "email", "nome", + "role", "senha" ], "properties": { @@ -1817,6 +1818,10 @@ "nome": { "type": "string" }, + "role": { + "description": "Role is now required", + "type": "string" + }, "senha": { "type": "string", "minLength": 6 diff --git a/backend/docs/swagger.yaml b/backend/docs/swagger.yaml index 5fdafb0..4c4135e 100644 --- a/backend/docs/swagger.yaml +++ b/backend/docs/swagger.yaml @@ -42,6 +42,9 @@ definitions: type: string nome: type: string + role: + description: Role is now required + type: string senha: minLength: 6 type: string @@ -50,6 +53,7 @@ definitions: required: - email - nome + - role - senha type: object auth.userResponse: @@ -1434,8 +1438,7 @@ paths: post: consumes: - application/json - description: Register a new user (defaults to 'profissional' role) with email, - password, name and phone + description: Register a new user with email, password, name, phone and role parameters: - description: Register Request in: body diff --git a/backend/internal/auth/handler.go b/backend/internal/auth/handler.go index 74d204a..ec0010d 100644 --- a/backend/internal/auth/handler.go +++ b/backend/internal/auth/handler.go @@ -23,11 +23,12 @@ type registerRequest struct { Senha string `json:"senha" binding:"required,min=6"` Nome string `json:"nome" binding:"required"` Telefone string `json:"telefone"` + Role string `json:"role" binding:"required"` // Role is now required } // Register godoc // @Summary Register a new user -// @Description Register a new user (defaults to 'profissional' role) with email, password, name and phone +// @Description Register a new user with email, password, name, phone and role // @Tags auth // @Accept json // @Produce json @@ -43,17 +44,16 @@ func (h *Handler) Register(c *gin.Context) { return } - // Default simplified registration: Role="profissional" - role := "profissional" - - // Create professional data from input - profData := &profissionais.CreateProfissionalInput{ - Nome: req.Nome, - Whatsapp: &req.Telefone, // Map Telefone to Whatsapp - // FuncaoProfissionalID is left empty intentionally + // Create professional data only if role is appropriate + var profData *profissionais.CreateProfissionalInput + if req.Role == "profissional" || req.Role == "empresa" { + profData = &profissionais.CreateProfissionalInput{ + Nome: req.Nome, + Whatsapp: &req.Telefone, + } } - _, err := h.service.Register(c.Request.Context(), req.Email, req.Senha, role, profData) + _, err := h.service.Register(c.Request.Context(), req.Email, req.Senha, req.Role, profData) if err != nil { if strings.Contains(err.Error(), "duplicate key") { c.JSON(http.StatusConflict, gin.H{"error": "email already registered"}) diff --git a/frontend/components/EventFiltersBar.tsx b/frontend/components/EventFiltersBar.tsx index 052b7cc..9f0ec1e 100644 --- a/frontend/components/EventFiltersBar.tsx +++ b/frontend/components/EventFiltersBar.tsx @@ -82,7 +82,7 @@ export const EventFiltersBar: React.FC = ({ /> - {/* Filtro por Tipo */ + {/* Filtro por Tipo */}