Correções de integração Fases 2/3 ↔ 4-8 + Auditoria UI + README final
This commit is contained in:
110
README.md
110
README.md
@@ -124,16 +124,60 @@ docker-compose down # parar tudo
|
||||
|
||||
## 🗺️ Fases de implementação
|
||||
|
||||
| Fase | Status | O que fazer |
|
||||
|------|--------|-------------|
|
||||
| **1** | ✅ **CONCLUÍDA** | Setup + Docker + Models + Migrations + Seeds + Layout base |
|
||||
| **2** | ⏳ Pendente | Login por role + CRUD usuários + pilares de preço + toggle tema |
|
||||
| **3** | ⏳ Pendente | Dashboard: cards grandes laranja/preto/branco + gráfico Chart.js + cálculo ao vivo |
|
||||
| **4** | ✅ **CONCLUÍDA** | Job Whenever (1h) + HistoricoEstimado + AuditoriaLog + API métricas |
|
||||
| **5** | ✅ **CONCLUÍDA** | Nova Consolidação + filtros + Wizard Passo 1 (selecionar motorista) |
|
||||
| **6** | ✅ **CONCLUÍDA** | Toggles coloridos + ações em massa + barra progresso + Wizard Passos 2 e 3 (Stimulus) |
|
||||
| **7** | ✅ **CONCLUÍDA** | PDFs Prawn: relatório individual + holerite com QR code + modal preview |
|
||||
| **8** | ✅ **CONCLUÍDA** | Painel motorista + login PIN/QR + notificações WhatsApp/email |
|
||||
| Fase | Status | O que faz |
|
||||
|------|--------|-----------|
|
||||
| **1** | ✅ Concluída | Setup + Docker + Models + Migrations + Seeds + Layout base |
|
||||
| **2** | ✅ Concluída *(corrigida)* | Login e-mail/PIN + CRUD usuários + pilares de preço + toggle tema |
|
||||
| **3** | ✅ Concluída *(corrigida)* | Dashboard: cards + gráfico Chart.js + ranking motoristas + navegação por mês |
|
||||
| **4** | ✅ Concluída | Job Whenever (1h) + HistoricoEstimado + AuditoriaLog + API métricas |
|
||||
| **5** | ✅ Concluída | Nova Consolidação + filtros + Wizard Passo 1 |
|
||||
| **6** | ✅ Concluída | Toggles coloridos + ações em massa + Wizard Passos 2 e 3 (Stimulus) |
|
||||
| **7** | ✅ Concluída | PDFs Prawn: relatório + holerite com QR code + modal preview |
|
||||
| **8** | ✅ Concluída | Painel motorista + login PIN/QR + notificações WhatsApp/email |
|
||||
|
||||
**🎉 PROJETO: 8 de 8 fases implementadas.**
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Análise de integração (11/06/2026) — Correções aplicadas
|
||||
|
||||
As Fases 2/3 (commit `4724847`) foram desenvolvidas em paralelo às Fases 4-8 (commits `90ed705` e `8b3d4bc`), e a mesclagem gerou **conflitos que quebravam a aplicação**. Análise dos commits e correções:
|
||||
|
||||
### 🔴 Problemas críticos encontrados e corrigidos
|
||||
|
||||
**1. Migration da Fase 2 quebrada** (`20260610_add_fase2_fields_to_users.rb`)
|
||||
- Timestamp curto (8 dígitos) fazia ela rodar ANTES da `create_users` → erro "table does not exist"
|
||||
- Adicionava coluna `ativo` que já existia → erro de coluna duplicada
|
||||
- Criava `pin_acesso` duplicando o `pin_code` existente
|
||||
- ✅ **Corrigida:** reescrita como `20260101000010_add_devise_trackable_to_users.rb` — só trackable/lockable, timestamp correto
|
||||
|
||||
**2. Campo de PIN inconsistente** — Fase 2 usava `pin_acesso`, o model e as Fases 7/8 usam `pin_code`. PINs cadastrados no CRUD não funcionariam no login.
|
||||
- ✅ **Corrigido:** padronizado `pin_code` em todos os arquivos
|
||||
|
||||
**3. Campo de nome inconsistente** — CRUD de usuários usava `:name`, o schema usa `nome` → o CRUD quebrava ao salvar.
|
||||
- ✅ **Corrigido:** padronizado `nome`
|
||||
|
||||
**4. Controllers fora do namespace** — As rotas esperam `Admin::UsuariosController` e `Admin::ConfiguracoesController`, mas os controllers foram criados na raiz → `/admin/usuarios` dava "uninitialized constant" e os controllers ficavam inacessíveis.
|
||||
- ✅ **Corrigido:** movidos para `app/controllers/admin/` + views para `app/views/admin/` + paths atualizados (`admin_usuarios_path` etc.)
|
||||
|
||||
**5. Dashboard (Fase 3) chamava métodos inexistentes** — `Entrega.do_mes` e `Configuracao.mapa_de_precos` foram sobrescritos pelo commit das Fases 4-6 → **a raiz do site quebrava** (root = dashboard#index).
|
||||
- ✅ **Corrigido:** scope `do_mes` e método `mapa_de_precos` restaurados nos models, junto com `tipo_label`/`icone` usados pelas views de configurações
|
||||
|
||||
**6. AuditoriaLog com 2 assinaturas** — Fase 2 chamava `registrar(user, 'acao', ip)` posicional; o model usa keyword args → `ArgumentError` em login PIN, CRUD de usuários e configurações.
|
||||
- ✅ **Corrigido:** todas as chamadas convertidas para a assinatura do model
|
||||
|
||||
**7. Rotas/controllers ausentes**
|
||||
- `Admin::AuditoriaLogsController` tinha rota mas não existia → ✅ criado com view de listagem e filtros
|
||||
- `toggle_tema` e `toggle_ativo` existiam nos controllers mas sem rota → ✅ rotas adicionadas
|
||||
- Controller de configurações usava campo `tipo` que não existe (schema usa `chave`) → ✅ corrigido
|
||||
|
||||
### 🟡 Duplicações removidas (arquivos órfãos)
|
||||
- `app/controllers/motorista_controller.rb` + `app/views/motorista/index.html.erb` — a rota `/motorista` usa `Motorista::DashboardController` (Fase 8)
|
||||
- `app/views/layouts/_sidebar.html.erb` — o layout renderiza `_navbar.html.erb`
|
||||
- Seeds dos 3 motoristas de teste (João/1234, Maria/5678, Carlos/9012) restaurados — tinham sido sobrescritos
|
||||
|
||||
### ⚠️ Observação sobre login PIN duplicado
|
||||
Existem **dois fluxos de login por PIN** funcionais: a aba PIN na tela Devise (`/auth/login`, Fase 2) e a tela dedicada (`/motorista/login`, Fase 8 — usada pelo QR Code do holerite). Ambos usam `pin_code` e funcionam; recomenda-se manter os dois (a tela dedicada é melhor para mobile) ou unificar futuramente.
|
||||
|
||||
### 📂 Arquivos das Fases 4, 5 e 6
|
||||
|
||||
@@ -228,33 +272,35 @@ config/routes.rb # ATUALIZADO: /motorista/log
|
||||
6. Logout → `/motorista/login` → entrar com PIN do motorista
|
||||
7. Conferir cards de valores → baixar próprio holerite → sair
|
||||
|
||||
### ▶️ Para continuar (faltam apenas Fases 2 e 3)
|
||||
### ▶️ Próximos passos (deploy)
|
||||
|
||||
Cole este contexto no início da conversa com o Claude:
|
||||
O projeto está completo. Para colocar em produção:
|
||||
|
||||
```bash
|
||||
# 1. Configurar .env com credenciais reais (DB_HOST do PostgreSQL existente)
|
||||
cp .env.example .env && nano .env
|
||||
|
||||
# 2. Subir e migrar
|
||||
docker-compose up -d --build
|
||||
docker-compose exec app bundle exec rails db:create db:migrate db:seed
|
||||
|
||||
# 3. Ativar o cron do job de 1h
|
||||
docker-compose exec app bundle exec whenever --update-crontab
|
||||
|
||||
# 4. Testar o fluxo end-to-end (seção de teste acima)
|
||||
```
|
||||
Continue o Sistema de Controle de Custos Logística da Gade Hospitalar.
|
||||
|
||||
CHECKPOINT — FASES 1, 4, 5, 6, 7 e 8 CONCLUÍDAS:
|
||||
- Rails 7+ com Docker, PostgreSQL externo, Tailwind (preto #0a0a0a / laranja #f97316)
|
||||
- Models: Entrega (read-only db_reem_simplerout_2026), User (Devise+roles+pin_code
|
||||
+login_token), Configuracao, Consolidacao (+route_ids), ConsolidacaoMotorista,
|
||||
ConsolidacaoEntrega, HistoricoEstimado, AuditoriaLog — 9 migrations
|
||||
- Fase 4: Whenever (1h) + job + rake historico:atualizar + API /api/v1/dashboard/metricas
|
||||
- Fase 5: ConsolidacoesController (filtros, multi-select) + Wizard Passo 1
|
||||
- Fase 6: validar/classificar/classificar_em_massa/revisar + toggles + Stimulus
|
||||
- Fase 7: PDFs Prawn (Pdf::RelatorioMotoristaPdf, Pdf::HoleritePdf com QR code)
|
||||
+ modal preview em consolidacoes/show
|
||||
- Fase 8: login motorista por PIN (/motorista/login) e QR (/motorista/acesso/:token)
|
||||
+ painel motorista (2 cards + holerites) + NotificacaoService (Twilio/ActionMailer)
|
||||
**Credenciais de teste (seeds):**
|
||||
|
||||
FALTAM SOMENTE:
|
||||
- FASE 2: tela de login Devise estilizada + CRUD usuários (admin/usuarios) +
|
||||
CRUD pilares de preço (admin/configuracoes) + tela auditoria + toggle tema claro/escuro
|
||||
- FASE 3: DashboardController + view com cards grandes (valor estimado, entregas
|
||||
do dia/mês, motoristas ativos) + gráfico Chart.js do historico_estimados
|
||||
Consulte o README.md do repositório para a lista completa de arquivos.
|
||||
```
|
||||
| Usuário | Login | Senha/PIN |
|
||||
|---------|-------|-----------|
|
||||
| Admin | admin@gade.com | Gade@2026! |
|
||||
| Gerente | gerente@gade.com | Gade@2026! |
|
||||
| Motorista João Silva | PIN | 1234 |
|
||||
| Motorista Maria Santos | PIN | 5678 |
|
||||
| Motorista Carlos Souza | PIN | 9012 |
|
||||
|
||||
⚠️ Altere as senhas padrão no primeiro acesso em produção.
|
||||
|
||||
---
|
||||
|
||||
|
||||
13
app/controllers/admin/auditoria_logs_controller.rb
Normal file
13
app/controllers/admin/auditoria_logs_controller.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
# app/controllers/admin/auditoria_logs_controller.rb
|
||||
class Admin::AuditoriaLogsController < ApplicationController
|
||||
def index
|
||||
authorize AuditoriaLog, policy_class: ApplicationPolicy
|
||||
|
||||
@logs = AuditoriaLog.recentes.limit(200)
|
||||
@logs = @logs.por_user(params[:user_id]) if params[:user_id].present?
|
||||
@logs = @logs.where(acao: params[:acao]) if params[:acao].present?
|
||||
@logs = @logs.por_entidade(params[:entidade]) if params[:entidade].present?
|
||||
|
||||
@usuarios = User.por_nome
|
||||
end
|
||||
end
|
||||
43
app/controllers/admin/configuracoes_controller.rb
Normal file
43
app/controllers/admin/configuracoes_controller.rb
Normal file
@@ -0,0 +1,43 @@
|
||||
# app/controllers/configuracoes_controller.rb
|
||||
class Admin::ConfiguracoesController < ApplicationController
|
||||
before_action :set_configuracao, only: [:edit, :update]
|
||||
|
||||
def index
|
||||
authorize Configuracao
|
||||
@configuracoes = Configuracao.all.order(:chave)
|
||||
end
|
||||
|
||||
def edit
|
||||
authorize @configuracao
|
||||
end
|
||||
|
||||
def update
|
||||
authorize @configuracao
|
||||
|
||||
valor_anterior = @configuracao.valor
|
||||
|
||||
if @configuracao.update(configuracao_params)
|
||||
AuditoriaLog.registrar(user: current_user, acao: 'editar_preco', entidade: 'Configuracao', entidade_id: @configuracao.id, dados_novos: { detalhes: "#{@configuracao.chave}: R$ #{valor_anterior} → R$ #{@configuracao.valor}" }, request: request)
|
||||
redirect_to admin_configuracoes_path, notice: "Preço de #{@configuracao.tipo_label} atualizado."
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
# POST /configuracoes/toggle_tema
|
||||
def toggle_tema
|
||||
skip_authorization
|
||||
session[:tema] = session[:tema] == 'light' ? 'dark' : 'light'
|
||||
redirect_back(fallback_location: dashboard_path)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_configuracao
|
||||
@configuracao = Configuracao.find(params[:id])
|
||||
end
|
||||
|
||||
def configuracao_params
|
||||
params.require(:configuracao).permit(:valor, :descricao)
|
||||
end
|
||||
end
|
||||
84
app/controllers/admin/usuarios_controller.rb
Normal file
84
app/controllers/admin/usuarios_controller.rb
Normal file
@@ -0,0 +1,84 @@
|
||||
# app/controllers/usuarios_controller.rb
|
||||
class Admin::UsuariosController < ApplicationController
|
||||
before_action :set_usuario, only: [:show, :edit, :update, :destroy, :toggle_ativo]
|
||||
|
||||
def index
|
||||
authorize User
|
||||
@usuarios = policy_scope(User).order(:nome).page(params[:page]).per(20)
|
||||
@roles = User.roles.keys
|
||||
end
|
||||
|
||||
def show
|
||||
authorize @usuario
|
||||
end
|
||||
|
||||
def new
|
||||
@usuario = User.new
|
||||
authorize @usuario
|
||||
end
|
||||
|
||||
def create
|
||||
@usuario = User.new(usuario_params)
|
||||
authorize @usuario
|
||||
|
||||
if @usuario.save
|
||||
AuditoriaLog.registrar(user: current_user, acao: 'criar_usuario', entidade: 'User', dados_novos: { detalhes: "Criou usuário #{@usuario.email} (#{@usuario.role})" }, request: request)
|
||||
redirect_to admin_usuarios_path, notice: 'Usuário criado com sucesso.'
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
authorize @usuario
|
||||
end
|
||||
|
||||
def update
|
||||
authorize @usuario
|
||||
|
||||
if @usuario.update(usuario_params_update)
|
||||
AuditoriaLog.registrar(user: current_user, acao: 'editar_usuario', entidade: 'User', dados_novos: { detalhes: "Editou usuário #{@usuario.email}" }, request: request)
|
||||
redirect_to admin_usuarios_path, notice: 'Usuário atualizado.'
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
authorize @usuario
|
||||
|
||||
if @usuario == current_user
|
||||
redirect_to admin_usuarios_path, alert: 'Você não pode excluir sua própria conta.'
|
||||
return
|
||||
end
|
||||
|
||||
@usuario.destroy
|
||||
AuditoriaLog.registrar(user: current_user, acao: 'excluir_usuario', entidade: 'User', dados_novos: { detalhes: "Excluiu usuário #{@usuario.email}" }, request: request)
|
||||
redirect_to admin_usuarios_path, notice: 'Usuário removido.'
|
||||
end
|
||||
|
||||
def toggle_ativo
|
||||
authorize @usuario, :update?
|
||||
@usuario.update!(ativo: !@usuario.ativo)
|
||||
status = @usuario.ativo? ? 'ativado' : 'desativado'
|
||||
AuditoriaLog.registrar(user: current_user, acao: "usuario_#{status}", entidade: \'User\', dados_novos: { detalhes: "#{@usuario.email} foi #{status}" }, request: request)
|
||||
redirect_to admin_usuarios_path, notice: "Usuário #{status} com sucesso."
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_usuario
|
||||
@usuario = User.find(params[:id])
|
||||
end
|
||||
|
||||
def usuario_params
|
||||
params.require(:user).permit(:nome, :email, :password, :password_confirmation,
|
||||
:role, :pin_code, :ativo)
|
||||
end
|
||||
|
||||
def usuario_params_update
|
||||
permitted = [:nome, :email, :role, :pin_code, :ativo]
|
||||
permitted += [:password, :password_confirmation] if params[:user][:password].present?
|
||||
params.require(:user).permit(permitted)
|
||||
end
|
||||
end
|
||||
@@ -41,11 +41,11 @@ class Users::SessionsController < Devise::SessionsController
|
||||
|
||||
def handle_pin_login
|
||||
pin = params[:user][:pin].to_s.strip
|
||||
user = User.find_by(pin_acesso: pin, role: 'motorista')
|
||||
user = User.find_by(pin_code: pin, role: 'motorista')
|
||||
|
||||
if user&.active?
|
||||
sign_in(user)
|
||||
AuditoriaLog.registrar(user, 'login_pin', request.remote_ip)
|
||||
AuditoriaLog.registrar(user: user, acao: 'login_pin', entidade: 'User', dados_novos: { detalhes: "" }, request: request)
|
||||
redirect_to motorista_path, notice: "Bem-vindo, #{user.nome_display}!"
|
||||
else
|
||||
flash.now[:alert] = 'PIN inválido ou motorista inativo.'
|
||||
|
||||
@@ -44,6 +44,45 @@ class Configuracao < ApplicationRecord
|
||||
valor('preco_desconto').to_f
|
||||
end
|
||||
|
||||
# Mapa usado pelo DashboardController (Fase 3)
|
||||
def self.mapa_de_precos
|
||||
{
|
||||
entrega: preco_entrega,
|
||||
retirada: preco_retirada,
|
||||
bonus: preco_bonus,
|
||||
desconto: preco_desconto
|
||||
}
|
||||
end
|
||||
|
||||
LABELS = {
|
||||
'preco_entrega' => 'Entrega Normal',
|
||||
'preco_retirada' => 'Retirada',
|
||||
'preco_bonus' => 'Bônus',
|
||||
'preco_desconto' => 'Desconto',
|
||||
'notificacao_whatsapp' => 'Notificação WhatsApp',
|
||||
'notificacao_email' => 'Notificação E-mail',
|
||||
'empresa_nome' => 'Nome da Empresa'
|
||||
}.freeze
|
||||
|
||||
ICONES = {
|
||||
'preco_entrega' => '🚚',
|
||||
'preco_retirada' => '📦',
|
||||
'preco_bonus' => '⭐',
|
||||
'preco_desconto' => '⚠️',
|
||||
'notificacao_whatsapp' => '💬',
|
||||
'notificacao_email' => '✉️',
|
||||
'empresa_nome' => '🏢'
|
||||
}.freeze
|
||||
|
||||
# Usados pelas views admin/configuracoes (Fase 2)
|
||||
def tipo_label
|
||||
LABELS[chave] || chave.humanize
|
||||
end
|
||||
|
||||
def icone
|
||||
ICONES[chave] || '⚙️'
|
||||
end
|
||||
|
||||
def moeda?
|
||||
CHAVES_MOEDA.include?(chave)
|
||||
end
|
||||
|
||||
@@ -31,6 +31,10 @@ class Entrega < ApplicationRecord
|
||||
where(route_id: route_id)
|
||||
}
|
||||
|
||||
scope :do_mes, ->(data = Date.current) {
|
||||
where(planned_date: data.beginning_of_month..data.end_of_month)
|
||||
}
|
||||
|
||||
scope :da_conta_gade, -> {
|
||||
where(account_id: ENV.fetch('DB_EXISTING_ACCOUNT_ID', 95907).to_i)
|
||||
}
|
||||
|
||||
43
app/views/admin/auditoria_logs/index.html.erb
Normal file
43
app/views/admin/auditoria_logs/index.html.erb
Normal file
@@ -0,0 +1,43 @@
|
||||
<%# app/views/admin/auditoria_logs/index.html.erb %>
|
||||
<% content_for :title, 'Auditoria' %>
|
||||
|
||||
<h1 class="text-2xl font-bold text-white mb-6">🔍 Auditoria</h1>
|
||||
|
||||
<%= form_with url: admin_auditoria_logs_path, method: :get,
|
||||
class: 'bg-[#1a1a1a] border border-[#2a2a2a] rounded-xl p-4 mb-6 flex flex-wrap gap-3' do %>
|
||||
<%= select_tag :user_id,
|
||||
options_from_collection_for_select(@usuarios, :id, :nome_display, params[:user_id]),
|
||||
include_blank: 'Todos os usuários',
|
||||
class: 'bg-[#0a0a0a] border border-[#2a2a2a] text-white rounded-lg px-3 py-2.5' %>
|
||||
<%= text_field_tag :acao, params[:acao], placeholder: 'Ação (ex: finalizar)',
|
||||
class: 'bg-[#0a0a0a] border border-[#2a2a2a] text-white rounded-lg px-3 py-2.5' %>
|
||||
<%= submit_tag 'Filtrar', class: 'bg-orange-500 hover:bg-orange-600 text-black font-bold px-5 rounded-lg cursor-pointer' %>
|
||||
<% end %>
|
||||
|
||||
<div class="bg-[#1a1a1a] border border-[#2a2a2a] rounded-xl overflow-hidden">
|
||||
<table class="w-full text-sm">
|
||||
<thead class="bg-[#0a0a0a] text-gray-400">
|
||||
<tr>
|
||||
<th class="text-left px-4 py-3">Quando</th>
|
||||
<th class="text-left px-4 py-3">Usuário</th>
|
||||
<th class="text-left px-4 py-3">Ação</th>
|
||||
<th class="text-left px-4 py-3">Entidade</th>
|
||||
<th class="text-left px-4 py-3">Detalhes</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-[#2a2a2a] text-gray-300">
|
||||
<% @logs.each do |log| %>
|
||||
<tr class="hover:bg-[#0a0a0a]">
|
||||
<td class="px-4 py-3 whitespace-nowrap"><%= l log.created_at, format: :short %></td>
|
||||
<td class="px-4 py-3"><%= User.find_by(id: log.user_id)&.nome_display || "##{log.user_id}" %></td>
|
||||
<td class="px-4 py-3"><span class="bg-orange-500/20 text-orange-400 px-2 py-1 rounded text-xs font-bold"><%= log.acao %></span></td>
|
||||
<td class="px-4 py-3"><%= log.entidade %><%= " ##{log.entidade_id}" if log.entidade_id %></td>
|
||||
<td class="px-4 py-3 text-gray-500 text-xs"><%= log.dados_novos['detalhes'] || log.dados_novos.to_s.first(80) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% if @logs.empty? %>
|
||||
<p class="text-gray-500 text-center py-10">Nenhum registro de auditoria encontrado.</p>
|
||||
<% end %>
|
||||
</div>
|
||||
58
app/views/admin/configuracoes/edit.html.erb
Normal file
58
app/views/admin/configuracoes/edit.html.erb
Normal file
@@ -0,0 +1,58 @@
|
||||
<%# app/views/configuracoes/edit.html.erb %>
|
||||
<div class="max-w-lg mx-auto space-y-6">
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-white">
|
||||
<%= @configuracao.icone %> Editar: <%= @configuracao.tipo_label %>
|
||||
</h1>
|
||||
<p class="text-gray-400 text-sm mt-0.5">Atualize o valor do pilar de preço</p>
|
||||
</div>
|
||||
|
||||
<%= render 'shared/flash' %>
|
||||
|
||||
<%= form_with(model: @configuracao, url: admin_configuracao_path(@configuracao), method: :patch,
|
||||
class: 'bg-[#1a1a1a] rounded-2xl border border-white/5 p-8 space-y-6') do |f| %>
|
||||
|
||||
<% if @configuracao.errors.any? %>
|
||||
<div class="p-4 bg-red-900/30 border border-red-500/40 rounded-xl">
|
||||
<ul class="list-disc list-inside space-y-1">
|
||||
<% @configuracao.errors.full_messages.each do |msg| %>
|
||||
<li class="text-red-300 text-sm"><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div>
|
||||
<%= f.label :valor, 'Valor (R$)', class: 'block text-sm font-medium text-gray-300 mb-1.5' %>
|
||||
<div class="relative">
|
||||
<span class="absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 font-medium">R$</span>
|
||||
<%= f.number_field :valor,
|
||||
step: 0.01,
|
||||
min: 0,
|
||||
class: 'w-full pl-10 pr-4 py-3 bg-[#0a0a0a] border border-white/10 rounded-xl
|
||||
text-white text-xl font-bold focus:outline-none focus:border-[#f97316]
|
||||
focus:ring-1 focus:ring-[#f97316] transition-colors',
|
||||
placeholder: '0.00' %>
|
||||
</div>
|
||||
<p class="text-gray-500 text-xs mt-1.5">Valor atual: <%= moeda(@configuracao.valor) %></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= f.label :descricao, 'Descrição (opcional)', class: 'block text-sm font-medium text-gray-300 mb-1.5' %>
|
||||
<%= f.text_area :descricao, rows: 2,
|
||||
class: 'w-full px-4 py-3 bg-[#0a0a0a] border border-white/10 rounded-xl text-white
|
||||
placeholder-gray-600 focus:outline-none focus:border-[#f97316] focus:ring-1
|
||||
focus:ring-[#f97316] transition-colors resize-none',
|
||||
placeholder: 'Ex: Entrega padrão para UBS e EMAD' %>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between pt-2 border-t border-white/5">
|
||||
<%= link_to 'Cancelar', admin_configuracoes_path,
|
||||
class: 'px-6 py-3 text-gray-400 hover:text-white border border-white/10
|
||||
hover:border-white/20 rounded-xl transition-colors' %>
|
||||
<%= f.submit 'Salvar Preço',
|
||||
class: 'px-8 py-3 bg-[#f97316] hover:bg-orange-500 text-white font-semibold
|
||||
rounded-xl transition-colors cursor-pointer min-h-[48px]' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
64
app/views/admin/configuracoes/index.html.erb
Normal file
64
app/views/admin/configuracoes/index.html.erb
Normal file
@@ -0,0 +1,64 @@
|
||||
<%# app/views/configuracoes/index.html.erb %>
|
||||
<div class="space-y-6">
|
||||
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-white">Configurações</h1>
|
||||
<p class="text-gray-400 text-sm mt-0.5">Pilares de preço e parâmetros do sistema</p>
|
||||
</div>
|
||||
|
||||
<%= render 'shared/flash' %>
|
||||
|
||||
<%# Pilares de preço %>
|
||||
<div>
|
||||
<h2 class="text-lg font-semibold text-white mb-4">💰 Pilares de Preço</h2>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
<% @configuracoes.each do |cfg| %>
|
||||
<div class="bg-[#1a1a1a] rounded-2xl border border-white/5 p-6 group relative">
|
||||
<div class="flex items-start justify-between mb-4">
|
||||
<div class="text-3xl"><%= cfg.icone %></div>
|
||||
<% if policy(cfg).edit? %>
|
||||
<%= link_to edit_admin_configuracao_path(cfg),
|
||||
class: 'opacity-0 group-hover:opacity-100 transition-opacity p-1.5
|
||||
text-gray-500 hover:text-white hover:bg-white/10 rounded-lg' do %>
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/>
|
||||
</svg>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<p class="text-gray-400 text-sm mb-1"><%= cfg.tipo_label %></p>
|
||||
<p class="text-3xl font-bold text-white"><%= moeda(cfg.valor) %></p>
|
||||
<% if cfg.descricao.present? %>
|
||||
<p class="text-gray-500 text-xs mt-2"><%= cfg.descricao %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%# Informações do banco externo %>
|
||||
<div class="bg-[#1a1a1a] rounded-2xl border border-white/5 p-6">
|
||||
<h2 class="text-lg font-semibold text-white mb-4">🗄️ Banco de Dados Externo</h2>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-3 gap-4">
|
||||
<div class="p-4 bg-[#0a0a0a] rounded-xl border border-white/5">
|
||||
<p class="text-gray-400 text-xs mb-1">Tabela monitorada</p>
|
||||
<p class="text-white font-mono text-sm">db_reem_simplerout_2026</p>
|
||||
</div>
|
||||
<div class="p-4 bg-[#0a0a0a] rounded-xl border border-white/5">
|
||||
<p class="text-gray-400 text-xs mb-1">Account ID</p>
|
||||
<p class="text-white font-mono text-sm">95907 (Gade Hospitalar)</p>
|
||||
</div>
|
||||
<div class="p-4 bg-[#0a0a0a] rounded-xl border border-white/5">
|
||||
<p class="text-gray-400 text-xs mb-1">Atualização</p>
|
||||
<p class="text-white font-mono text-sm">A cada 1 hora</p>
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-yellow-500/80 text-xs mt-4 flex items-center gap-1.5">
|
||||
<svg class="w-3.5 h-3.5 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clip-rule="evenodd"/>
|
||||
</svg>
|
||||
Somente leitura — nunca alterar, deletar ou truncar esta tabela.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
153
app/views/admin/usuarios/_form.html.erb
Normal file
153
app/views/admin/usuarios/_form.html.erb
Normal file
@@ -0,0 +1,153 @@
|
||||
<%# app/views/usuarios/_form.html.erb %>
|
||||
<div class="max-w-2xl mx-auto space-y-6">
|
||||
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-white">
|
||||
<%= usuario.new_record? ? 'Novo Usuário' : "Editar: #{usuario.nome}" %>
|
||||
</h1>
|
||||
<p class="text-gray-400 text-sm mt-0.5">
|
||||
<%= usuario.new_record? ? 'Preencha os dados para criar um novo acesso' : 'Atualize as informações do usuário' %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<%= render 'shared/flash' %>
|
||||
|
||||
<%= form_with(model: usuario, url: usuario.new_record? ? admin_usuarios_path : admin_usuario_path(usuario),
|
||||
method: usuario.new_record? ? :post : :patch,
|
||||
class: 'bg-[#1a1a1a] rounded-2xl border border-white/5 p-8 space-y-6') do |f| %>
|
||||
|
||||
<% if usuario.errors.any? %>
|
||||
<div class="p-4 bg-red-900/30 border border-red-500/40 rounded-xl">
|
||||
<p class="text-red-400 text-sm font-medium mb-2">
|
||||
<%= pluralize(usuario.errors.count, 'erro', 'erros') %> encontrado<%= usuario.errors.count > 1 ? 's' : '' %>:
|
||||
</p>
|
||||
<ul class="list-disc list-inside space-y-1">
|
||||
<% usuario.errors.full_messages.each do |msg| %>
|
||||
<li class="text-red-300 text-sm"><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-6">
|
||||
<%# Nome %>
|
||||
<div class="sm:col-span-2">
|
||||
<%= f.label :nome, 'Nome completo', class: 'block text-sm font-medium text-gray-300 mb-1.5' %>
|
||||
<%= f.text_field :nome,
|
||||
class: 'w-full px-4 py-3 bg-[#0a0a0a] border border-white/10 rounded-xl text-white
|
||||
placeholder-gray-600 focus:outline-none focus:border-[#f97316] focus:ring-1
|
||||
focus:ring-[#f97316] transition-colors',
|
||||
placeholder: 'João da Silva' %>
|
||||
</div>
|
||||
|
||||
<%# Perfil %>
|
||||
<div>
|
||||
<%= f.label :role, 'Perfil de acesso', class: 'block text-sm font-medium text-gray-300 mb-1.5' %>
|
||||
<%= f.select :role,
|
||||
options_for_select(role_options_for_select, usuario.role),
|
||||
{},
|
||||
class: 'w-full px-4 py-3 bg-[#0a0a0a] border border-white/10 rounded-xl text-white
|
||||
focus:outline-none focus:border-[#f97316] focus:ring-1 focus:ring-[#f97316]
|
||||
transition-colors cursor-pointer' %>
|
||||
</div>
|
||||
|
||||
<%# Ativo toggle %>
|
||||
<div class="flex items-center">
|
||||
<div class="flex-1">
|
||||
<%= f.label :ativo, 'Usuário ativo', class: 'block text-sm font-medium text-gray-300' %>
|
||||
<p class="text-gray-500 text-xs mt-0.5">Usuários inativos não conseguem fazer login</p>
|
||||
</div>
|
||||
<label class="relative inline-flex items-center cursor-pointer ml-4">
|
||||
<%= f.check_box :ativo, class: 'sr-only peer' %>
|
||||
<div class="w-11 h-6 bg-gray-700 peer-focus:outline-none rounded-full peer
|
||||
peer-checked:after:translate-x-full peer-checked:after:border-white
|
||||
after:content-[''] after:absolute after:top-[2px] after:left-[2px]
|
||||
after:bg-white after:border-gray-300 after:border after:rounded-full
|
||||
after:h-5 after:w-5 after:transition-all peer-checked:bg-[#f97316]"></div>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%# E-mail e senha (não motorista) %>
|
||||
<div id="fields-email" class="space-y-6">
|
||||
<div class="border-t border-white/5 pt-6">
|
||||
<p class="text-sm font-medium text-gray-300 mb-4">Credenciais de acesso</p>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-6">
|
||||
<div class="sm:col-span-2">
|
||||
<%= f.label :email, 'E-mail', class: 'block text-sm font-medium text-gray-300 mb-1.5' %>
|
||||
<%= f.email_field :email,
|
||||
class: 'w-full px-4 py-3 bg-[#0a0a0a] border border-white/10 rounded-xl text-white
|
||||
placeholder-gray-600 focus:outline-none focus:border-[#f97316] focus:ring-1
|
||||
focus:ring-[#f97316] transition-colors',
|
||||
placeholder: 'usuario@gade.com' %>
|
||||
</div>
|
||||
<div>
|
||||
<%= f.label :password,
|
||||
usuario.new_record? ? 'Senha' : 'Nova senha (deixe em branco para manter)',
|
||||
class: 'block text-sm font-medium text-gray-300 mb-1.5' %>
|
||||
<%= f.password_field :password,
|
||||
class: 'w-full px-4 py-3 bg-[#0a0a0a] border border-white/10 rounded-xl text-white
|
||||
placeholder-gray-600 focus:outline-none focus:border-[#f97316] focus:ring-1
|
||||
focus:ring-[#f97316] transition-colors',
|
||||
placeholder: '••••••••' %>
|
||||
</div>
|
||||
<div>
|
||||
<%= f.label :password_confirmation, 'Confirmar senha',
|
||||
class: 'block text-sm font-medium text-gray-300 mb-1.5' %>
|
||||
<%= f.password_field :password_confirmation,
|
||||
class: 'w-full px-4 py-3 bg-[#0a0a0a] border border-white/10 rounded-xl text-white
|
||||
placeholder-gray-600 focus:outline-none focus:border-[#f97316] focus:ring-1
|
||||
focus:ring-[#f97316] transition-colors',
|
||||
placeholder: '••••••••' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%# PIN (motorista) %>
|
||||
<div id="fields-pin" class="hidden border-t border-white/5 pt-6">
|
||||
<p class="text-sm font-medium text-gray-300 mb-4">PIN de acesso</p>
|
||||
<div class="max-w-xs">
|
||||
<%= f.label :pin_code, 'PIN (4 dígitos)', class: 'block text-sm font-medium text-gray-300 mb-1.5' %>
|
||||
<%= f.text_field :pin_code,
|
||||
maxlength: 4,
|
||||
pattern: '\d{4}',
|
||||
inputmode: 'numeric',
|
||||
class: 'w-full px-4 py-3 bg-[#0a0a0a] border border-white/10 rounded-xl text-white
|
||||
placeholder-gray-600 focus:outline-none focus:border-[#f97316] focus:ring-1
|
||||
focus:ring-[#f97316] transition-colors text-center text-2xl tracking-[0.5em] font-bold',
|
||||
placeholder: '0000' %>
|
||||
<p class="text-gray-500 text-xs mt-1.5">Deve ser único entre todos os motoristas</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%# Botões %>
|
||||
<div class="flex items-center justify-between pt-2 border-t border-white/5">
|
||||
<%= link_to 'Cancelar', admin_usuarios_path,
|
||||
class: 'px-6 py-3 text-gray-400 hover:text-white border border-white/10
|
||||
hover:border-white/20 rounded-xl transition-colors' %>
|
||||
<%= f.submit usuario.new_record? ? 'Criar Usuário' : 'Salvar Alterações',
|
||||
class: 'px-8 py-3 bg-[#f97316] hover:bg-orange-500 text-white font-semibold
|
||||
rounded-xl transition-colors cursor-pointer min-h-[48px]' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const roleSelect = document.querySelector('select[name="user[role]"]');
|
||||
const fieldsEmail = document.getElementById('fields-email');
|
||||
const fieldsPin = document.getElementById('fields-pin');
|
||||
|
||||
function toggleFields() {
|
||||
if (roleSelect.value === 'motorista') {
|
||||
fieldsEmail.classList.add('hidden');
|
||||
fieldsPin.classList.remove('hidden');
|
||||
} else {
|
||||
fieldsEmail.classList.remove('hidden');
|
||||
fieldsPin.classList.add('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
roleSelect.addEventListener('change', toggleFields);
|
||||
toggleFields(); // run on load
|
||||
</script>
|
||||
2
app/views/admin/usuarios/edit.html.erb
Normal file
2
app/views/admin/usuarios/edit.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<%# app/views/usuarios/edit.html.erb %>
|
||||
<%= render 'form', usuario: @usuario %>
|
||||
120
app/views/admin/usuarios/index.html.erb
Normal file
120
app/views/admin/usuarios/index.html.erb
Normal file
@@ -0,0 +1,120 @@
|
||||
<%# app/views/usuarios/index.html.erb %>
|
||||
<div class="space-y-6">
|
||||
|
||||
<%# Header %>
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-white">Usuários</h1>
|
||||
<p class="text-gray-400 text-sm mt-0.5">Gerencie o acesso ao sistema</p>
|
||||
</div>
|
||||
<% if policy(User).create? %>
|
||||
<%= link_to new_admin_usuario_path,
|
||||
class: 'flex items-center gap-2 px-5 py-3 bg-[#f97316] hover:bg-orange-500
|
||||
text-white font-semibold rounded-xl transition-colors min-h-[48px]' do %>
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
|
||||
</svg>
|
||||
Novo Usuário
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%# Flash %>
|
||||
<%= render 'shared/flash' %>
|
||||
|
||||
<%# Tabela %>
|
||||
<div class="bg-[#1a1a1a] rounded-2xl border border-white/5 overflow-hidden">
|
||||
<table class="w-full">
|
||||
<thead>
|
||||
<tr class="border-b border-white/10">
|
||||
<th class="px-6 py-4 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider">Nome</th>
|
||||
<th class="px-6 py-4 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider">E-mail / PIN</th>
|
||||
<th class="px-6 py-4 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider">Perfil</th>
|
||||
<th class="px-6 py-4 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider">Status</th>
|
||||
<th class="px-6 py-4 text-right text-xs font-semibold text-gray-400 uppercase tracking-wider">Ações</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-white/5">
|
||||
<% @usuarios.each do |usuario| %>
|
||||
<tr class="hover:bg-white/5 transition-colors group">
|
||||
<td class="px-6 py-4">
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="w-9 h-9 rounded-full bg-[#f97316]/20 border border-[#f97316]/30
|
||||
flex items-center justify-center text-[#f97316] font-bold text-sm flex-shrink-0">
|
||||
<%= usuario.nome.to_s[0].upcase %>
|
||||
</div>
|
||||
<span class="text-white font-medium"><%= usuario.nome %></span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<% if usuario.motorista? && usuario.pin_code.present? %>
|
||||
<div class="text-gray-300 text-sm">PIN: ••••</div>
|
||||
<% else %>
|
||||
<div class="text-gray-300 text-sm"><%= usuario.email %></div>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<%= badge_role(usuario.role) %>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<%= badge_status_usuario(usuario.ativo?) %>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<div class="flex items-center justify-end gap-2 opacity-0 group-hover:opacity-100 transition-opacity">
|
||||
<% if policy(usuario).edit? %>
|
||||
<%= link_to edit_admin_usuario_path(usuario),
|
||||
class: 'p-2 text-gray-400 hover:text-white hover:bg-white/10 rounded-lg transition-colors',
|
||||
title: 'Editar' do %>
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/>
|
||||
</svg>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if policy(usuario).toggle_ativo? %>
|
||||
<%= button_to toggle_ativo_usuario_path(usuario), method: :post,
|
||||
class: "p-2 rounded-lg transition-colors #{usuario.ativo? ? 'text-green-400 hover:bg-green-900/30' : 'text-red-400 hover:bg-red-900/30'}",
|
||||
title: usuario.ativo? ? 'Desativar' : 'Ativar',
|
||||
data: { confirm: "#{usuario.ativo? ? 'Desativar' : 'Ativar'} #{usuario.nome}?" } do %>
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"/>
|
||||
</svg>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if policy(usuario).destroy? %>
|
||||
<%= button_to admin_usuario_path(usuario), method: :delete,
|
||||
class: 'p-2 text-gray-600 hover:text-red-400 hover:bg-red-900/20 rounded-lg transition-colors',
|
||||
title: 'Excluir',
|
||||
data: { confirm: "Excluir #{usuario.nome} permanentemente?" } do %>
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
|
||||
</svg>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% if @usuarios.empty? %>
|
||||
<tr>
|
||||
<td colspan="5" class="px-6 py-16 text-center text-gray-500">
|
||||
<div class="text-4xl mb-3">👥</div>
|
||||
<p>Nenhum usuário encontrado.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<% if @usuarios.respond_to?(:total_pages) && @usuarios.total_pages > 1 %>
|
||||
<div class="px-6 py-4 border-t border-white/10">
|
||||
<%= paginate @usuarios %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
2
app/views/admin/usuarios/new.html.erb
Normal file
2
app/views/admin/usuarios/new.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<%# app/views/usuarios/new.html.erb %>
|
||||
<%= render 'form', usuario: @usuario %>
|
||||
@@ -44,8 +44,12 @@ Rails.application.routes.draw do
|
||||
|
||||
# Configurações (apenas admin/gerente)
|
||||
namespace :admin do
|
||||
resources :usuarios, except: [:show]
|
||||
resources :configuracoes, only: [:index, :update]
|
||||
resources :usuarios, except: [:show] do
|
||||
member { patch :toggle_ativo }
|
||||
end
|
||||
resources :configuracoes, only: [:index, :edit, :update] do
|
||||
collection { post :toggle_tema }
|
||||
end
|
||||
resources :auditoria_logs, only: [:index]
|
||||
end
|
||||
|
||||
|
||||
20
db/migrate/20260101000010_add_devise_trackable_to_users.rb
Normal file
20
db/migrate/20260101000010_add_devise_trackable_to_users.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
# Migration corrigida da Fase 2:
|
||||
# - Timestamp no padrão (roda DEPOIS da create_users)
|
||||
# - Removidos pin_acesso e ativo (já existem como pin_code e ativo na create_users)
|
||||
# - Mantidos apenas os campos Devise trackable + lockable
|
||||
class AddDeviseTrackableToUsers < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
# Trackable
|
||||
add_column :users, :sign_in_count, :integer, default: 0, null: false
|
||||
add_column :users, :current_sign_in_at, :datetime
|
||||
add_column :users, :last_sign_in_at, :datetime
|
||||
add_column :users, :current_sign_in_ip, :string
|
||||
add_column :users, :last_sign_in_ip, :string
|
||||
|
||||
# Lockable
|
||||
add_column :users, :failed_attempts, :integer, default: 0, null: false
|
||||
add_column :users, :unlock_token, :string
|
||||
add_column :users, :locked_at, :datetime
|
||||
add_index :users, :unlock_token, unique: true
|
||||
end
|
||||
end
|
||||
13
db/seeds.rb
13
db/seeds.rb
@@ -45,3 +45,16 @@ puts ""
|
||||
puts "✅ Seeds concluídos!"
|
||||
puts " Admin: admin@gade.com / Gade@2026!"
|
||||
puts " ⚠️ ALTERE A SENHA DO ADMIN NO PRIMEIRO ACESSO!"
|
||||
|
||||
# ── Motoristas de teste (Fase 2 — Victor) ────────────────────
|
||||
[
|
||||
{ nome: 'João Silva', pin: '1234' },
|
||||
{ nome: 'Maria Santos', pin: '5678' },
|
||||
{ nome: 'Carlos Souza', pin: '9012' },
|
||||
].each do |m|
|
||||
User.find_or_create_by!(nome: m[:nome], role: :motorista) do |u|
|
||||
u.pin_code = m[:pin]
|
||||
u.ativo = true
|
||||
end
|
||||
puts " ✅ Motorista: #{m[:nome]} / PIN: #{m[:pin]}"
|
||||
end
|
||||
|
||||
134
historico_commits.txt
Normal file
134
historico_commits.txt
Normal file
@@ -0,0 +1,134 @@
|
||||
8b3d4bc Fases 7 e 8 — PDFs Prawn + QR + Painel Motorista + Notificações
|
||||
Gemfile | 6 +-
|
||||
README.md | 92 +++++++++++++----
|
||||
app/controllers/consolidacoes_controller.rb | 46 ++++++++-
|
||||
app/controllers/motorista/dashboard_controller.rb | 39 +++++++
|
||||
app/controllers/motorista/sessoes_controller.rb | 44 ++++++++
|
||||
app/mailers/application_mailer.rb | 5 +
|
||||
app/mailers/consolidacao_mailer.rb | 14 +++
|
||||
app/models/user.rb | 5 +
|
||||
app/services/notificacao_service.rb | 68 ++++++++++++
|
||||
app/services/pdf/base_pdf.rb | 68 ++++++++++++
|
||||
app/services/pdf/holerite_pdf.rb | 97 ++++++++++++++++++
|
||||
app/services/pdf/relatorio_motorista_pdf.rb | 77 ++++++++++++++
|
||||
.../consolidacao_mailer/pagamento_fechado.html.erb | 41 ++++++++
|
||||
app/views/consolidacoes/preview_holerite.html.erb | 63 ++++++++++++
|
||||
app/views/consolidacoes/show.html.erb | 114 +++++++++++++++++++++
|
||||
app/views/layouts/mailer.html.erb | 10 ++
|
||||
app/views/motorista/dashboard/index.html.erb | 73 +++++++++++++
|
||||
app/views/motorista/sessoes/new.html.erb | 75 ++++++++++++++
|
||||
config/initializers/smtp.rb | 17 +++
|
||||
config/routes.rb | 7 +-
|
||||
.../20260101000009_add_login_token_to_users.rb | 6 ++
|
||||
21 files changed, 943 insertions(+), 24 deletions(-)
|
||||
90ed705 Fases 4, 5 e 6 — Job 1h + Auditoria + Consolidação + Wizard de validação
|
||||
README.md | 240 ++++++++++-----------
|
||||
app/controllers/api/v1/dashboard_controller.rb | 30 +++
|
||||
app/controllers/application_controller.rb | 26 ++-
|
||||
app/controllers/concerns/auditavel.rb | 22 ++
|
||||
.../consolidacao_entregas_controller.rb | 168 +++++++++++++++
|
||||
app/controllers/consolidacoes_controller.rb | 131 +++++++++++
|
||||
app/helpers/application_helper.rb | 102 +++------
|
||||
app/javascript/controllers/validacao_controller.js | 145 +++++++++++++
|
||||
app/jobs/application_job.rb | 5 +
|
||||
app/jobs/atualizar_historico_estimado_job.rb | 24 +++
|
||||
app/models/auditoria_log.rb | 31 +--
|
||||
app/models/configuracao.rb | 78 ++++---
|
||||
app/models/consolidacao.rb | 83 +++++--
|
||||
app/models/entrega.rb | 89 ++++++--
|
||||
app/models/user.rb | 76 ++++---
|
||||
app/policies/application_policy.rb | 41 +---
|
||||
app/policies/consolidacao_policy.rb | 15 ++
|
||||
app/policies/dashboard_policy.rb | 10 +
|
||||
app/views/consolidacao_entregas/revisar.html.erb | 74 +++++++
|
||||
app/views/consolidacao_entregas/validar.html.erb | 166 ++++++++++++++
|
||||
app/views/consolidacoes/index.html.erb | 65 ++++++
|
||||
app/views/consolidacoes/new.html.erb | 89 ++++++++
|
||||
app/views/consolidacoes/wizard.html.erb | 91 ++++++++
|
||||
app/views/layouts/application.html.erb | 216 ++++++-------------
|
||||
config/routes.rb | 82 ++++---
|
||||
config/schedule.rb | 12 ++
|
||||
...0260101000008_add_route_ids_to_consolidacoes.rb | 6 +
|
||||
db/seeds.rb | 101 +++------
|
||||
lib/tasks/historico.rake | 13 ++
|
||||
29 files changed, 1616 insertions(+), 615 deletions(-)
|
||||
b77fc01 Atualização README - Fase 2 e 3
|
||||
Projeto-Reem-Custo | 1 +
|
||||
README.md | 189 ++++++++++++++++++++++++++++++++++-------------------
|
||||
2 files changed, 124 insertions(+), 66 deletions(-)
|
||||
bd60e4c Atualizou o MD
|
||||
README.md | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
4724847 implantação da fase 2 e 3
|
||||
README_FASE2_3.md | 163 +++++
|
||||
app/controllers/application_controller.rb | 26 +-
|
||||
app/controllers/configuracoes_controller.rb | 44 ++
|
||||
app/controllers/dashboard_controller.rb | 77 +++
|
||||
app/controllers/motorista_controller.rb | 42 ++
|
||||
app/controllers/users/sessions_controller.rb | 56 ++
|
||||
app/controllers/usuarios_controller.rb | 88 +++
|
||||
app/helpers/application_helper.rb | 102 ++-
|
||||
app/models/auditoria_log.rb | 31 +-
|
||||
app/models/configuracao.rb | 78 +--
|
||||
app/models/consolidacao.rb | 83 +--
|
||||
app/models/entrega.rb | 89 +--
|
||||
app/models/user.rb | 76 +--
|
||||
app/policies/application_policy.rb | 41 +-
|
||||
app/policies/configuracao_policy.rb | 20 +
|
||||
app/policies/user_policy.rb | 46 ++
|
||||
app/views/configuracoes/edit.html.erb | 58 ++
|
||||
app/views/configuracoes/index.html.erb | 64 ++
|
||||
app/views/dashboard/index.html.erb | 234 +++++++
|
||||
app/views/devise/sessions/new.html.erb | 231 +++++++
|
||||
app/views/layouts/_sidebar.html.erb | 64 ++
|
||||
app/views/layouts/application.html.erb | 216 ++++---
|
||||
app/views/motorista/index.html.erb | 96 +++
|
||||
app/views/shared/_flash.html.erb | 18 +
|
||||
app/views/usuarios/_form.html.erb | 153 +++++
|
||||
app/views/usuarios/edit.html.erb | 2 +
|
||||
app/views/usuarios/index.html.erb | 120 ++++
|
||||
app/views/usuarios/new.html.erb | 2 +
|
||||
config/routes.rb | 76 ++-
|
||||
db/migrate/20260610_add_fase2_fields_to_users.rb | 25 +
|
||||
db/seeds.rb | 101 ++-
|
||||
prompt_sistema_logistica_final.html | 771 +++++++++++++++++++++++
|
||||
setup_fase2_3.sh | 54 ++
|
||||
33 files changed, 2916 insertions(+), 431 deletions(-)
|
||||
d37237e Alteração de alguns arquivos para retirar do yaml o container Postgres pois ja tem um
|
||||
.env.example | 24 +++---
|
||||
README.md | 210 +++++++++++++++++++++++++++++++++++++++--------------
|
||||
docker-compose.yml | 25 +------
|
||||
setup_git.sh | 13 ++--
|
||||
4 files changed, 175 insertions(+), 97 deletions(-)
|
||||
eb81286 Initial commit - Fase 1: Setup Rails + Docker
|
||||
.env.example | 43 ++++++++
|
||||
.gitignore | 61 +++++++++++
|
||||
Dockerfile | 29 ++++++
|
||||
Gemfile | 55 ++++++++++
|
||||
README.md | 113 +++++++++++++++++++++
|
||||
app/controllers/application_controller.rb | 27 +++++
|
||||
app/helpers/application_helper.rb | 46 +++++++++
|
||||
app/models/auditoria_log.rb | 29 ++++++
|
||||
app/models/configuracao.rb | 55 ++++++++++
|
||||
app/models/consolidacao.rb | 75 ++++++++++++++
|
||||
app/models/consolidacao_entrega.rb | 32 ++++++
|
||||
app/models/consolidacao_motorista.rb | 29 ++++++
|
||||
app/models/entrega.rb | 88 ++++++++++++++++
|
||||
app/models/historico_estimado.rb | 32 ++++++
|
||||
app/models/user.rb | 69 +++++++++++++
|
||||
app/policies/application_policy.rb | 30 ++++++
|
||||
app/views/layouts/_navbar.html.erb | 92 +++++++++++++++++
|
||||
app/views/layouts/application.html.erb | 95 +++++++++++++++++
|
||||
config/routes.rb | 50 +++++++++
|
||||
db/migrate/20260101000001_create_users.rb | 27 +++++
|
||||
db/migrate/20260101000002_create_configuracoes.rb | 14 +++
|
||||
db/migrate/20260101000003_create_consolidacoes.rb | 23 +++++
|
||||
...0260101000004_create_consolidacao_motoristas.rb | 17 ++++
|
||||
.../20260101000005_create_consolidacao_entregas.rb | 23 +++++
|
||||
.../20260101000006_create_historico_estimados.rb | 13 +++
|
||||
db/migrate/20260101000007_create_auditoria_logs.rb | 22 ++++
|
||||
db/seeds.rb | 47 +++++++++
|
||||
docker-compose.yml | 49 +++++++++
|
||||
setup_git.sh | 46 +++++++++
|
||||
tailwind.config.js | 59 +++++++++++
|
||||
30 files changed, 1390 insertions(+)
|
||||
BIN
reem-notas.zip
Normal file
BIN
reem-notas.zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user