diff --git a/backend/internal/agenda/service.go b/backend/internal/agenda/service.go index 6ef38d9..65a1546 100644 --- a/backend/internal/agenda/service.go +++ b/backend/internal/agenda/service.go @@ -673,9 +673,9 @@ func (s *Service) GetProfessionalFinancialStatement(ctx context.Context, userID nomeEvento := "" if t.FotNumero.Valid { if t.CursoNome.Valid { - nomeEvento = fmt.Sprintf("Formatura %s (FOT %d)", t.CursoNome.String, t.FotNumero.Int32) + nomeEvento = fmt.Sprintf("Formatura %s (FOT %s)", t.CursoNome.String, t.FotNumero.String) } else { - nomeEvento = fmt.Sprintf("Formatura FOT %d", t.FotNumero.Int32) + nomeEvento = fmt.Sprintf("Formatura FOT %s", t.FotNumero.String) } } else { nomeEvento = t.TipoEvento.String diff --git a/backend/internal/cadastro_fot/handler.go b/backend/internal/cadastro_fot/handler.go index 1242be3..ec0c71f 100644 --- a/backend/internal/cadastro_fot/handler.go +++ b/backend/internal/cadastro_fot/handler.go @@ -20,7 +20,7 @@ func NewHandler(service *Service) *Handler { type CadastroFotResponse struct { ID string `json:"id"` - Fot int32 `json:"fot"` + Fot string `json:"fot"` EmpresaID string `json:"empresa_id"` EmpresaNome string `json:"empresa_nome,omitempty"` CursoID string `json:"curso_id"` diff --git a/backend/internal/cadastro_fot/service.go b/backend/internal/cadastro_fot/service.go index 4a8f4a0..e0ebfba 100644 --- a/backend/internal/cadastro_fot/service.go +++ b/backend/internal/cadastro_fot/service.go @@ -20,7 +20,7 @@ func NewService(queries *generated.Queries) *Service { } type CreateInput struct { - Fot int32 `json:"fot"` + Fot string `json:"fot"` EmpresaID string `json:"empresa_id"` CursoID string `json:"curso_id"` AnoFormaturaID string `json:"ano_formatura_id"` diff --git a/backend/internal/db/generated/agenda.sql.go b/backend/internal/db/generated/agenda.sql.go index 3f3acbc..3057b50 100644 --- a/backend/internal/db/generated/agenda.sql.go +++ b/backend/internal/db/generated/agenda.sql.go @@ -396,7 +396,7 @@ type ListAgendasRow struct { CriadoEm pgtype.Timestamptz `json:"criado_em"` AtualizadoEm pgtype.Timestamptz `json:"atualizado_em"` Status pgtype.Text `json:"status"` - FotNumero int32 `json:"fot_numero"` + FotNumero string `json:"fot_numero"` Instituicao pgtype.Text `json:"instituicao"` CursoNome string `json:"curso_nome"` EmpresaNome string `json:"empresa_nome"` @@ -618,7 +618,7 @@ type ListAgendasByUserRow struct { CriadoEm pgtype.Timestamptz `json:"criado_em"` AtualizadoEm pgtype.Timestamptz `json:"atualizado_em"` Status pgtype.Text `json:"status"` - FotNumero int32 `json:"fot_numero"` + FotNumero string `json:"fot_numero"` Instituicao pgtype.Text `json:"instituicao"` CursoNome string `json:"curso_nome"` EmpresaNome string `json:"empresa_nome"` diff --git a/backend/internal/db/generated/cadastro_fot.sql.go b/backend/internal/db/generated/cadastro_fot.sql.go index 5ff98a4..093dc99 100644 --- a/backend/internal/db/generated/cadastro_fot.sql.go +++ b/backend/internal/db/generated/cadastro_fot.sql.go @@ -20,7 +20,7 @@ INSERT INTO cadastro_fot ( ` type CreateCadastroFotParams struct { - Fot int32 `json:"fot"` + Fot string `json:"fot"` EmpresaID pgtype.UUID `json:"empresa_id"` CursoID pgtype.UUID `json:"curso_id"` AnoFormaturaID pgtype.UUID `json:"ano_formatura_id"` @@ -77,7 +77,7 @@ const getCadastroFotByFOT = `-- name: GetCadastroFotByFOT :one SELECT id, fot, empresa_id, curso_id, ano_formatura_id, instituicao, cidade, estado, observacoes, gastos_captacao, pre_venda, created_at, updated_at FROM cadastro_fot WHERE fot = $1 ` -func (q *Queries) GetCadastroFotByFOT(ctx context.Context, fot int32) (CadastroFot, error) { +func (q *Queries) GetCadastroFotByFOT(ctx context.Context, fot string) (CadastroFot, error) { row := q.db.QueryRow(ctx, getCadastroFotByFOT, fot) var i CadastroFot err := row.Scan( @@ -113,7 +113,7 @@ WHERE c.fot = $1 type GetCadastroFotByFotJoinRow struct { ID pgtype.UUID `json:"id"` - Fot int32 `json:"fot"` + Fot string `json:"fot"` EmpresaID pgtype.UUID `json:"empresa_id"` CursoID pgtype.UUID `json:"curso_id"` AnoFormaturaID pgtype.UUID `json:"ano_formatura_id"` @@ -130,7 +130,7 @@ type GetCadastroFotByFotJoinRow struct { AnoFormaturaLabel string `json:"ano_formatura_label"` } -func (q *Queries) GetCadastroFotByFotJoin(ctx context.Context, fot int32) (GetCadastroFotByFotJoinRow, error) { +func (q *Queries) GetCadastroFotByFotJoin(ctx context.Context, fot string) (GetCadastroFotByFotJoinRow, error) { row := q.db.QueryRow(ctx, getCadastroFotByFotJoin, fot) var i GetCadastroFotByFotJoinRow err := row.Scan( @@ -169,7 +169,7 @@ WHERE c.id = $1 type GetCadastroFotByIDRow struct { ID pgtype.UUID `json:"id"` - Fot int32 `json:"fot"` + Fot string `json:"fot"` EmpresaID pgtype.UUID `json:"empresa_id"` CursoID pgtype.UUID `json:"curso_id"` AnoFormaturaID pgtype.UUID `json:"ano_formatura_id"` @@ -225,7 +225,7 @@ ORDER BY c.fot DESC type ListCadastroFotRow struct { ID pgtype.UUID `json:"id"` - Fot int32 `json:"fot"` + Fot string `json:"fot"` EmpresaID pgtype.UUID `json:"empresa_id"` CursoID pgtype.UUID `json:"curso_id"` AnoFormaturaID pgtype.UUID `json:"ano_formatura_id"` @@ -295,7 +295,7 @@ ORDER BY c.fot DESC type ListCadastroFotByEmpresaRow struct { ID pgtype.UUID `json:"id"` - Fot int32 `json:"fot"` + Fot string `json:"fot"` EmpresaID pgtype.UUID `json:"empresa_id"` CursoID pgtype.UUID `json:"curso_id"` AnoFormaturaID pgtype.UUID `json:"ano_formatura_id"` @@ -366,7 +366,7 @@ LIMIT 10 type SearchFotRow struct { ID pgtype.UUID `json:"id"` - Fot int32 `json:"fot"` + Fot string `json:"fot"` EmpresaID pgtype.UUID `json:"empresa_id"` CursoID pgtype.UUID `json:"curso_id"` AnoFormaturaID pgtype.UUID `json:"ano_formatura_id"` @@ -439,7 +439,7 @@ RETURNING id, fot, empresa_id, curso_id, ano_formatura_id, instituicao, cidade, type UpdateCadastroFotParams struct { ID pgtype.UUID `json:"id"` - Fot int32 `json:"fot"` + Fot string `json:"fot"` EmpresaID pgtype.UUID `json:"empresa_id"` CursoID pgtype.UUID `json:"curso_id"` AnoFormaturaID pgtype.UUID `json:"ano_formatura_id"` diff --git a/backend/internal/db/generated/financial_transactions.sql.go b/backend/internal/db/generated/financial_transactions.sql.go index b66f651..255c365 100644 --- a/backend/internal/db/generated/financial_transactions.sql.go +++ b/backend/internal/db/generated/financial_transactions.sql.go @@ -144,7 +144,7 @@ type ListTransactionsRow struct { CriadoEm pgtype.Timestamptz `json:"criado_em"` AtualizadoEm pgtype.Timestamptz `json:"atualizado_em"` ProfissionalID pgtype.UUID `json:"profissional_id"` - FotNumero pgtype.Int4 `json:"fot_numero"` + FotNumero pgtype.Text `json:"fot_numero"` } func (q *Queries) ListTransactions(ctx context.Context) ([]ListTransactionsRow, error) { @@ -271,7 +271,7 @@ type ListTransactionsByProfessionalRow struct { CriadoEm pgtype.Timestamptz `json:"criado_em"` AtualizadoEm pgtype.Timestamptz `json:"atualizado_em"` ProfissionalID pgtype.UUID `json:"profissional_id"` - FotNumero pgtype.Int4 `json:"fot_numero"` + FotNumero pgtype.Text `json:"fot_numero"` EmpresaNome pgtype.Text `json:"empresa_nome"` CursoNome pgtype.Text `json:"curso_nome"` } diff --git a/backend/internal/db/generated/models.go b/backend/internal/db/generated/models.go index 9bf106b..e1f2f10 100644 --- a/backend/internal/db/generated/models.go +++ b/backend/internal/db/generated/models.go @@ -79,7 +79,7 @@ type CadastroCliente struct { type CadastroFot struct { ID pgtype.UUID `json:"id"` - Fot int32 `json:"fot"` + Fot string `json:"fot"` EmpresaID pgtype.UUID `json:"empresa_id"` CursoID pgtype.UUID `json:"curso_id"` AnoFormaturaID pgtype.UUID `json:"ano_formatura_id"` diff --git a/backend/internal/db/migrations/006_sync_production.sql b/backend/internal/db/migrations/006_sync_production.sql new file mode 100644 index 0000000..5694cf2 --- /dev/null +++ b/backend/internal/db/migrations/006_sync_production.sql @@ -0,0 +1,207 @@ +-- Migration de Sincronização Completa (DEV -> PROD/HML) +-- Este script verifica e cria colunas/tabelas que podem estar faltando após o merge de DEV. +-- Seguro para rodar múltiplas vezes (usa IF NOT EXISTS). + +-- ============================================================================== +-- 1. UTILS +-- ============================================================================== +CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; + +-- ============================================================================== +-- 2. CADASTRO DE PROFISSIONAIS (Atualizações de Colunas) +-- ============================================================================== +ALTER TABLE cadastro_profissionais ADD COLUMN IF NOT EXISTS email VARCHAR(255); +ALTER TABLE cadastro_profissionais ADD COLUMN IF NOT EXISTS avatar_url VARCHAR(255); +ALTER TABLE cadastro_profissionais ADD COLUMN IF NOT EXISTS tabela_free VARCHAR(50); +ALTER TABLE cadastro_profissionais ADD COLUMN IF NOT EXISTS media NUMERIC(3,2); +ALTER TABLE cadastro_profissionais ADD COLUMN IF NOT EXISTS equipamentos TEXT; +ALTER TABLE cadastro_profissionais ADD COLUMN IF NOT EXISTS extra_por_equipamento BOOLEAN DEFAULT FALSE; +ALTER TABLE cadastro_profissionais ADD COLUMN IF NOT EXISTS qtd_estudio INT; +ALTER TABLE cadastro_profissionais ADD COLUMN IF NOT EXISTS disp_horario INT; +ALTER TABLE cadastro_profissionais ADD COLUMN IF NOT EXISTS desempenho_evento INT; +ALTER TABLE cadastro_profissionais ADD COLUMN IF NOT EXISTS educacao_simpatia INT; +ALTER TABLE cadastro_profissionais ADD COLUMN IF NOT EXISTS qual_tec INT; + +-- ============================================================================== +-- 3. TABELAS DE DOMÍNIO E CONFIGURAÇÃO +-- ============================================================================== + +-- Tabela de Preços (Se não existir) +CREATE TABLE IF NOT EXISTS precos_tipos_eventos ( + id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), + tipo_evento_id UUID REFERENCES tipos_eventos(id) ON DELETE CASCADE, + funcao_profissional_id UUID REFERENCES funcoes_profissionais(id) ON DELETE CASCADE, + valor NUMERIC(10,2) NOT NULL DEFAULT 0.00, + criado_em TIMESTAMPTZ NOT NULL DEFAULT NOW(), + UNIQUE(tipo_evento_id, funcao_profissional_id) +); + +-- Tabela de Cadastro FOT (Se não existir) +CREATE TABLE IF NOT EXISTS cadastro_fot ( + id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), + fot INTEGER NOT NULL UNIQUE, + empresa_id UUID NOT NULL REFERENCES empresas(id), + curso_id UUID NOT NULL REFERENCES cursos(id), + ano_formatura_id UUID NOT NULL REFERENCES anos_formaturas(id), + instituicao VARCHAR(255), + cidade VARCHAR(255), + estado VARCHAR(2), + observacoes TEXT, + gastos_captacao NUMERIC(10, 2), + pre_venda BOOLEAN, + created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP +); + +-- Códigos de Acesso +CREATE TABLE IF NOT EXISTS codigos_acesso ( + id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), + codigo VARCHAR(50) UNIQUE NOT NULL, + descricao VARCHAR(255), + validade_dias INT NOT NULL DEFAULT 30, + criado_em TIMESTAMPTZ NOT NULL DEFAULT NOW(), + expira_em TIMESTAMPTZ NOT NULL, + ativo BOOLEAN NOT NULL DEFAULT TRUE, + usos INT NOT NULL DEFAULT 0 +); + +-- Cadastro Clientes +CREATE TABLE IF NOT EXISTS cadastro_clientes ( + id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), + usuario_id UUID REFERENCES usuarios(id) ON DELETE CASCADE, + empresa_id UUID REFERENCES empresas(id) ON DELETE SET NULL, + nome VARCHAR(255), + telefone VARCHAR(20), + criado_em TIMESTAMPTZ NOT NULL DEFAULT NOW(), + atualizado_em TIMESTAMPTZ NOT NULL DEFAULT NOW(), + UNIQUE(usuario_id) +); + +-- Juntação Profissionais <-> Funções +CREATE TABLE IF NOT EXISTS profissionais_funcoes_junction ( + profissional_id UUID NOT NULL REFERENCES cadastro_profissionais(id) ON DELETE CASCADE, + funcao_id UUID NOT NULL REFERENCES funcoes_profissionais(id) ON DELETE CASCADE, + PRIMARY KEY (profissional_id, funcao_id) +); + +-- ============================================================================== +-- 4. MÓDULO DE AGENDA E LOGÍSTICA +-- ============================================================================== + +-- Agenda +CREATE TABLE IF NOT EXISTS agenda ( + id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), + user_id UUID REFERENCES usuarios(id) ON DELETE CASCADE, + fot_id UUID NOT NULL REFERENCES cadastro_fot(id) ON DELETE CASCADE, + data_evento DATE NOT NULL, + tipo_evento_id UUID NOT NULL REFERENCES tipos_eventos(id), + observacoes_evento TEXT, + local_evento VARCHAR(255), + endereco VARCHAR(255), + horario VARCHAR(20), + qtd_formandos INTEGER DEFAULT 0, + qtd_fotografos INTEGER DEFAULT 0, + qtd_recepcionistas INTEGER DEFAULT 0, + qtd_cinegrafistas INTEGER DEFAULT 0, + qtd_estudios INTEGER DEFAULT 0, + qtd_ponto_foto INTEGER DEFAULT 0, + qtd_ponto_id INTEGER DEFAULT 0, + qtd_ponto_decorado INTEGER DEFAULT 0, + qtd_pontos_led INTEGER DEFAULT 0, + qtd_plataforma_360 INTEGER DEFAULT 0, + status_profissionais VARCHAR(20) DEFAULT 'OK', + foto_faltante INTEGER DEFAULT 0, + recep_faltante INTEGER DEFAULT 0, + cine_faltante INTEGER DEFAULT 0, + logistica_observacoes TEXT, + pre_venda BOOLEAN DEFAULT FALSE, + criado_em TIMESTAMPTZ NOT NULL DEFAULT NOW(), + atualizado_em TIMESTAMPTZ NOT NULL DEFAULT NOW(), + status VARCHAR(50) DEFAULT 'Pendente' +); + +-- Agenda Profissionais (Atribuição) +CREATE TABLE IF NOT EXISTS agenda_profissionais ( + id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), + agenda_id UUID NOT NULL REFERENCES agenda(id) ON DELETE CASCADE, + profissional_id UUID NOT NULL REFERENCES cadastro_profissionais(id) ON DELETE CASCADE, + status VARCHAR(20) DEFAULT 'PENDENTE', + motivo_rejeicao TEXT, + funcao_id UUID REFERENCES funcoes_profissionais(id), + criado_em TIMESTAMPTZ NOT NULL DEFAULT NOW(), + UNIQUE(agenda_id, profissional_id) +); +ALTER TABLE agenda_profissionais ADD COLUMN IF NOT EXISTS posicao VARCHAR(100); + +-- Disponibilidade +CREATE TABLE IF NOT EXISTS disponibilidade_profissionais ( + id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), + usuario_id UUID NOT NULL REFERENCES usuarios(id) ON DELETE CASCADE, + data DATE NOT NULL, + status VARCHAR(20) NOT NULL DEFAULT 'DISPONIVEL', + criado_em TIMESTAMPTZ NOT NULL DEFAULT NOW(), + UNIQUE(usuario_id, data) +); + +-- Escalas (Time blocks) +CREATE TABLE IF NOT EXISTS agenda_escalas ( + id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), + agenda_id UUID NOT NULL REFERENCES agenda(id) ON DELETE CASCADE, + profissional_id UUID NOT NULL REFERENCES cadastro_profissionais(id) ON DELETE CASCADE, + data_hora_inicio TIMESTAMPTZ NOT NULL, + data_hora_fim TIMESTAMPTZ NOT NULL, + funcao_especifica VARCHAR(100), + criado_em TIMESTAMPTZ NOT NULL DEFAULT NOW(), + atualizado_em TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +-- Mapas +CREATE TABLE IF NOT EXISTS mapas_eventos ( + id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), + agenda_id UUID NOT NULL REFERENCES agenda(id) ON DELETE CASCADE, + nome VARCHAR(100), + imagem_url TEXT, + criado_em TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +-- Marcadores +CREATE TABLE IF NOT EXISTS marcadores_mapa ( + id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), + mapa_id UUID NOT NULL REFERENCES mapas_eventos(id) ON DELETE CASCADE, + profissional_id UUID REFERENCES cadastro_profissionais(id) ON DELETE CASCADE, + pos_x NUMERIC(5,2), + pos_y NUMERIC(5,2), + rotulo VARCHAR(50), + criado_em TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +-- Logística Carros +CREATE TABLE IF NOT EXISTS logistica_carros ( + id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), + agenda_id UUID NOT NULL REFERENCES agenda(id) ON DELETE CASCADE, + motorista_id UUID REFERENCES cadastro_profissionais(id) ON DELETE SET NULL, + nome_motorista VARCHAR(255), + horario_chegada VARCHAR(20), + observacoes TEXT, + criado_em TIMESTAMPTZ NOT NULL DEFAULT NOW(), + atualizado_em TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +-- Logística Passageiros +CREATE TABLE IF NOT EXISTS logistica_passageiros ( + id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), + carro_id UUID NOT NULL REFERENCES logistica_carros(id) ON DELETE CASCADE, + profissional_id UUID NOT NULL REFERENCES cadastro_profissionais(id) ON DELETE CASCADE, + criado_em TIMESTAMPTZ NOT NULL DEFAULT NOW(), + UNIQUE(carro_id, profissional_id) +); + +-- ============================================================================== +-- 5. MÓDULO FINANCEIRO (Atualizações) +-- ============================================================================== +DO $$ +BEGIN + IF EXISTS (SELECT FROM information_schema.tables WHERE table_name = 'financial_transactions') THEN + ALTER TABLE financial_transactions ADD COLUMN IF NOT EXISTS profissional_id UUID REFERENCES cadastro_profissionais(id); + END IF; +END $$; diff --git a/backend/internal/db/migrations/007_change_fot_to_varchar.sql b/backend/internal/db/migrations/007_change_fot_to_varchar.sql new file mode 100644 index 0000000..9db4db0 --- /dev/null +++ b/backend/internal/db/migrations/007_change_fot_to_varchar.sql @@ -0,0 +1,5 @@ +-- Migration to change 'fot' column from INTEGER to VARCHAR(50) to support alphanumeric codes +-- Example: '20000MG' + +-- 1. Alter table 'cadastro_fot' +ALTER TABLE cadastro_fot ALTER COLUMN fot TYPE VARCHAR(50); diff --git a/backend/internal/db/schema.sql b/backend/internal/db/schema.sql index 1ff120e..6d355c7 100644 --- a/backend/internal/db/schema.sql +++ b/backend/internal/db/schema.sql @@ -157,7 +157,7 @@ CREATE TABLE IF NOT EXISTS precos_tipos_eventos ( -- Cadastro FOT CREATE TABLE IF NOT EXISTS cadastro_fot ( id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), - fot INTEGER NOT NULL UNIQUE, + fot VARCHAR(50) NOT NULL UNIQUE, empresa_id UUID NOT NULL REFERENCES empresas(id), curso_id UUID NOT NULL REFERENCES cursos(id), ano_formatura_id UUID NOT NULL REFERENCES anos_formaturas(id), diff --git a/backend/internal/finance/handler.go b/backend/internal/finance/handler.go index ccd9b00..b5cc783 100644 --- a/backend/internal/finance/handler.go +++ b/backend/internal/finance/handler.go @@ -4,7 +4,6 @@ import ( "fmt" "net/http" "photum-backend/internal/db/generated" - "strconv" "time" "github.com/gin-gonic/gin" @@ -197,13 +196,12 @@ func (h *Handler) List(c *gin.Context) { func (h *Handler) AutoFill(c *gin.Context) { fotNumStr := c.Query("fot") - fotNum, err := strconv.Atoi(fotNumStr) - if err != nil { - c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid FOT Number"}) + if fotNumStr == "" { + c.JSON(http.StatusBadRequest, gin.H{"error": "FOT Number required"}) return } - fotData, err := h.service.AutoFillSearch(c.Request.Context(), int32(fotNum)) + fotData, err := h.service.AutoFillSearch(c.Request.Context(), fotNumStr) if err != nil { c.JSON(http.StatusNotFound, gin.H{"error": "FOT not found"}) return diff --git a/backend/internal/finance/service.go b/backend/internal/finance/service.go index 670f31d..5d3798c 100644 --- a/backend/internal/finance/service.go +++ b/backend/internal/finance/service.go @@ -67,7 +67,7 @@ func (s *Service) ListAll(ctx context.Context) ([]generated.ListTransactionsRow, return s.queries.ListTransactions(ctx) } -func (s *Service) AutoFillSearch(ctx context.Context, fotNumber int32) (generated.GetCadastroFotByFotJoinRow, error) { +func (s *Service) AutoFillSearch(ctx context.Context, fotNumber string) (generated.GetCadastroFotByFotJoinRow, error) { return s.queries.GetCadastroFotByFotJoin(ctx, fotNumber) } diff --git a/frontend/components/EventTable.tsx b/frontend/components/EventTable.tsx index e530175..66caa55 100644 --- a/frontend/components/EventTable.tsx +++ b/frontend/components/EventTable.tsx @@ -596,20 +596,10 @@ export const EventTable: React.FC = ({
-
- -

- Digite o código de acesso fornecido pela empresa para continuar com o cadastro. -

- -
- - { - setAccessCode(e.target.value.toUpperCase()); - setCodeError(""); - }} - onKeyPress={(e) => e.key === "Enter" && handleVerifyCode()} - className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#B9CF33] focus:border-transparent uppercase" - placeholder="DIGITE O CÓDIGO" - autoFocus - /> - {codeError && ( -

{codeError}

- )} -
- -
-

- Atenção: O código de acesso é fornecido pela - empresa e tem validade temporária. -

-
- -
- - -
- - - )} - - {isAccessValidated && ( onNavigate("cadastro")} /> - )} ); }; diff --git a/frontend/pages/Team.tsx b/frontend/pages/Team.tsx index 151368f..98326d3 100644 --- a/frontend/pages/Team.tsx +++ b/frontend/pages/Team.tsx @@ -189,16 +189,18 @@ export const TeamPage: React.FC = () => { setIsLoadingCep(true); try { const response = await fetch( - `https://cep.awesomeapi.com.br/json/${cep}` + `https://viacep.com.br/ws/${cep}/json/` ); if (!response.ok) throw new Error("CEP não encontrado"); const data = await response.json(); + if (data.erro) throw new Error("CEP não encontrado"); + setFormData((prev) => ({ ...prev, - endereco: `${data.address || ""} ${data.district ? `- ${data.district}` : ""}`.trim() || prev.endereco, - cidade: data.city || prev.cidade, - uf: data.state || prev.uf, + endereco: `${data.logradouro || ""} ${data.bairro ? `- ${data.bairro}` : ""}`.trim() || prev.endereco, + cidade: data.localidade || prev.cidade, + uf: data.uf || prev.uf, })); } catch (error) { console.error("Erro ao buscar CEP:", error);