const { Card, Button, Icon, IconButton, Input, Select, Modal, Badge, StatusPill, PriorityBadge, EmptyState, DataTable, StatCard, Textarea } = window.ACRFlowDesignSystem_ba1e9c; const slugify = (s) => s.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]+/g, "_").replace(/(^_|_$)/g, ""); const TONES = [ { value: "st-aberta", label: "Azul — recém aberta" }, { value: "st-triagem", label: "Roxo — triagem" }, { value: "st-andamento", label: "Verde — em execução" }, { value: "st-aguardando", label: "Âmbar — aguardando" }, { value: "st-aprovacao", label: "Índigo — aprovação" }, { value: "st-encerrada", label: "Cinza — encerrada" }, { value: "st-reaberta", label: "Vermelho — reaberta" }, ]; const PRIO_TONES = [{ value: "baixa", label: "Baixa" }, { value: "normal", label: "Normal" }, { value: "alta", label: "Alta" }, { value: "urgente", label: "Urgente" }]; function WorkflowScreen({ onToast }) { const D = window.useStore(); const S = window.ACRStore; const statuses = D.statuses || []; const priorities = D.priorities || []; const [salvando, setSalvando] = React.useState(false); const falhou = (r) => { if (!r.ok) { onToast({ tone: "danger", title: "Não foi possível gravar", message: r.error }); return true; } return false; }; const [statusForm, setStatusForm] = React.useState(null); const [prioForm, setPrioForm] = React.useState(null); const [remove, setRemove] = React.useState(null); const useCount = (kind, id) => D.demands.filter((d) => (kind === "status" ? d.status : d.priority) === id).length; const saveStatus = async () => { const f = statusForm; if (!f.name || !f.name.trim()) { onToast({ tone: "danger", title: "Informe o nome", message: "O nome do status é obrigatório." }); return; } setSalvando(true); const r = await S.salvarStatus({ ...f, existing: !!f.id }); setSalvando(false); if (falhou(r)) return; onToast({ tone: "success", title: f.id ? "Status atualizado" : "Status criado", message: f.name }); setStatusForm(null); }; const savePrio = async () => { const f = prioForm; if (!f.name || !f.name.trim()) { onToast({ tone: "danger", title: "Informe o nome", message: "O nome da prioridade é obrigatório." }); return; } setSalvando(true); const r = await S.salvarPrioridade({ ...f, existing: !!f.id }); setSalvando(false); if (falhou(r)) return; onToast({ tone: "success", title: f.id ? "Prioridade atualizada" : "Prioridade criada", message: f.name }); setPrioForm(null); }; const doRemove = async () => { setSalvando(true); const r = remove.kind === "status" ? await S.removerStatus(remove.item.id) : await S.removerPrioridade(remove.item.id); setSalvando(false); if (falhou(r)) return; onToast({ tone: "danger", title: remove.kind === "status" ? "Status removido" : "Prioridade removida", message: remove.item.name }); setRemove(null); }; return (

Prioridades e Status

Cadastro dos estados do ciclo de vida e dos níveis de prioridade usados em toda a operação.
} /> } /> s.system).length} icon={} />
Regra fixa do fluxo: ao ser atribuída, a demanda fica em Aguardando atendimento. Só passa para Em andamento na primeira interação do operacional — comentário, checklist, evidência ou anexo. Status marcados como "do sistema" não podem ser removidos porque sustentam essa regra e a aprovação do supervisor. } onClick={() => setStatusForm({ name: "", tone: "st-aguardando", help: "" })}>Novo status}> }, { key: "help", label: "Quando usar" }, { key: "system", label: "Tipo", width: 120, render: (r) => {r.system ? "Do sistema" : "Personalizado"} }, { key: "uso", label: "Demandas", width: 100, render: (r) => useCount("status", r.id) }, { key: "acoes", label: "", width: 92, render: (r) => ( } onClick={() => setStatusForm(r)} /> } disabled={r.system} onClick={() => setRemove({ kind: "status", item: r })} /> ) }, ]} /> } onClick={() => setPrioForm({ name: "", tone: "normal", sla: "" })}>Nova prioridade}> }, { key: "sla", label: "Prazo-alvo" }, { key: "system", label: "Tipo", width: 120, render: (r) => {r.system ? "Do sistema" : "Personalizada"} }, { key: "uso", label: "Demandas", width: 100, render: (r) => useCount("priority", r.id) }, { key: "acoes", label: "", width: 92, render: (r) => ( } onClick={() => setPrioForm(r)} /> } disabled={r.system} onClick={() => setRemove({ kind: "prioridade", item: r })} /> ) }, ]} /> {statusForm ? ( setStatusForm(null)} footer={<>}> setStatusForm({ ...statusForm, name: e.target.value })} />