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:
371
front-end-dash.aggios.app/app/superadmin/plans/[id]/page.tsx
Normal file
371
front-end-dash.aggios.app/app/superadmin/plans/[id]/page.tsx
Normal file
@@ -0,0 +1,371 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useRouter, useParams } from 'next/navigation';
|
||||
import { ArrowLeftIcon, CheckCircleIcon } from '@heroicons/react/24/outline';
|
||||
|
||||
interface Plan {
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
description: string;
|
||||
min_users: number;
|
||||
max_users: number;
|
||||
monthly_price: number | null;
|
||||
annual_price: number | null;
|
||||
features: string[];
|
||||
differentiators: string[];
|
||||
storage_gb: number;
|
||||
is_active: boolean;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export default function EditPlanPage() {
|
||||
const router = useRouter();
|
||||
const params = useParams();
|
||||
const planId = params.id as string;
|
||||
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [success, setSuccess] = useState(false);
|
||||
const [plan, setPlan] = useState<Plan | null>(null);
|
||||
const [formData, setFormData] = useState<Partial<Plan>>({});
|
||||
|
||||
useEffect(() => {
|
||||
const token = localStorage.getItem('token');
|
||||
if (!token) {
|
||||
router.push('/login');
|
||||
return;
|
||||
}
|
||||
|
||||
fetchPlan();
|
||||
}, [planId, router]);
|
||||
|
||||
const fetchPlan = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const token = localStorage.getItem('token');
|
||||
const response = await fetch(`/api/admin/plans/${planId}`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Erro ao carregar plano');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
setPlan(data.plan);
|
||||
setFormData(data.plan);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Erro ao carregar plano');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
|
||||
const { name, value, type } = e.target;
|
||||
|
||||
if (type === 'checkbox') {
|
||||
setFormData(prev => ({
|
||||
...prev,
|
||||
[name]: (e.target as HTMLInputElement).checked,
|
||||
}));
|
||||
} else if (type === 'number') {
|
||||
setFormData(prev => ({
|
||||
...prev,
|
||||
[name]: value === '' ? null : parseFloat(value),
|
||||
}));
|
||||
} else {
|
||||
setFormData(prev => ({
|
||||
...prev,
|
||||
[name]: value,
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
const handleSave = async () => {
|
||||
try {
|
||||
setSaving(true);
|
||||
setError(null);
|
||||
setSuccess(false);
|
||||
|
||||
const token = localStorage.getItem('token');
|
||||
|
||||
// Parse features e differentiators
|
||||
const features = (formData.features as any)
|
||||
.split(',')
|
||||
.map((f: string) => f.trim())
|
||||
.filter((f: string) => f.length > 0);
|
||||
|
||||
const differentiators = (formData.differentiators as any)
|
||||
.split(',')
|
||||
.map((d: string) => d.trim())
|
||||
.filter((d: string) => d.length > 0);
|
||||
|
||||
const payload = {
|
||||
...formData,
|
||||
features,
|
||||
differentiators,
|
||||
};
|
||||
|
||||
const response = await fetch(`/api/admin/plans/${planId}`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
throw new Error(error.message || 'Erro ao atualizar plano');
|
||||
}
|
||||
|
||||
setSuccess(true);
|
||||
setTimeout(() => setSuccess(false), 3000);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Erro ao atualizar plano');
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-[400px]">
|
||||
<div className="text-center">
|
||||
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"></div>
|
||||
<p className="text-zinc-600 dark:text-zinc-400">Carregando plano...</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!plan) {
|
||||
return (
|
||||
<div className="text-center py-12">
|
||||
<p className="text-red-600 dark:text-red-400">Plano não encontrado</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* Header */}
|
||||
<div className="flex items-center gap-4">
|
||||
<button
|
||||
onClick={() => router.back()}
|
||||
className="p-2 hover:bg-zinc-100 dark:hover:bg-zinc-800 rounded-lg transition-colors"
|
||||
>
|
||||
<ArrowLeftIcon className="h-6 w-6 text-zinc-600 dark:text-zinc-400" />
|
||||
</button>
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold text-zinc-900 dark:text-white">Editar Plano</h1>
|
||||
<p className="mt-1 text-sm text-zinc-600 dark:text-zinc-400">{plan.name}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Success Message */}
|
||||
{success && (
|
||||
<div className="rounded-lg bg-emerald-50 dark:bg-emerald-900/20 p-4 border border-emerald-200 dark:border-emerald-800 flex items-center gap-3">
|
||||
<CheckCircleIcon className="h-5 w-5 text-emerald-600 dark:text-emerald-400 flex-shrink-0" />
|
||||
<p className="text-sm font-medium text-emerald-800 dark:text-emerald-400">Plano atualizado com sucesso!</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Error Message */}
|
||||
{error && (
|
||||
<div className="rounded-lg bg-red-50 dark:bg-red-900/20 p-4 border border-red-200 dark:border-red-800">
|
||||
<p className="text-sm font-medium text-red-800 dark:text-red-400">{error}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Form Card */}
|
||||
<div className="rounded-2xl border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-900 p-6 sm:p-8">
|
||||
<form className="space-y-6" onSubmit={(e) => { e.preventDefault(); handleSave(); }}>
|
||||
{/* Row 1: Nome e Slug */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div>
|
||||
<label className="block text-sm font-semibold text-zinc-900 dark:text-white mb-2">
|
||||
Nome do Plano
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
name="name"
|
||||
value={formData.name || ''}
|
||||
onChange={handleInputChange}
|
||||
className="w-full px-4 py-2.5 border border-zinc-300 dark:border-zinc-600 rounded-lg bg-white dark:bg-zinc-800 text-zinc-900 dark:text-white placeholder-zinc-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-semibold text-zinc-900 dark:text-white mb-2">
|
||||
Slug
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
name="slug"
|
||||
value={formData.slug || ''}
|
||||
onChange={handleInputChange}
|
||||
className="w-full px-4 py-2.5 border border-zinc-300 dark:border-zinc-600 rounded-lg bg-white dark:bg-zinc-800 text-zinc-900 dark:text-white placeholder-zinc-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Descrição */}
|
||||
<div>
|
||||
<label className="block text-sm font-semibold text-zinc-900 dark:text-white mb-2">
|
||||
Descrição
|
||||
</label>
|
||||
<textarea
|
||||
name="description"
|
||||
value={formData.description || ''}
|
||||
onChange={handleInputChange}
|
||||
rows={3}
|
||||
className="w-full px-4 py-2.5 border border-zinc-300 dark:border-zinc-600 rounded-lg bg-white dark:bg-zinc-800 text-zinc-900 dark:text-white placeholder-zinc-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all resize-none"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Row 2: Usuários */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div>
|
||||
<label className="block text-sm font-semibold text-zinc-900 dark:text-white mb-2">
|
||||
Mínimo de Usuários
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
name="min_users"
|
||||
value={formData.min_users || 1}
|
||||
onChange={handleInputChange}
|
||||
min="1"
|
||||
className="w-full px-4 py-2.5 border border-zinc-300 dark:border-zinc-600 rounded-lg bg-white dark:bg-zinc-800 text-zinc-900 dark:text-white placeholder-zinc-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-semibold text-zinc-900 dark:text-white mb-2">
|
||||
Máximo de Usuários (-1 = ilimitado)
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
name="max_users"
|
||||
value={formData.max_users || 30}
|
||||
onChange={handleInputChange}
|
||||
className="w-full px-4 py-2.5 border border-zinc-300 dark:border-zinc-600 rounded-lg bg-white dark:bg-zinc-800 text-zinc-900 dark:text-white placeholder-zinc-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Row 3: Preços */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div>
|
||||
<label className="block text-sm font-semibold text-zinc-900 dark:text-white mb-2">
|
||||
Preço Mensal (BRL)
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
name="monthly_price"
|
||||
value={formData.monthly_price || ''}
|
||||
onChange={handleInputChange}
|
||||
step="0.01"
|
||||
className="w-full px-4 py-2.5 border border-zinc-300 dark:border-zinc-600 rounded-lg bg-white dark:bg-zinc-800 text-zinc-900 dark:text-white placeholder-zinc-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-semibold text-zinc-900 dark:text-white mb-2">
|
||||
Preço Anual (BRL)
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
name="annual_price"
|
||||
value={formData.annual_price || ''}
|
||||
onChange={handleInputChange}
|
||||
step="0.01"
|
||||
className="w-full px-4 py-2.5 border border-zinc-300 dark:border-zinc-600 rounded-lg bg-white dark:bg-zinc-800 text-zinc-900 dark:text-white placeholder-zinc-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Armazenamento */}
|
||||
<div>
|
||||
<label className="block text-sm font-semibold text-zinc-900 dark:text-white mb-2">
|
||||
Armazenamento (GB)
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
name="storage_gb"
|
||||
value={formData.storage_gb || 1}
|
||||
onChange={handleInputChange}
|
||||
min="1"
|
||||
className="w-full px-4 py-2.5 border border-zinc-300 dark:border-zinc-600 rounded-lg bg-white dark:bg-zinc-800 text-zinc-900 dark:text-white placeholder-zinc-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Features */}
|
||||
<div>
|
||||
<label className="block text-sm font-semibold text-zinc-900 dark:text-white mb-2">
|
||||
Recursos <span className="text-xs font-normal text-zinc-500">(separados por vírgula)</span>
|
||||
</label>
|
||||
<textarea
|
||||
name="features"
|
||||
value={typeof formData.features === 'string' ? formData.features : (formData.features || []).join(', ')}
|
||||
onChange={handleInputChange}
|
||||
rows={3}
|
||||
className="w-full px-4 py-2.5 border border-zinc-300 dark:border-zinc-600 rounded-lg bg-white dark:bg-zinc-800 text-zinc-900 dark:text-white placeholder-zinc-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all resize-none"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Differentiators */}
|
||||
<div>
|
||||
<label className="block text-sm font-semibold text-zinc-900 dark:text-white mb-2">
|
||||
Diferenciais <span className="text-xs font-normal text-zinc-500">(separados por vírgula)</span>
|
||||
</label>
|
||||
<textarea
|
||||
name="differentiators"
|
||||
value={typeof formData.differentiators === 'string' ? formData.differentiators : (formData.differentiators || []).join(', ')}
|
||||
onChange={handleInputChange}
|
||||
rows={3}
|
||||
className="w-full px-4 py-2.5 border border-zinc-300 dark:border-zinc-600 rounded-lg bg-white dark:bg-zinc-800 text-zinc-900 dark:text-white placeholder-zinc-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all resize-none"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Status Checkbox */}
|
||||
<div className="pt-4 border-t border-zinc-200 dark:border-zinc-800">
|
||||
<label className="flex items-center gap-3">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="is_active"
|
||||
checked={formData.is_active || false}
|
||||
onChange={handleInputChange}
|
||||
className="h-5 w-5 rounded border-zinc-300 dark:border-zinc-600 text-blue-600 focus:ring-blue-500 dark:bg-zinc-800 cursor-pointer"
|
||||
/>
|
||||
<span className="text-sm font-semibold text-zinc-900 dark:text-white">Plano Ativo</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{/* Buttons */}
|
||||
<div className="flex gap-3 pt-6 border-t border-zinc-200 dark:border-zinc-800">
|
||||
<button
|
||||
type="submit"
|
||||
disabled={saving}
|
||||
className="flex-1 px-6 py-3 bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 disabled:cursor-not-allowed text-white font-semibold rounded-lg transition-colors"
|
||||
>
|
||||
{saving ? 'Salvando...' : 'Salvar Alterações'}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => router.back()}
|
||||
disabled={saving}
|
||||
className="flex-1 px-6 py-3 border border-zinc-300 dark:border-zinc-600 text-zinc-700 dark:text-zinc-300 font-semibold rounded-lg hover:bg-zinc-50 dark:hover:bg-zinc-800 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
||||
>
|
||||
Cancelar
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
271
front-end-dash.aggios.app/app/superadmin/plans/page.tsx
Normal file
271
front-end-dash.aggios.app/app/superadmin/plans/page.tsx
Normal file
@@ -0,0 +1,271 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import { PencilIcon, TrashIcon, PlusIcon } from '@heroicons/react/24/outline';
|
||||
import CreatePlanModal from '@/components/plans/CreatePlanModal';
|
||||
|
||||
export default function PlansPage() {
|
||||
const [plans, setPlans] = useState<any[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState('');
|
||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
fetchPlans();
|
||||
}, []);
|
||||
|
||||
const fetchPlans = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const token = localStorage.getItem('token');
|
||||
const response = await fetch('/api/admin/plans', {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Erro ao carregar planos');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
setPlans(data.plans || []);
|
||||
setError('');
|
||||
} catch (err: any) {
|
||||
setError(err.message);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeletePlan = async (id: string) => {
|
||||
if (!confirm('Tem certeza que deseja deletar este plano? Esta ação não pode ser desfeita.')) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const token = localStorage.getItem('token');
|
||||
const response = await fetch(`/api/admin/plans/${id}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Erro ao deletar plano');
|
||||
}
|
||||
|
||||
fetchPlans();
|
||||
} catch (err: any) {
|
||||
setError(err.message);
|
||||
}
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-[400px]">
|
||||
<div className="text-center">
|
||||
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"></div>
|
||||
<p className="text-zinc-600 dark:text-zinc-400">Carregando planos...</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* Header */}
|
||||
<div className="flex justify-between items-center">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold text-zinc-900 dark:text-white">Planos</h1>
|
||||
<p className="mt-2 text-sm text-zinc-600 dark:text-zinc-400">
|
||||
Gerencie os planos de assinatura disponíveis para as agências
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => setIsModalOpen(true)}
|
||||
className="inline-flex items-center gap-2 px-4 py-2.5 bg-blue-600 hover:bg-blue-700 text-white font-semibold rounded-lg transition-colors shadow-sm"
|
||||
>
|
||||
<PlusIcon className="h-5 w-5" />
|
||||
Novo Plano
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Error Message */}
|
||||
{error && (
|
||||
<div className="rounded-lg bg-red-50 dark:bg-red-900/20 p-4 border border-red-200 dark:border-red-800">
|
||||
<p className="text-sm font-medium text-red-800 dark:text-red-400">{error}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Plans Grid */}
|
||||
{plans.length > 0 ? (
|
||||
<div className="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3">
|
||||
{plans.map((plan) => (
|
||||
<div
|
||||
key={plan.id}
|
||||
className="group rounded-2xl border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-900 hover:shadow-lg dark:hover:shadow-2xl transition-all duration-200 overflow-hidden"
|
||||
>
|
||||
{/* Header */}
|
||||
<div className="px-6 pt-6 pb-4 border-b border-zinc-100 dark:border-zinc-800">
|
||||
<div className="flex items-start justify-between mb-2">
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold text-zinc-900 dark:text-white">
|
||||
{plan.name}
|
||||
</h3>
|
||||
{!plan.is_active && (
|
||||
<span className="inline-block mt-2 px-2 py-1 rounded-full text-xs font-semibold bg-zinc-100 dark:bg-zinc-800 text-zinc-600 dark:text-zinc-400">
|
||||
Inativo
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{plan.is_active && (
|
||||
<span className="px-2.5 py-1 rounded-full text-xs font-semibold bg-emerald-100 dark:bg-emerald-900/30 text-emerald-700 dark:text-emerald-400">
|
||||
Ativo
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{plan.description && (
|
||||
<p className="text-sm text-zinc-600 dark:text-zinc-400 line-clamp-2">
|
||||
{plan.description}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Content */}
|
||||
<div className="px-6 py-4 space-y-4">
|
||||
{/* Pricing */}
|
||||
<div className="space-y-2">
|
||||
{plan.monthly_price && (
|
||||
<div className="flex justify-between items-center">
|
||||
<span className="text-sm text-zinc-600 dark:text-zinc-400">Mensal</span>
|
||||
<span className="text-2xl font-bold text-zinc-900 dark:text-white">
|
||||
R$ <span className="text-xl">{parseFloat(plan.monthly_price).toFixed(2)}</span>
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{plan.annual_price && (
|
||||
<div className="flex justify-between items-center">
|
||||
<span className="text-sm text-zinc-600 dark:text-zinc-400">Anual</span>
|
||||
<span className="text-2xl font-bold text-zinc-900 dark:text-white">
|
||||
R$ <span className="text-xl">{parseFloat(plan.annual_price).toFixed(2)}</span>
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Stats */}
|
||||
<div className="grid grid-cols-2 gap-3 pt-2 border-t border-zinc-100 dark:border-zinc-800">
|
||||
<div className="p-3 bg-zinc-50 dark:bg-zinc-800 rounded-lg">
|
||||
<p className="text-xs text-zinc-600 dark:text-zinc-400 mb-1">Usuários</p>
|
||||
<p className="text-sm font-semibold text-zinc-900 dark:text-white">
|
||||
{plan.min_users} - {plan.max_users === -1 ? '∞' : plan.max_users}
|
||||
</p>
|
||||
</div>
|
||||
<div className="p-3 bg-zinc-50 dark:bg-zinc-800 rounded-lg">
|
||||
<p className="text-xs text-zinc-600 dark:text-zinc-400 mb-1">Armazenamento</p>
|
||||
<p className="text-sm font-semibold text-zinc-900 dark:text-white">
|
||||
{plan.storage_gb} GB
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Features */}
|
||||
{plan.features && plan.features.length > 0 && (
|
||||
<div className="pt-2">
|
||||
<p className="text-xs font-semibold text-zinc-700 dark:text-zinc-300 uppercase tracking-wide mb-2">
|
||||
Recursos
|
||||
</p>
|
||||
<ul className="space-y-1">
|
||||
{plan.features.slice(0, 4).map((feature: string, idx: number) => (
|
||||
<li key={idx} className="text-xs text-zinc-600 dark:text-zinc-400 flex items-center gap-2">
|
||||
<span className="inline-block h-1.5 w-1.5 bg-blue-600 rounded-full"></span>
|
||||
{feature}
|
||||
</li>
|
||||
))}
|
||||
{plan.features.length > 4 && (
|
||||
<li className="text-xs text-zinc-600 dark:text-zinc-400 italic">
|
||||
+{plan.features.length - 4} mais
|
||||
</li>
|
||||
)}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Differentiators */}
|
||||
{plan.differentiators && plan.differentiators.length > 0 && (
|
||||
<div className="pt-2">
|
||||
<p className="text-xs font-semibold text-zinc-700 dark:text-zinc-300 uppercase tracking-wide mb-2">
|
||||
Diferenciais
|
||||
</p>
|
||||
<ul className="space-y-1">
|
||||
{plan.differentiators.slice(0, 2).map((diff: string, idx: number) => (
|
||||
<li key={idx} className="text-xs text-zinc-600 dark:text-zinc-400 flex items-center gap-2">
|
||||
<span className="inline-block h-1.5 w-1.5 bg-emerald-600 rounded-full"></span>
|
||||
{diff}
|
||||
</li>
|
||||
))}
|
||||
{plan.differentiators.length > 2 && (
|
||||
<li className="text-xs text-zinc-600 dark:text-zinc-400 italic">
|
||||
+{plan.differentiators.length - 2} mais
|
||||
</li>
|
||||
)}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
<div className="px-6 py-4 bg-zinc-50 dark:bg-zinc-800/50 border-t border-zinc-100 dark:border-zinc-800 flex gap-2">
|
||||
<a
|
||||
href={`/superadmin/plans/${plan.id}`}
|
||||
className="flex-1 inline-flex items-center justify-center gap-2 px-3 py-2 bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400 hover:bg-blue-200 dark:hover:bg-blue-900/50 font-medium rounded-lg transition-colors text-sm"
|
||||
>
|
||||
<PencilIcon className="h-4 w-4" />
|
||||
Editar
|
||||
</a>
|
||||
<button
|
||||
onClick={() => handleDeletePlan(plan.id)}
|
||||
className="flex-1 inline-flex items-center justify-center gap-2 px-3 py-2 bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-400 hover:bg-red-200 dark:hover:bg-red-900/50 font-medium rounded-lg transition-colors text-sm"
|
||||
>
|
||||
<TrashIcon className="h-4 w-4" />
|
||||
Deletar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-center py-12">
|
||||
<div className="text-zinc-400 dark:text-zinc-600 mb-2">
|
||||
<svg
|
||||
className="h-12 w-12 mx-auto"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth={1.5}
|
||||
d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<p className="text-zinc-600 dark:text-zinc-400 text-lg font-medium">Nenhum plano criado</p>
|
||||
<p className="text-zinc-500 dark:text-zinc-500 text-sm">Clique no botão acima para criar o primeiro plano</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Create Plan Modal */}
|
||||
<CreatePlanModal
|
||||
isOpen={isModalOpen}
|
||||
onClose={() => setIsModalOpen(false)}
|
||||
onSuccess={() => {
|
||||
fetchPlans();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user