feat: redesign superadmin agencies list, implement flat design, add date filters, and fix UI bugs
This commit is contained in:
3
postgres/migrations/000_create_superadmin.sql
Normal file
3
postgres/migrations/000_create_superadmin.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
INSERT INTO users (id, email, password_hash, role, is_active, created_at, updated_at)
|
||||
VALUES (gen_random_uuid(), 'admin@aggios.app', '\\\', 'SUPERADMIN', true, NOW(), NOW())
|
||||
ON CONFLICT (email) DO UPDATE SET password_hash = '\\\';
|
||||
1
postgres/migrations/001_fix_password_utility.sql
Normal file
1
postgres/migrations/001_fix_password_utility.sql
Normal file
@@ -0,0 +1 @@
|
||||
UPDATE users SET password_hash = '$2a$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy' WHERE email = 'aggio@aggios.app';
|
||||
6
postgres/migrations/002_add_branding_columns.sql
Normal file
6
postgres/migrations/002_add_branding_columns.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
-- Add branding/customization columns to tenants table
|
||||
ALTER TABLE tenants
|
||||
ADD COLUMN IF NOT EXISTS primary_color VARCHAR(7),
|
||||
ADD COLUMN IF NOT EXISTS secondary_color VARCHAR(7),
|
||||
ADD COLUMN IF NOT EXISTS logo_url TEXT,
|
||||
ADD COLUMN IF NOT EXISTS logo_horizontal_url TEXT;
|
||||
@@ -0,0 +1,6 @@
|
||||
-- Add structured address and team size fields to tenants
|
||||
ALTER TABLE tenants
|
||||
ADD COLUMN IF NOT EXISTS neighborhood TEXT,
|
||||
ADD COLUMN IF NOT EXISTS number TEXT,
|
||||
ADD COLUMN IF NOT EXISTS complement TEXT,
|
||||
ADD COLUMN IF NOT EXISTS team_size TEXT;
|
||||
69
postgres/migrations/007_create_signup_templates.sql
Normal file
69
postgres/migrations/007_create_signup_templates.sql
Normal file
@@ -0,0 +1,69 @@
|
||||
-- Migration: Create signup_templates table
|
||||
-- Descrição: Tabela para armazenar templates personalizados de cadastro
|
||||
|
||||
CREATE TABLE IF NOT EXISTS signup_templates (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
name VARCHAR(255) NOT NULL,
|
||||
description TEXT,
|
||||
slug VARCHAR(100) UNIQUE NOT NULL,
|
||||
|
||||
-- Campos do formulário (JSON com array de campos)
|
||||
form_fields JSONB NOT NULL DEFAULT '[]'::jsonb,
|
||||
|
||||
-- Módulos habilitados (JSON com array de módulos)
|
||||
enabled_modules JSONB NOT NULL DEFAULT '[]'::jsonb,
|
||||
|
||||
-- Configurações adicionais
|
||||
redirect_url VARCHAR(500),
|
||||
success_message TEXT,
|
||||
|
||||
-- Branding
|
||||
custom_logo_url VARCHAR(500),
|
||||
custom_primary_color VARCHAR(20),
|
||||
|
||||
-- Controle
|
||||
is_active BOOLEAN DEFAULT true,
|
||||
usage_count INTEGER DEFAULT 0,
|
||||
|
||||
-- Auditoria
|
||||
created_by UUID REFERENCES users(id),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- Índices para performance
|
||||
CREATE INDEX idx_signup_templates_slug ON signup_templates(slug);
|
||||
CREATE INDEX idx_signup_templates_is_active ON signup_templates(is_active);
|
||||
CREATE INDEX idx_signup_templates_created_by ON signup_templates(created_by);
|
||||
|
||||
-- Comentários
|
||||
COMMENT ON TABLE signup_templates IS 'Templates personalizados para links de cadastro';
|
||||
COMMENT ON COLUMN signup_templates.form_fields IS 'Array JSON com campos do formulário: [{"name": "email", "required": true, "type": "email"}]';
|
||||
COMMENT ON COLUMN signup_templates.enabled_modules IS 'Array JSON com módulos habilitados: ["CRM", "ERP", "PROJECTS"]';
|
||||
COMMENT ON COLUMN signup_templates.slug IS 'Slug único usado na URL: aggios.app/cadastro/{slug}';
|
||||
|
||||
-- Trigger para atualizar updated_at
|
||||
CREATE OR REPLACE FUNCTION update_signup_templates_updated_at()
|
||||
RETURNS TRIGGER AS $$
|
||||
BEGIN
|
||||
NEW.updated_at = CURRENT_TIMESTAMP;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE TRIGGER trigger_update_signup_templates_updated_at
|
||||
BEFORE UPDATE ON signup_templates
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION update_signup_templates_updated_at();
|
||||
|
||||
-- Template padrão (exemplo)
|
||||
INSERT INTO signup_templates (name, description, slug, form_fields, enabled_modules) VALUES
|
||||
('Cadastro Rápido CRM', 'Template simplificado apenas com CRM', 'crm-rapido',
|
||||
'[
|
||||
{"name": "email", "label": "E-mail", "type": "email", "required": true, "order": 1},
|
||||
{"name": "password", "label": "Senha", "type": "password", "required": true, "order": 2},
|
||||
{"name": "subdomain", "label": "Subdomínio", "type": "text", "required": true, "order": 3},
|
||||
{"name": "company_name", "label": "Nome da Empresa", "type": "text", "required": false, "order": 4}
|
||||
]'::jsonb,
|
||||
'["CRM"]'::jsonb
|
||||
);
|
||||
38
postgres/migrations/008_create_agency_signup_templates.sql
Normal file
38
postgres/migrations/008_create_agency_signup_templates.sql
Normal file
@@ -0,0 +1,38 @@
|
||||
-- Agency Signup Templates (SuperAdmin → Agencies)
|
||||
CREATE TABLE IF NOT EXISTS agency_signup_templates (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
name VARCHAR(255) NOT NULL,
|
||||
slug VARCHAR(100) UNIQUE NOT NULL,
|
||||
description TEXT,
|
||||
|
||||
-- Campos do formulário (JSONB com campos habilitados/desabilitados)
|
||||
form_fields JSONB NOT NULL DEFAULT '[]',
|
||||
|
||||
-- Módulos disponíveis para a agência
|
||||
available_modules JSONB NOT NULL DEFAULT '[]',
|
||||
|
||||
-- Personalização
|
||||
custom_primary_color VARCHAR(7),
|
||||
custom_logo_url TEXT,
|
||||
|
||||
-- Redirecionamento após cadastro
|
||||
redirect_url TEXT,
|
||||
success_message TEXT,
|
||||
|
||||
-- Controle
|
||||
is_active BOOLEAN DEFAULT true,
|
||||
usage_count INTEGER DEFAULT 0,
|
||||
max_uses INTEGER,
|
||||
expires_at TIMESTAMP WITH TIME ZONE,
|
||||
|
||||
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- Index para busca rápida por slug
|
||||
CREATE INDEX idx_agency_templates_slug ON agency_signup_templates(slug);
|
||||
CREATE INDEX idx_agency_templates_active ON agency_signup_templates(is_active);
|
||||
|
||||
COMMENT ON TABLE agency_signup_templates IS 'Templates de cadastro de agências (SuperAdmin → Agências)';
|
||||
COMMENT ON COLUMN agency_signup_templates.form_fields IS 'Campos do formulário em JSONB: [{"name": "cnpj", "required": true, "enabled": true}]';
|
||||
COMMENT ON COLUMN agency_signup_templates.available_modules IS 'Módulos disponíveis: ["CRM", "Financial", "Projects"]';
|
||||
Reference in New Issue
Block a user