PageSourceSearch

https://alinhafood.com.br/_next/static/chunks/25664.ce67c75e8090a1f2.js

js alinhafood.com.br collected 2026-10-02 01:19:29 UTC 29,655 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[25664],{3283:(e,t,s)=>{s.r(t),s.d(t,{default:()=>q});var l=s(95155),a=s(12115),r=s(35626),c=s(89559),n=s(60952),d=s(26921),i=s(25664),o=s(91169),x=s(45345),m=s(6191),u=s(61362),p=s(78874),b=s(31716),h=s(64347),j=s(18514),f=s(71360),v=s(24033),N=s(27937),g=s(65229),y=s(34527),_=s(78384),k=s(67592),w=s(1790);let A={id:"",code:"",discount_pct:10,valid_from:"",valid_until:"",active:!0,first_order_only:!1};function C(e){return e.toLocaleString("pt-BR",{style:"currency",currency:"BRL"})}function z(e){return e?new Date(e).toLocaleDateString("pt-BR"):"—"}function S(e){return new Date(e).toLocaleString("pt-BR",{dateStyle:"short",timeStyle:"short"})}function D(e){return!!e.valid_until&&new Date(e.valid_until)<new Date}let E={pending:{label:"Pendente",cls:"bg-yellow-100 text-yellow-700"},confirmed:{label:"Confirmado",cls:"bg-blue-100 text-blue-700"},preparing:{label:"Preparando",cls:"bg-orange-100 text-orange-700"},ready:{label:"Pronto",cls:"bg-purple-100 text-purple-700"},delivered:{label:"Entregue",cls:"bg-emerald-100 text-emerald-700"},cancelled:{label:"Cancelado",cls:"bg-red-100 text-red-600"}};function q(){var e,t,s,q,P,R;let{restaurantId:V}=(0,_.p)(),{showToast:I}=(0,k.d)(),[B,U]=(0,a.useState)([]),[F,L]=(0,a.useState)(null),[O,T]=(0,a.useState)(!0),[G,M]=(0,a.useState)(!1),[H,J]=(0,a.useState)(A),[W,K]=(0,a.useState)(!1),[Q,X]=(0,a.useState)(""),[Y,Z]=(0,a.useState)(null),[$,ee]=(0,a.useState)(null),[et,es]=(0,a.useState)(null),el=(0,a.useCallback)(async()=>{if(V){T(!0);try{let e=(()=>{let e=localStorage.getItem("alinhafood-admin-auth")||localStorage.getItem("alinhafood-public-auth");if(!e)return"";try{var t;let s=JSON.parse(e);return Array.isArray(s)?s[0]:(null==s?void 0:s.access_token)||(null==s||null==(t=s.session)?void 0:t.access_token)||""}catch(e){return""}})(),t=await fetch("/api/admin/coupons?restaurant_id=".concat(V),{headers:{Authorization:"Bearer ".concat(e)}}),s=await t.json();s.coupons&&U(s.coupons),s.summary&&L(s.summary)}catch(e){}T(!1)}},[V]);(0,a.useEffect)(()=>{el()},[el]),(0,a.useEffect)(()=>{if(!$)return;let e=B.find(e=>e.id===$.id);e&&ee(e)},[B]);let ea=()=>{J(A),X(""),M(!0)},er=e=>{var t,s,l,a;J({id:e.id,code:e.code,discount_pct:e.discount_pct,active:e.active,first_order_only:!!e.first_order_only,valid_from:null!=(l=null==(t=e.valid_from)?void 0:t.slice(0,10))?l:"",valid_until:null!=(a=null==(s=e.valid_until)?void 0:s.slice(0,10))?a:""}),X(""),M(!0)},ec=async e=>{if(e.preventDefault(),!H.code.trim()||H.discount_pct<=0||H.discount_pct>100)return void X("C\xf3digo inv\xe1lido ou desconto fora do intervalo (1–100%).");K(!0);let{error:t}=await (0,y.Gk)({...H.id?{id:H.id}:{},code:H.code.trim().toUpperCase(),discount_pct:Number(H.discount_pct),valid_from:H.valid_from||void 0,valid_until:H.valid_until||void 0,active:H.active,first_order_only:H.first_order_only,restaurant_id:null!=V?V:void 0},null!=V?V:void 0);if(K(!1),t){var s;X(null!=(s=null==t?void 0:t.message)?s:"Erro ao salvar");return}I(H.id?"Cupom atualizado!":"Cupom criado!","success"),M(!1),el()},en=async()=>{if(!Y||!V)return;let{error:e}=await (0,y.W_)(Y,V);if(e){var t;I(null!=(t=e.message)?t:"Erro ao excluir cupom.","error");return}I("Cupom exclu\xeddo.","success"),Z(null),el()},ed=async e=>{await (0,y.Gk)({id:e.id,code:e.code,discount_pct:e.discount_pct,active:!e.active,restaurant_id:null!=V?V:void 0},null!=V?V:void 0),el()};if($)return(0,l.jsxs)("div",{className:"space-y-6 p-6 max-md:space-y-4 max-md:p-3",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsxs)("button",{onClick:()=>ee(null),className:"flex items-center gap-2 text-sm font-bold text-slate-500 hover:text-slate-800 transition-colors cursor-pointer",children:[(0,l.jsx)(r.A,{size:16})," Voltar"]}),(0,l.jsx)("span",{className:"text-slate-300",children:"/"}),(0,l.jsxs)("span",{className:"text-sm font-black text-slate-800",children:["Cupom ",(0,l.jsx)("span",{className:"text-blue-600",children:$.code})]})]}),(0,l.jsxs)("button",{onClick:el,title:"Atualizar dados",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-xl border border-slate-200 text-slate-500 hover:bg-slate-50 transition-colors cursor-pointer text-xs font-bold",children:[(0,l.jsx)(c.A,{size:13,className:O?"animate-spin":""})," Atualizar"]})]}),(0,l.jsx)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[{label:"Usos",value:$.use_count.toString(),icon:n.A,color:"blue"},{label:"Desconto Total",value:C($.total_discount),icon:d.A,color:"red"},{label:"Receita Gerada",value:C($.total_revenue),icon:i.A,color:"emerald"},{label:"Clientes \xdanicos",value:$.unique_customers.toString(),icon:o.A,color:"purple"}].map(e=>{let{label:t,value:s,icon:a,color:r}=e;return(0,l.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200 p-5 shadow-sm max-md:p-3",children:[(0,l.jsx)("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl mb-3 bg-".concat(r,"-50 max-md:hidden"),children:(0,l.jsx)(a,{size:18,className:"text-".concat(r,"-600")})}),(0,l.jsx)("p",{className:"text-2xl font-black text-slate-800 max-md:text-xl",children:s}),(0,l.jsx)("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-widest mt-0.5 max-md:text-[0.75rem] max-md:normal-case max-md:tracking-normal",children:t})]},t)})}),(0,l.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200 shadow-sm p-6 max-md:p-4",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-blue-50",children:(0,l.jsx)(x.A,{size:18,className:"text-blue-600"})}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"font-black text-slate-800 text-lg tracking-wider",children:$.code}),(0,l.jsxs)("p",{className:"text-sm text-slate-500",children:[$.discount_pct,"% de desconto",$.first_order_only&&" \xb7 s\xf3 na primeira compra"]})]})]}),(0,l.jsx)("span",{className:"px-3 py-1 rounded-full text-xs font-black tracking-wide ".concat(D($)?"bg-red-100 text-red-600":$.active?"bg-emerald-100 text-emerald-700":"bg-slate-100 text-slate-500"),children:D($)?"● Expirado":$.active?"● Ativo":"○ Inativo"})]}),(0,l.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 text-sm",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1",children:"In\xedcio"}),(0,l.jsx)("p",{className:"font-bold text-slate-700",children:z($.valid_from)})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1",children:"Validade"}),(0,l.jsx)("p",{className:"font-bold text-slate-700",children:z($.valid_until)})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1",children:"Subtotal Bruto"}),(0,l.jsx)("p",{className:"font-bold text-slate-700",children:C($.subtotal)})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1",children:"Ticket M\xe9dio"}),(0,l.jsx)("p",{className:"font-bold text-slate-700",children:$.use_count>0?C($.total_revenue/$.use_count):"—"})]})]})]}),(0,l.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200 shadow-sm overflow-hidden",children:[(0,l.jsxs)("div",{className:"px-6 py-4 border-b border-slate-100 flex items-center justify-between max-md:px-3 max-md:gap-2",children:[(0,l.jsx)("h3",{className:"font-black text-slate-800",children:"Pedidos que usaram este cupom"}),(0,l.jsxs)("span",{className:"text-xs font-bold text-slate-400",children:[$.recent_orders.length," pedidos"]})]}),0===$.recent_orders.length?(0,l.jsxs)("div",{className:"py-16 text-center text-slate-400",children:[(0,l.jsx)(n.A,{size:28,className:"mx-auto mb-3 opacity-40"}),(0,l.jsx)("p",{className:"font-bold",children:"Nenhum pedido ainda"})]}):(0,l.jsx)("div",{className:"overflow-x-auto",children:(0,l.jsxs)("table",{className:"w-full text-left text-sm",children:[(0,l.jsx)("thead",{className:"bg-slate-50 text-[10px] uppercase tracking-widest text-slate-400 font-black border-b border-slate-100",children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{className:"px-6 py-3 max-md:px-3",children:"Cliente"}),(0,l.jsx)("th",{className:"px-6 py-3 max-md:hidden",children:"Data"}),(0,l.jsx)("th",{className:"px-6 py-3 max-md:hidden",children:"Subtotal"}),(0,l.jsx)("th",{className:"px-6 py-3 text-red-500 max-md:px-2",children:"Desconto"}),(0,l.jsx)("th",{className:"px-6 py-3 text-emerald-600 max-md:px-3",children:"Total Pago"}),(0,l.jsx)("th",{className:"px-6 py-3 max-md:hidden",children:"Status"})]})}),(0,l.jsx)("tbody",{className:"divide-y divide-slate-100",children:$.recent_orders.map(e=>{var t;let s=null!=(t=E[e.status])?t:{label:e.status,cls:"bg-slate-100 text-slate-500"};return(0,l.jsxs)("tr",{className:"hover:bg-slate-50/60 transition-colors",children:[(0,l.jsxs)("td",{className:"px-6 py-4 max-md:px-3 max-md:py-3",children:[(0,l.jsx)("p",{className:"font-bold text-slate-800",children:e.customer_name||"An\xf4nimo"}),e.customer_phone&&(0,l.jsx)("p",{className:"text-xs text-slate-400",children:e.customer_phone}),(0,l.jsxs)("p",{className:"mt-0.5 hidden text-xs text-slate-500 max-md:block",children:[S(e.created_at)," \xb7 ",s.label]})]}),(0,l.jsx)("td",{className:"px-6 py-4 text-slate-500 text-xs max-md:hidden",children:S(e.created_at)}),(0,l.jsx)("td",{className:"px-6 py-4 font-medium text-slate-600 max-md:hidden",children:C(e.total+(e.discount_amount||0))}),(0,l.jsxs)("td",{className:"px-6 py-4 font-bold text-red-500 max-md:whitespace-nowrap max-md:px-2",children:["−",C(e.discount_amount||0)]}),(0,l.jsx)("td",{className:"px-6 py-4 font-black text-emerald-600 max-md:whitespace-nowrap max-md:px-3",children:C(e.total)}),(0,l.jsx)("td",{className:"px-6 py-4 max-md:hidden",children:(0,l.jsx)("span",{className:"inline-flex px-2.5 py-1 rounded-full text-[10px] font-black uppercase ".concat(s.cls),children:s.label})})]},e.id)})})]})})]})]});let ei=B.filter(e=>e.active&&!D(e)).length,eo=B.filter(e=>D(e)).length;return(0,l.jsxs)("div",{className:"space-y-6 p-6 max-md:space-y-4 max-md:p-3",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[(0,l.jsxs)("div",{children:[(0,l.jsxs)("h2",{className:"text-xl font-black tracking-tight text-slate-800 flex items-center gap-2",children:[(0,l.jsx)(x.A,{size:20,className:"text-blue-600"})," Cupons de Desconto"]}),(0,l.jsx)("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-widest mt-1",children:"Gerencie e acompanhe o desempenho dos seus cupons"})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("button",{onClick:el,className:"p-2.5 rounded-xl border border-slate-200 text-slate-500 hover:bg-slate-50 transition-colors cursor-pointer",children:(0,l.jsx)(c.A,{size:16,className:O?"animate-spin":""})}),(0,l.jsxs)("button",{onClick:ea,className:"flex items-center gap-2 px-5 py-2.5 bg-blue-600 text-white rounded-xl text-sm font-black shadow-lg shadow-blue-600/20 hover:bg-blue-700 active:scale-95 transition-all cursor-pointer",children:[(0,l.jsx)(m.A,{size:16})," Novo Cupom"]})]})]}),(0,l.jsx)("div",{className:"grid grid-cols-2 lg:grid-cols-3 xl:grid-cols-6 gap-4 max-md:grid-cols-3 max-md:gap-2",children:[{label:"Total",value:null!=(e=null==F?void 0:F.total_coupons)?e:B.length,sub:"cupons",color:"slate",icon:x.A},{label:"Ativos",value:ei,sub:"cupons",color:"emerald",icon:u.A},{label:"Expirados",value:eo,sub:"cupons",color:"red",icon:p.A},{label:"Utiliza\xe7\xf5es",value:null!=(t=null==F?void 0:F.total_usages)?t:0,sub:"total",color:"blue",icon:n.A},{label:"Desconto Dado",value:C(null!=(s=null==F?void 0:F.total_discount_given)?s:0),sub:"em descontos",color:"orange",icon:d.A,small:!0},{label:"Clientes \xdanicos",value:null!=(q=null==F?void 0:F.unique_customers)?q:0,sub:"compradores",color:"purple",icon:o.A}].map(e=>{let{label:t,value:s,sub:a,color:r,icon:c,small:n}=e;return(0,l.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200 p-4 shadow-sm max-md:p-2.5",children:[(0,l.jsx)("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-".concat(r,"-50 mb
1-2 max-md:hidden"),children:(0,l.jsx)(c,{size:15,className:"text-".concat(r,"-600")})}),(0,l.jsx)("p",{className:"font-black text-slate-800 ".concat(n?"text-base max-md:text-[0.95rem]":"text-2xl max-md:text-xl"),children:s}),(0,l.jsx)("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-widest max-md:text-[0.72rem] max-md:normal-case max-md:tracking-normal max-md:leading-tight",children:t})]},t)})}),O?(0,l.jsx)(w.He,{}):0===B.length?(0,l.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200 shadow-sm flex flex-col items-center justify-center py-20 gap-4",children:[(0,l.jsx)("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-blue-50",children:(0,l.jsx)(x.A,{size:28,className:"text-blue-400"})}),(0,l.jsxs)("div",{className:"text-center",children:[(0,l.jsx)("p",{className:"font-black text-slate-700 text-lg",children:"Nenhum cupom criado"}),(0,l.jsx)("p",{className:"text-sm text-slate-400 mt-1",children:"Crie o primeiro cupom para oferecer descontos aos seus clientes."})]}),(0,l.jsxs)("button",{onClick:ea,className:"flex items-center gap-2 px-5 py-2.5 bg-blue-600 text-white rounded-xl text-sm font-black shadow-lg shadow-blue-600/20 hover:bg-blue-700 transition-all cursor-pointer",children:[(0,l.jsx)(m.A,{size:16})," Criar Primeiro Cupom"]})]}):(0,l.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200 shadow-sm overflow-hidden",children:[(0,l.jsx)("ul",{className:"hidden divide-y divide-slate-100 max-md:block",children:B.map(e=>{let t=D(e),s="flex h-10 flex-1 items-center justify-center gap-1.5 rounded border text-[0.9rem] font-semibold active:bg-slate-50";return(0,l.jsxs)("li",{className:"px-3.5 py-3.5",children:[(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,l.jsx)("span",{className:"font-black tracking-wider text-slate-800",children:e.code}),(0,l.jsxs)("span",{className:"rounded bg-blue-50 px-1.5 py-0.5 text-[0.8rem] font-black text-blue-700",children:[e.discount_pct,"% OFF"]}),e.first_order_only&&(0,l.jsx)("span",{className:"rounded border border-slate-300 bg-white px-1.5 py-0.5 text-[0.75rem] font-semibold text-slate-600",children:"1\xaa compra"})]}),(0,l.jsxs)("p",{className:"mt-1 text-[0.85rem] text-slate-500",children:[(0,l.jsx)("span",{className:"font-bold ".concat(t?"text-red-600":e.active?"text-emerald-700":"text-slate-500"),children:t?"Expirado":e.active?"Ativo":"Inativo"})," \xb7 ",e.valid_until?(0,l.jsxs)("span",{className:t?"font-bold text-red-500":"",children:["at\xe9 ",z(e.valid_until)]}):"Sem validade"]})]}),(0,l.jsx)("button",{onClick:()=>ed(e),"aria-label":e.active?"Desativar o cupom ".concat(e.code):"Ativar o cupom ".concat(e.code),className:"-mr-1 -mt-1 shrink-0 p-1",children:e.active?(0,l.jsx)(b.A,{size:32,className:"text-blue-600"}):(0,l.jsx)(h.A,{size:32,className:"text-slate-300"})})]}),(0,l.jsx)("dl",{className:"mt-2.5 grid grid-cols-4 gap-1.5 text-center",children:[["Usos",String(e.use_count),"text-slate-700"],["Clientes",e.unique_customers>0?String(e.unique_customers):"—","text-slate-700"],["Desconto",e.total_discount>0?"−".concat(C(e.total_discount)):"—","text-red-500"],["Receita",e.total_revenue>0?C(e.total_revenue):"—","text-emerald-600"]].map(e=>{let[t,s,a]=e;return(0,l.jsxs)("div",{className:"min-w-0 rounded border border-slate-200 px-1 py-1.5",children:[(0,l.jsx)("dt",{className:"text-[0.72rem] text-slate-400",children:t}),(0,l.jsx)("dd",{className:"truncate text-[0.82rem] font-bold ".concat(a),children:s})]},t)})}),(0,l.jsxs)("div",{className:"mt-2.5 flex gap-2",children:[e.use_count>0&&(0,l.jsxs)("button",{onClick:()=>ee(e),className:"".concat(s," border-slate-300 text-slate-700"),children:[(0,l.jsx)(i.A,{size:15})," Pedidos"]}),(0,l.jsxs)("button",{onClick:()=>er(e),className:"".concat(s," border-slate-300 text-slate-700"),children:[(0,l.jsx)(j.A,{size:14})," Editar"]}),(0,l.jsxs)("button",{onClick:()=>Z(e.id),className:"".concat(s," border-red-200 text-red-600"),children:[(0,l.jsx)(f.A,{size:14})," Excluir"]})]})]},e.id)})}),(0,l.jsx)("div",{className:"overflow-x-auto max-md:hidden",children:(0,l.jsxs)("table",{className:"w-full text-left",children:[(0,l.jsx)("thead",{className:"bg-slate-50 text-[10px] uppercase tracking-widest text-slate-400 font-black border-b border-slate-100",children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{className:"px-6 py-4",children:"C\xf3digo"}),(0,l.jsx)("th",{className:"px-6 py-4",children:"Desconto"}),(0,l.jsx)("th",{className:"px-6 py-4",children:"Validade"}),(0,l.jsx)("th",{className:"px-6 py-4 text-center",children:"Usos"}),(0,l.jsx)("th",{className:"px-6 py-4",children:"Desconto Total"}),(0,l.jsx)("th",{className:"px-6 py-4",children:"Receita"}),(0,l.jsx)("th",{className:"px-6 py-4 text-center",children:"Clientes"}),(0,l.jsx)("th",{className:"px-6 py-4",children:"Status"}),(0,l.jsx)("th",{className:"px-6 py-4 text-center",children:"Ativo"}),(0,l.jsx)("th",{className:"px-6 py-4 text-center",children:"A\xe7\xf5es"})]})}),(0,l.jsx)("tbody",{className:"divide-y divide-slate-100 text-sm",children:B.map(e=>{let t=D(e),s=et===e.id;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("tr",{className:"hover:bg-slate-50/60 transition-colors",children:[(0,l.jsx)("td",{className:"px-6 py-4",children:(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-blue-50 shrink-0",children:(0,l.jsx)(x.A,{size:13,className:"text-blue-600"})}),(0,l.jsx)("span",{className:"font-black text-slate-800 tracking-wider",children:e.code}),e.first_order_only&&(0,l.jsx)("span",{className:"whitespace-nowrap rounded border border-slate-300 bg-white px-1.5 py-0.5 text-[11px] font-semibold text-slate-600",title:"S\xf3 vale para quem nunca fez pedido na loja",children:"1\xaa compra"})]})}),(0,l.jsx)("td",{className:"px-6 py-4",children:(0,l.jsxs)("span",{className:"inline-flex items-center px-2.5 py-1 rounded-lg bg-blue-50 text-blue-700 font-black text-sm",children:[e.discount_pct,"% OFF"]})}),(0,l.jsx)("td",{className:"px-6 py-4",children:(0,l.jsx)("div",{className:"text-xs font-medium text-slate-500",children:e.valid_until?(0,l.jsxs)("span",{className:t?"text-red-500 font-bold":"",children:["at\xe9 ",z(e.valid_until)]}):(0,l.jsx)("span",{className:"text-slate-400",children:"Sem validade"})})}),(0,l.jsx)("td",{className:"px-6 py-4 text-center",children:(0,l.jsx)("span",{className:"font-black text-lg ".concat(e.use_count>0?"text-blue-600":"text-slate-300"),children:e.use_count})}),(0,l.jsx)("td",{className:"px-6 py-4 font-bold text-red-500",children:e.total_discount>0?"−".concat(C(e.total_discount)):"—"}),(0,l.jsx)("td",{className:"px-6 py-4 font-bold text-emerald-600",children:e.total_revenue>0?C(e.total_revenue):"—"}),(0,l.jsx)("td",{className:"px-6 py-4 text-center",children:(0,l.jsx)("span",{className:"font-bold ".concat(e.unique_customers>0?"text-slate-700":"text-slate-300"),children:e.unique_customers>0?e.unique_customers:"—"})}),(0,l.jsx)("td",{className:"px-6 py-4",children:(0,l.jsx)("span",{className:"inline-flex px-2.5 py-1 rounded-full text-[10px] font-black uppercase tracking-wide ".concat(t?"bg-red-100 text-red-600":e.active?"bg-emerald-100 text-emerald-700":"bg-slate-100 text-slate-500"),children:t?"● Expirado":e.active?"● Ativo":"○ Inativo"})}),(0,l.jsx)("td",{className:"px-6 py-4 text-center",children:(0,l.jsx)("button",{onClick:()=>ed(e),className:"cursor-pointer transition-opacity hover:opacity-70",title:e.active?"Desativar":"Ativar",children:e.active?(0,l.jsx)(b.A,{size:26,className:"text-blue-600"}):(0,l.jsx)(h.A,{size:26,className:"text-slate-300"})})}),(0,l.jsx)("td",{className:"px-6 py-4",children:(0,l.jsxs)("div",{className:"flex items-center justify-center gap-1",children:[e.use_count>0&&(0,l.jsx)("button",{onClick:()=>ee(e),className:"p-2 rounded-lg text-slate-400 hover:text-blue-600 hover:bg-blue-50 transition-colors cursor-pointer",title:"Ver detalhes",children:(0,l.jsx)(i.A,{size:15})}),(0,l.jsx)("button",{onClick:()=>er(e),className:"p-2 rounded-lg text-slate-400 hover:text-blue-600 hover:bg-blue-50 transition-colors cursor-pointer",title:"Editar",children:(0,l.jsx)(j.A,{size:15})}),(0,l.jsx)("button",{onClick:()=>Z(e.id),className:"p-2 rounded-lg text-slate-400 hover:text-red-500 hover:bg-red-50 transition-colors cursor-pointer",title:"Excluir",children:(0,l.jsx)(f.A,{size:15})}),e.use_count>0&&(0,l.jsx)("button",{onClick:()=>es(s?null:e.id),className:"p-2 rounded-lg text-slate-400 hover:text-slate-600 hover:bg-slate-100 transition-colors cursor-pointer",title:"Ver pedidos",children:s?(0,l.jsx)(v.A,{size:15}):(0,l.jsx)(N.A,{size:15})})]})})]},e.id),s&&(0,l.jsx)("tr",{children:(0,l.jsx)("td",{colSpan:10,className:"px-0 py-0 bg-slate-50/60",children:(0,l.jsxs)("div",{className:"px-6 py-4 border-t border-slate-100",children:[(0,l.jsx)("p",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest mb-3",children:"\xdaltimos pedidos com este cupom"}),(0,l.jsxs)("div",{className:"space-y-2",children:[e.recent_orders.slice(0,5).map(e=>{var t;let s=null!=(t=E[e.status])?t:{label:e.status,cls:"bg-slate-100 text-slate-500"};return(0,l.jsxs)("div",{className:"flex items-center gap-4 bg-white rounded-xl border border-slate-100 px-4 py-3 text-sm",children:[(0,l.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,l.jsx)("p",{className:"font-bold text-slate-800 truncate",children:e.customer_name||"An\xf4nimo"}),e.customer_phone&&(0,l.jsx)("p",{className:"text-xs text-slate-400",children:e.customer_phone})]}
1),(0,l.jsx)("p",{className:"text-xs text-slate-500 whitespace-nowrap",children:S(e.created_at)}),(0,l.jsxs)("p",{className:"text-xs font-bold text-red-500 whitespace-nowrap",children:["−",C(e.discount_amount||0)]}),(0,l.jsx)("p",{className:"text-sm font-black text-emerald-600 whitespace-nowrap",children:C(e.total)}),(0,l.jsx)("span",{className:"text-[10px] font-black px-2 py-0.5 rounded-full whitespace-nowrap ".concat(s.cls),children:s.label})]},e.id)}),e.use_count>5&&(0,l.jsxs)("button",{onClick:()=>ee(e),className:"text-xs font-bold text-blue-600 hover:underline cursor-pointer pl-1",children:["Ver todos os ",e.use_count," pedidos →"]})]})]})})},"".concat(e.id,"-expanded"))]})})})]})})]}),G&&(0,l.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4 max-md:items-end max-md:p-0 max-md:backdrop-blur-none",onClick:()=>M(!1),children:(0,l.jsxs)("div",{className:"w-full max-w-md bg-white rounded-2xl shadow-2xl cel-folha-md max-md:max-h-[92dvh] max-md:max-w-none max-md:overflow-y-auto max-md:rounded-b-none max-md:rounded-t-lg max-md:pb-[env(safe-area-inset-bottom)]",onClick:e=>e.stopPropagation(),children:[(0,l.jsxs)("div",{className:"flex items-center justify-between px-6 py-5 border-b border-slate-100",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("h3",{className:"font-black text-slate-900 text-lg",children:H.id?"Editar Cupom":"Novo Cupom"}),(0,l.jsx)("p",{className:"text-xs text-slate-400 font-medium mt-0.5",children:"Preencha os dados do cupom de desconto"})]}),(0,l.jsx)("button",{onClick:()=>M(!1),className:"p-2 rounded-xl text-slate-400 hover:bg-slate-100 hover:text-slate-600 transition-colors cursor-pointer",children:(0,l.jsx)(g.A,{size:20})})]}),(0,l.jsxs)("form",{onSubmit:ec,className:"p-6 space-y-5",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-1.5 block",children:"C\xf3digo do Cupom *"}),(0,l.jsx)("input",{value:H.code,onChange:e=>J({...H,code:e.target.value.toUpperCase()}),placeholder:"Ex: PROMO20",className:"w-full rounded-xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm font-black tracking-widest focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 uppercase",required:!0})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-1.5 block",children:"Percentual de Desconto *"}),(0,l.jsxs)("div",{className:"relative",children:[(0,l.jsx)("input",{type:"number",min:"1",max:"100",value:H.discount_pct,onChange:e=>J({...H,discount_pct:Number(e.target.value)}),className:"w-full rounded-xl border border-slate-200 bg-slate-50 px-4 py-3 pr-12 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500",required:!0}),(0,l.jsx)("span",{className:"absolute right-4 top-1/2 -translate-y-1/2 text-sm font-black text-slate-400",children:"%"})]})]}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-1.5 block",children:"Data de In\xedcio"}),(0,l.jsx)("input",{type:"date",value:null!=(P=H.valid_from)?P:"",onChange:e=>J({...H,valid_from:e.target.value}),className:"w-full rounded-xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-1.5 block",children:"Data de Validade"}),(0,l.jsx)("input",{type:"date",value:null!=(R=H.valid_until)?R:"",onChange:e=>J({...H,valid_until:e.target.value}),className:"w-full rounded-xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500"})]})]}),(0,l.jsxs)("div",{className:"flex items-center justify-between gap-4 p-4 rounded-xl border border-slate-100 bg-slate-50",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-sm font-bold text-slate-700",children:"S\xf3 na primeira compra"}),(0,l.jsx)("p",{className:"text-xs text-slate-400 mt-0.5",children:"Vale uma vez, para quem nunca fez pedido na loja"})]}),(0,l.jsx)("button",{type:"button",onClick:()=>J({...H,first_order_only:!H.first_order_only}),"aria-pressed":H.first_order_only,className:"shrink-0 cursor-pointer transition-opacity hover:opacity-70",children:H.first_order_only?(0,l.jsx)(b.A,{size:30,className:"text-blue-600"}):(0,l.jsx)(h.A,{size:30,className:"text-slate-300"})})]}),(0,l.jsxs)("div",{className:"flex items-center justify-between p-4 rounded-xl border border-slate-100 bg-slate-50",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-sm font-bold text-slate-700",children:"Cupom ativo"}),(0,l.jsx)("p",{className:"text-xs text-slate-400 mt-0.5",children:"Clientes poder\xe3o usar este cupom"})]}),(0,l.jsx)("button",{type:"button",onClick:()=>J({...H,active:!H.active}),className:"cursor-pointer transition-opacity hover:opacity-70",children:H.active?(0,l.jsx)(b.A,{size:30,className:"text-blue-600"}):(0,l.jsx)(h.A,{size:30,className:"text-slate-300"})})]}),Q&&(0,l.jsx)("p",{className:"text-xs font-bold text-red-600 bg-red-50 p-3 rounded-xl border border-red-100",children:Q}),(0,l.jsxs)("div",{className:"flex gap-3 pt-1",children:[(0,l.jsx)("button",{type:"button",onClick:()=>M(!1),className:"flex-1 py-3 rounded-xl border border-slate-200 text-sm font-bold text-slate-600 hover:bg-slate-50 cursor-pointer transition-colors",children:"Cancelar"}),(0,l.jsx)("button",{type:"submit",disabled:W,className:"flex-1 py-3 rounded-xl bg-blue-600 text-white text-sm font-black shadow-lg shadow-blue-600/20 hover:bg-blue-700 disabled:opacity-70 cursor-pointer transition-all",children:W?"Salvando...":H.id?"Salvar Altera\xe7\xf5es":"Criar Cupom"})]})]})]})}),Y&&(0,l.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4 max-md:backdrop-blur-none",children:(0,l.jsxs)("div",{className:"w-full max-w-sm bg-white rounded-2xl shadow-2xl p-6",children:[(0,l.jsx)("div",{className:"flex h-12 w-12 items-center justify-center rounded-2xl bg-red-100 mb-4",children:(0,l.jsx)(f.A,{size:20,className:"text-red-600"})}),(0,l.jsx)("h3",{className:"text-lg font-black text-slate-900 mb-1",children:"Excluir cupom?"}),(0,l.jsx)("p",{className:"text-sm text-slate-500 mb-6",children:"Esta a\xe7\xe3o n\xe3o pode ser desfeita."}),(0,l.jsxs)("div",{className:"flex gap-3",children:[(0,l.jsx)("button",{onClick:()=>Z(null),className:"flex-1 py-3 rounded-xl border border-slate-200 text-sm font-bold text-slate-600 hover:bg-slate-50 cursor-pointer transition-colors",children:"Cancelar"}),(0,l.jsx)("button",{onClick:en,className:"flex-1 py-3 rounded-xl bg-red-600 text-white text-sm font-black hover:bg-red-700 cursor-pointer transition-colors",children:"Excluir"})]})]})})]})}},26921:(e,t,s)=>{s.d(t,{A:()=>l});let l=(0,s(71847).A)("trending-down",[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]])},31716:(e,t,s)=>{s.d(t,{A:()=>l});let l=(0,s(71847).A)("toggle-right",[["circle",{cx:"15",cy:"12",r:"3",key:"1afu0r"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]])},64347:(e,t,s)=>{s.d(t,{A:()=>l});let l=(0,s(71847).A)("toggle-left",[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]])}}]);

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.