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:
commit
1b65d26bcd
5 changed files with 28 additions and 15 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"})
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ export const EventFiltersBar: React.FC<EventFiltersBarProps> = ({
|
|||
/>
|
||||
</div>
|
||||
|
||||
{/* Filtro por Tipo */
|
||||
{/* Filtro por Tipo */}
|
||||
<div className="flex flex-col">
|
||||
<label className="text-xs font-medium text-gray-600 mb-1 flex items-center gap-1">
|
||||
<Filter size={14} className="text-brand-gold" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue