1import{r as n,j as e,B as t,L as d,C as u,b as N,T as y,ad as i}from"./index-D_pMiXlB.js";import{B as h}from"./badge-BDdOWxy6.js";import{b as c}from"./api-B1VRpR6w.js";import{M as b}from"./mail-BW5J0Dsq.js";import{Z as w}from"./zap-BnKveZlT.js";import{S as C}from"./square-pen-v5Zw6K5k.js";import{C as E}from"./copy-WkWhUXW4.js";import"./AdminLayout-Nt9XMtqW.js";import"./use-mobile-Bt3U17SH.js";import"./index-BZhZv-t1.js";import"./index-D4rMeGL5.js";import"./logo-edgar-white-Coz_BF94.js";import"./log-out-DfJMDBlQ.js";import"./users-B5JwvErv.js";import"./crown-ZOK1foEJ.js";import"./trophy-DhlLtMRq.js";import"./graduation-cap-Cj0QIP7n.js";import"./trending-up-CRriUHyq.js";import"./message-square-DF_2lToo.js";import"./video-DzGeFZHa.js";import"./chart-column-Bln0vWvO.js";import"./settings-C0up_N7q.js";import"./Seo-6rmTet4a.js";import"./download-D4gU19kp.js";import"./refresh-cw-Dsz7OpFN.js";import"./lock-Cwj-44ie.js";function X(){const[o,j]=n.useState([]),[f,p]=n.useState(!0),[x,r]=n.useState(null),m=async()=>{p(!0);try{const s=await c("list");j(s.templates||[])}catch(s){i({title:"Error",description:s.message,variant:"destructive"})}finally{p(!1)}};n.useEffect(()=>{m()},[]);const g=async s=>{r(s);try{await c("duplicate",{id:s}),i({title:"Plantilla duplicada"}),m()}catch(a){i({title:"Error",description:a.message,variant:"destructive"})}finally{r(null)}},v=async(s,a)=>{if(confirm(`¿Eliminar plantilla "${a}"?`)){r(s);try{await c("delete",{id:s}),i({title:"Plantilla eliminada"}),m()}catch(l){i({title:"Error",description:l.message,variant:"destructive"})}finally{r(null)}}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold",children:"Plantillas de correo"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Reutilizá correos prediseñados al mandar pedidos. Usá ",e.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"{{variables}}"})," que se reemplazan automáticamente."]})]}),e.jsx(t,{asChild:!0,children:e.jsxs(d,{to:"/admin/panel/tienda/plantillas/nueva",children:[e.jsx(u,{className:"w-4 h-4 mr-1"})," Nueva plantilla"]})})]}),f?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(N,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):o.length===0?e.jsxs("div",{className:"text-center py-16 border-2 border-dashed rounded-lg",children:[e.jsx(b,{className:"w-10 h-10 text-muted-foreground mx-auto mb-3"}),e.jsx("p",{className:"font-medium",children:"Sin plantillas todavÃa"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Creá tu primera plantilla para no escribir el mismo correo cada vez."}),e.jsx(t,{asChild:!0,children:e.jsxs(d,{to:"/admin/panel/tienda/plantillas/nueva",children:[e.jsx(u,{className:"w-4 h-4 mr-1"})," Crear plantilla"]})})]}):e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-3",children:o.map(s=>{var a;return e.jsxs("div",{className:"border rounded-lg p-4 bg-card flex flex-col gap-3 hover:border-primary/50 transition",children:[e.jsx("div",{className:"flex items-start justify-between gap-2",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[s.category==="auto_payment"&&e.jsxs(h,{variant:"outline",className:"text-[10px] border-primary/40 text-primary",children:[e.jsx(w,{className:"w-2.5 h-2.5 mr-0.5"})," Auto al pagar"]}),!s.active&&e.jsx(h,{variant:"outline",className:"text-[10px]",children:"Inactiva"})]}),e.jsx("h3",{className:"font-semibold truncate",children:s.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:s.subject})]})}),s.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),((a=s.custom_fields)==null?void 0:a.length)>0&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.custom_fields.slice(0,3).map(l=>e.jsx("code",{className:"text-[10px] bg-muted px-1.5 py-0.5 rounded",children:`{{${l.key}}}`},l.key)),s.custom_fields.length>3&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",s.custom_fields.length-3," más"]})]}),e.jsxs("div",{className:"flex items-center gap-1 mt-auto pt-2 border-t",children:[e.jsx(t,{asChild:!0,size:"sm",variant:"ghost",className:"flex-1 h-8",children:e.jsxs(d,{to:`/admin/panel/tienda/plantillas/${s.id}`,children:[e.jsx(C,{className:"w-3.5 h-3.5 mr-1"})," Editar"]})}),e.jsx(t,{size:"sm",variant:"ghost",className:"h-8 px-2",onClick:()=>g(s.id),disabled:x===s.id,title:"Duplicar",children:e.jsx(E,{className:"w-3.5 h-3.5"})}),e.jsx(t,{size:"sm",variant:"ghost",className:"h-8 px-2 text-destructive hover:text-destructive",onClick:()=>v(s.id,s.name),disabled:x===s.id,title:"Eliminar",children:e.jsx(y,{className:"w-3.5 h-3.5"})})]})]},s.id)})})]})}export{X 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.