Merge pull request #18 from rede5/Front-back-integracao-task2

feat: atualização de papéis no registro e correção de integração de tipos de evento

Backend:
- Atualiza endpoint /auth/register para aceitar e exigir 'role' no corpo da requisição.
- Atualiza handler de registro para criar perfil profissional condicionalmente baseado na role.
- Regenera documentação Swagger para refletir novos parâmetros de registro.

Frontend:
- Atualiza apiService para usar o endpoint correto /api/tipos-eventos.
- Corrige EventForm para renderizar objetos de tipo de evento corretamente (usando estrutura id/nome).
- Corrige erro de sintaxe JSX no componente EventFiltersBar.
This commit is contained in:
Andre F. Rodrigues 2025-12-12 11:12:09 -03:00 committed by GitHub
commit 1b65d26bcd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 28 additions and 15 deletions

View file

@ -1700,7 +1700,7 @@ const docTemplate = `{
}, },
"/auth/register": { "/auth/register": {
"post": { "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": [ "consumes": [
"application/json" "application/json"
], ],
@ -1814,6 +1814,7 @@ const docTemplate = `{
"required": [ "required": [
"email", "email",
"nome", "nome",
"role",
"senha" "senha"
], ],
"properties": { "properties": {
@ -1823,6 +1824,10 @@ const docTemplate = `{
"nome": { "nome": {
"type": "string" "type": "string"
}, },
"role": {
"description": "Role is now required",
"type": "string"
},
"senha": { "senha": {
"type": "string", "type": "string",
"minLength": 6 "minLength": 6

View file

@ -1694,7 +1694,7 @@
}, },
"/auth/register": { "/auth/register": {
"post": { "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": [ "consumes": [
"application/json" "application/json"
], ],
@ -1808,6 +1808,7 @@
"required": [ "required": [
"email", "email",
"nome", "nome",
"role",
"senha" "senha"
], ],
"properties": { "properties": {
@ -1817,6 +1818,10 @@
"nome": { "nome": {
"type": "string" "type": "string"
}, },
"role": {
"description": "Role is now required",
"type": "string"
},
"senha": { "senha": {
"type": "string", "type": "string",
"minLength": 6 "minLength": 6

View file

@ -42,6 +42,9 @@ definitions:
type: string type: string
nome: nome:
type: string type: string
role:
description: Role is now required
type: string
senha: senha:
minLength: 6 minLength: 6
type: string type: string
@ -50,6 +53,7 @@ definitions:
required: required:
- email - email
- nome - nome
- role
- senha - senha
type: object type: object
auth.userResponse: auth.userResponse:
@ -1434,8 +1438,7 @@ paths:
post: post:
consumes: consumes:
- application/json - application/json
description: Register a new user (defaults to 'profissional' role) with email, description: Register a new user with email, password, name, phone and role
password, name and phone
parameters: parameters:
- description: Register Request - description: Register Request
in: body in: body

View file

@ -23,11 +23,12 @@ type registerRequest struct {
Senha string `json:"senha" binding:"required,min=6"` Senha string `json:"senha" binding:"required,min=6"`
Nome string `json:"nome" binding:"required"` Nome string `json:"nome" binding:"required"`
Telefone string `json:"telefone"` Telefone string `json:"telefone"`
Role string `json:"role" binding:"required"` // Role is now required
} }
// Register godoc // Register godoc
// @Summary Register a new user // @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 // @Tags auth
// @Accept json // @Accept json
// @Produce json // @Produce json
@ -43,17 +44,16 @@ func (h *Handler) Register(c *gin.Context) {
return return
} }
// Default simplified registration: Role="profissional" // Create professional data only if role is appropriate
role := "profissional" var profData *profissionais.CreateProfissionalInput
if req.Role == "profissional" || req.Role == "empresa" {
// Create professional data from input profData = &profissionais.CreateProfissionalInput{
profData := &profissionais.CreateProfissionalInput{
Nome: req.Nome, Nome: req.Nome,
Whatsapp: &req.Telefone, // Map Telefone to Whatsapp Whatsapp: &req.Telefone,
// FuncaoProfissionalID is left empty intentionally }
} }
_, 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 err != nil {
if strings.Contains(err.Error(), "duplicate key") { if strings.Contains(err.Error(), "duplicate key") {
c.JSON(http.StatusConflict, gin.H{"error": "email already registered"}) c.JSON(http.StatusConflict, gin.H{"error": "email already registered"})

View file

@ -82,7 +82,7 @@ export const EventFiltersBar: React.FC<EventFiltersBarProps> = ({
/> />
</div> </div>
{/* Filtro por Tipo */ {/* Filtro por Tipo */}
<div className="flex flex-col"> <div className="flex flex-col">
<label className="text-xs font-medium text-gray-600 mb-1 flex items-center gap-1"> <label className="text-xs font-medium text-gray-600 mb-1 flex items-center gap-1">
<Filter size={14} className="text-brand-gold" /> <Filter size={14} className="text-brand-gold" />