1import{u as k,r as i,j as e,H as O,D as a,e as D,I as v,ax as b,aa as T,ab as z,ac as w,ad as C,ae as P,af as y,ag as I,O as A,Z as H,z as m,$ as x}from"./app-Dph3DIrv.js";import{E as B}from"./EmptyState-BpCmzwK9.js";import{C as F}from"./ConfirmDialog-Dp5iKLk9.js";import{P as K}from"./plus-B0JKOIZA.js";import{M as L}from"./map-pin-Bil1BHoI.js";import{T as M}from"./trash-2-Bl1ESl_R.js";/* empty css */function J(){const{origins:u,flash:h}=k().props,[E,t]=i.useState(!1),[r,g]=i.useState(""),[n,l]=i.useState(null),[j,p]=i.useState(""),[c,d]=i.useState(null),f=()=>{r.trim()&&m.post(x("crm.config.origens.store"),{name:r},{preserveScroll:!0,onSuccess:()=>{g(""),t(!1)}})},N=()=>{n&&m.put(x("crm.config.origens.update",n),{name:j},{preserveScroll:!0,onSuccess:()=>l(null)})},S=()=>{c&&m.delete(x("crm.config.origens.destroy",c),{onSuccess:()=>d(null)})};return e.jsxs(e.Fragment,{children:[e.jsx(O,{title:"Configurações - Origens"}),e.jsxs("div",{className:"p-4 md:p-6 space-y-4 md:space-y-6 animate-fade-in",children:[h?.error&&e.jsx("div",{className:"bg-destructive/10 border border-destructive/30 text-destructive rounded-md p-3 text-sm",children:h.error}),e.jsxs("div",{className:"flex items-center justify-between mb-4 md:mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-xl md:text-2xl font-bold",children:"Origens"}),e.jsx("p",{className:"text-xs md:text-sm text-muted-foreground mt-1",children:"Configure as origens disponÃveis para negócios e contatos."})]}),e.jsxs(a,{onClick:()=>t(!0),children:[e.jsx(K,{className:"w-4 h-4 mr-1"})," Nova Origem"]})]}),E&&e.jsx(D,{className:"p-4 mb-4 animate-scale-in",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(v,{value:r,onChange:s=>g(s.target.value),placeholder:"Nome da origem",className:"flex-1",onKeyDown:s=>s.key==="Enter"&&f(),autoFocus:!0}),e.jsx(a,{size:"sm",onClick:f,disabled:!r.trim(),children:"Salvar"}),e.jsx(a,{size:"sm",variant:"ghost",onClick:()=>t(!1),children:e.jsx(b,{className:"w-4 h-4"})})]})}),u.length===0?e.jsx(B,{icon:L,title:"Nenhuma origem",description:"Adicione origens para classificar de onde vieram seus negócios.",actionLabel:"Adicionar",onAction:()=>t(!0)}):e.jsx("div",{className:"rounded-lg border bg-card overflow-x-auto",children:e.jsxs(T,{children:[e.jsx(z,{children:e.jsxs(w,{children:[e.jsx(C,{children:"Origem"}),e.jsx(C,{className:"text-right",children:"Ações"})]})}),e.jsx(P,{children:u.map(s=>e.jsxs(w,{children:[e.jsx(y,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[n===s.id?e.jsx(v,{value:j,onChange:o=>p(o.target.value),className:"h-8",onKeyDown:o=>o.key==="Enter"&&N()}):e.jsx("span",{className:"font-medium text-sm",children:s.name}),s.isDefault&&e.jsx(I,{variant:"secondary",className:"text-xs",children:"Padrão"})]})}),e.jsx(y,{className:"text-right",children:n===s.id?e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(a,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:N,children:e.jsx(A,{className:"w-4 h-4 text-crm-success"})}),e.jsx(a,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>l(null),children:e.jsx(b,{className:"w-4 h-4"})})]}):e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(a,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>{l(s.id),p(s.name)},children:e.jsx(H,{className:"w-3.5 h-3.5"})}),e.jsx(a,{size:"icon",variant:"ghost",className:"h-7 w-7 text-destructive disabled:opacity-40",onClick:()=>d(s.id),disabled:s.isDefault,title:s.isDefault?"Origens padrão não podem ser excluÃdas":"Excluir origem",children:e.jsx(M,{className:"w-3.5 h-3.5"})})]})})]},s.id))})]})})]}),e.jsx(F,{open:!!c,onOpenChange:()=>d(null),title:"Excluir Origem",description:"Tem certeza que deseja excluir esta origem? Esta ação não pode ser desfeita.",confirmLabel:"Excluir",destructive:!0,onConfirm:S})]})}export{J as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.