import { useState, useEffect } from 'react'; import { Plus, X, Clock, DollarSign, Edit, Trash2, AlertTriangle } from 'lucide-react'; const categories = [ { id: '1', name: 'Cabelo', icon: '✂️' }, { id: '2', name: 'Barba', icon: '🧔' }, { id: '3', name: 'Combos', icon: '⭐' }, { id: '4', name: 'Manicure', icon: '💅' }, { id: '5', name: 'Massagem', icon: '💆' }, ]; interface Service { id: string; catId: string; name: string; desc: string; duration: number; price: number; active: boolean; } const initialServices: Service[] = [ { id: '1', catId: '1', name: 'Corte Masculino', desc: 'Corte moderno com lavagem e finalização', duration: 40, price: 55, active: true }, { id: '2', catId: '1', name: 'Corte Infantil', desc: 'Corte para crianças até 12 anos', duration: 30, price: 40, active: true }, { id: '3', catId: '2', name: 'Barba Completa', desc: 'Aparar, modelar e hidratação', duration: 30, price: 40, active: true }, { id: '4', catId: '2', name: 'Design de Sobrancelha', desc: 'Alinhamento com navalha', duration: 15, price: 25, active: true }, { id: '5', catId: '3', name: 'Combo Corte + Barba', desc: 'Corte masculino + barba completa', duration: 60, price: 85, active: true }, { id: '6', catId: '4', name: 'Manicure Completa', desc: 'Lixar, cuticular e esmaltação', duration: 45, price: 50, active: true }, { id: '7', catId: '4', name: 'Pedicure', desc: 'Tratamento completo para os pés', duration: 50, price: 55, active: true }, { id: '8', catId: '5', name: 'Massagem Relaxante', desc: 'Massagem corpo inteiro 60min', duration: 60, price: 120, active: true }, { id: '9', catId: '5', name: 'Quick Massage', desc: 'Massagem expressa 20min', duration: 20, price: 45, active: true }, ]; const emptyService: Service = { id: '', catId: '1', name: '', desc: '', duration: 30, price: 50, active: true }; export default function Services() { const [services, setServices] = useState(initialServices); const [showModal, setShowModal] = useState(false); const [selectedCat, setSelectedCat] = useState(null); const [editingService, setEditingService] = useState(null); const [formData, setFormData] = useState(emptyService); const [deleteConfirm, setDeleteConfirm] = useState(null); useEffect(() => { const savedName = localStorage.getItem('agendapro_tenant_name'); if (savedName) { setServices([ { id: '1', catId: '1', name: 'Corte de Cabelo (Exemplo)', desc: 'Corte padrão do estabelecimento', duration: 30, price: 40, active: true } ]); } }, []); const filtered = selectedCat ? services.filter(s => s.catId === selectedCat) : services; const openAdd = () => { setEditingService(null); setFormData({ ...emptyService, id: Date.now().toString() }); setShowModal(true); }; const openEdit = (svc: Service) => { setEditingService(svc); setFormData({ ...svc }); setShowModal(true); }; const handleSave = () => { if (!formData.name.trim()) return; if (editingService) { setServices(prev => prev.map(s => s.id === editingService.id ? { ...formData } : s)); } else { setServices(prev => [...prev, { ...formData }]); } setShowModal(false); setEditingService(null); }; const handleDelete = (id: string) => { setServices(prev => prev.filter(s => s.id !== id)); setDeleteConfirm(null); }; return (
{categories.filter(c => services.some(s => s.catId === c.id)).map(c => ( ))}
{filtered.map(svc => (
{deleteConfirm === svc.id && (

Excluir "{svc.name}"?

)}
{categories.find(c => c.id === svc.catId)?.icon}

{svc.name}

{svc.desc}

{svc.duration}min
R$ {svc.price.toFixed(2)}
))}
{filtered.length === 0 && (

Nenhum serviço encontrado

Adicione um serviço ou selecione outra categoria.

)} {showModal && (
setShowModal(false)}>
e.stopPropagation()}>

{editingService ? 'Editar Serviço' : 'Novo Serviço'}

setFormData(p => ({ ...p, name: e.target.value }))} />