refactor: redesign planos interface with design system patterns
- Create CreatePlanModal component with Headless UI Dialog - Implement dark mode support throughout plans UI - Update plans/page.tsx with professional card layout - Update plans/[id]/page.tsx with consistent styling - Add proper spacing, typography, and color consistency - Implement smooth animations and transitions - Add success/error message feedback - Improve form UX with better input styling
This commit is contained in:
25
postgres/migrations/009_create_plans_table.sql
Normal file
25
postgres/migrations/009_create_plans_table.sql
Normal file
@@ -0,0 +1,25 @@
|
||||
-- Create plans table
|
||||
CREATE TABLE IF NOT EXISTS plans (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
name VARCHAR(255) NOT NULL,
|
||||
slug VARCHAR(100) NOT NULL UNIQUE,
|
||||
description TEXT,
|
||||
min_users INTEGER NOT NULL DEFAULT 1,
|
||||
max_users INTEGER NOT NULL DEFAULT 30, -- -1 means unlimited
|
||||
monthly_price NUMERIC(10, 2),
|
||||
annual_price NUMERIC(10, 2),
|
||||
features TEXT[] NOT NULL DEFAULT '{}',
|
||||
differentiators TEXT[] NOT NULL DEFAULT '{}',
|
||||
storage_gb INTEGER NOT NULL DEFAULT 1,
|
||||
is_active BOOLEAN NOT NULL DEFAULT true,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- Add indexes
|
||||
CREATE INDEX idx_plans_slug ON plans(slug);
|
||||
CREATE INDEX idx_plans_is_active ON plans(is_active);
|
||||
|
||||
-- Add comments
|
||||
COMMENT ON TABLE plans IS 'Subscription plans for agencies';
|
||||
COMMENT ON COLUMN plans.max_users IS '-1 means unlimited users';
|
||||
@@ -0,0 +1,24 @@
|
||||
-- Create agency_subscriptions table
|
||||
CREATE TABLE IF NOT EXISTS agency_subscriptions (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
agency_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
|
||||
plan_id UUID NOT NULL REFERENCES plans(id) ON DELETE RESTRICT,
|
||||
billing_type VARCHAR(20) NOT NULL DEFAULT 'monthly', -- monthly or annual
|
||||
current_users INTEGER NOT NULL DEFAULT 0,
|
||||
status VARCHAR(50) NOT NULL DEFAULT 'active', -- active, suspended, cancelled
|
||||
start_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
renewal_date TIMESTAMP NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE(agency_id) -- One active subscription per agency
|
||||
);
|
||||
|
||||
-- Add indexes
|
||||
CREATE INDEX idx_agency_subscriptions_agency_id ON agency_subscriptions(agency_id);
|
||||
CREATE INDEX idx_agency_subscriptions_plan_id ON agency_subscriptions(plan_id);
|
||||
CREATE INDEX idx_agency_subscriptions_status ON agency_subscriptions(status);
|
||||
|
||||
-- Add comments
|
||||
COMMENT ON TABLE agency_subscriptions IS 'Tracks agency subscription to plans';
|
||||
COMMENT ON COLUMN agency_subscriptions.billing_type IS 'Monthly or annual billing';
|
||||
COMMENT ON COLUMN agency_subscriptions.current_users IS 'Current count of users (collaborators + clients)';
|
||||
68
postgres/migrations/011_seed_default_plans.sql
Normal file
68
postgres/migrations/011_seed_default_plans.sql
Normal file
@@ -0,0 +1,68 @@
|
||||
-- Seed the default plans
|
||||
INSERT INTO plans (id, name, slug, description, min_users, max_users, monthly_price, annual_price, features, differentiators, storage_gb, is_active, created_at, updated_at)
|
||||
VALUES
|
||||
(
|
||||
gen_random_uuid(),
|
||||
'Ignição',
|
||||
'ignition',
|
||||
'Ideal para pequenas agências iniciantes',
|
||||
1,
|
||||
30,
|
||||
199.99,
|
||||
1919.90,
|
||||
ARRAY['CRM', 'ERP', 'Projetos', 'Helpdesk', 'Pagamentos', 'Contratos', 'Documentos'],
|
||||
ARRAY[]::text[],
|
||||
1,
|
||||
true,
|
||||
CURRENT_TIMESTAMP,
|
||||
CURRENT_TIMESTAMP
|
||||
),
|
||||
(
|
||||
gen_random_uuid(),
|
||||
'Órbita',
|
||||
'orbit',
|
||||
'Para agências em crescimento',
|
||||
31,
|
||||
100,
|
||||
399.99,
|
||||
3839.90,
|
||||
ARRAY['CRM', 'ERP', 'Projetos', 'Helpdesk', 'Pagamentos', 'Contratos', 'Documentos'],
|
||||
ARRAY['Suporte prioritário'],
|
||||
1,
|
||||
true,
|
||||
CURRENT_TIMESTAMP,
|
||||
CURRENT_TIMESTAMP
|
||||
),
|
||||
(
|
||||
gen_random_uuid(),
|
||||
'Cosmos',
|
||||
'cosmos',
|
||||
'Para agências consolidadas',
|
||||
101,
|
||||
300,
|
||||
799.99,
|
||||
7679.90,
|
||||
ARRAY['CRM', 'ERP', 'Projetos', 'Helpdesk', 'Pagamentos', 'Contratos', 'Documentos'],
|
||||
ARRAY['Gerente de conta dedicado', 'API integrações'],
|
||||
1,
|
||||
true,
|
||||
CURRENT_TIMESTAMP,
|
||||
CURRENT_TIMESTAMP
|
||||
),
|
||||
(
|
||||
gen_random_uuid(),
|
||||
'Enterprise',
|
||||
'enterprise',
|
||||
'Solução customizada para grandes agências',
|
||||
301,
|
||||
-1,
|
||||
NULL,
|
||||
NULL,
|
||||
ARRAY['CRM', 'ERP', 'Projetos', 'Helpdesk', 'Pagamentos', 'Contratos', 'Documentos'],
|
||||
ARRAY['Armazenamento customizado', 'Treinamento personalizado'],
|
||||
1,
|
||||
true,
|
||||
CURRENT_TIMESTAMP,
|
||||
CURRENT_TIMESTAMP
|
||||
)
|
||||
ON CONFLICT DO NOTHING;
|
||||
Reference in New Issue
Block a user