// ServicesPage.jsx 'use strict'; const { useState, useEffect } = React; const SVC_CATS = ['Informática','Celular','Eletrônico','Geral','Outro']; const CAT_COLORS = { Informática:'#3B82F6', Celular:'#10B981', Eletrônico:'#F59E0B', Geral:'#6366F1', Outro:'#94A3B8' }; const CAT_ICONS = { Informática:'Laptop', Celular:'Smartphone', Eletrônico:'Tv', Geral:'Wrench', Outro:'Settings' }; function ServiceModal({ open, onClose, onSave, editSvc }) { const empty = { name:'', category:'Informática', description:'', basePrice:0, estimatedTime:60 }; const [form, setForm] = useState(empty); const [errors, setErrors] = useState({}); useEffect(()=>{ if(open){ setForm(editSvc?{...editSvc}:{...empty}); setErrors({}); } },[open,editSvc]); const set=(k,v)=>setForm(f=>({...f,[k]:v})); const validate=()=>{ const e={}; if(!form.name.trim())e.name='Nome obrigatório'; if(!form.basePrice)e.basePrice='Informe o valor'; setErrors(e); return Object.keys(e).length===0; }; const handleSave=()=>{ if(!validate())return; onSave(form); onClose(); }; return (
set('name',e.target.value)} placeholder="Ex: Formatação de PC" error={!!errors.name}/>
set('estimatedTime',+e.target.value)} placeholder="60"/>
set('basePrice',+e.target.value)} placeholder="0,00" error={!!errors.basePrice}/>