PageSourceSearch

https://zappio.app.br/static/js/7840.ddbae82a.chunk.js

js zappio.app.br collected 2026-10-02 01:20:38 UTC 47,161 bytes, 2 lines download raw bytes

1"use strict";(globalThis.webpackChunkfrontend=globalThis.webpackChunkfrontend||[]).push([[7840],{95952(e,a,t){t.d(a,{A:()=>c});var s=t(65043),n=t(67361),i=t.n(n),r=t(65598),o=t(13390),l=t(49048),d=t(70579);function c(e){var a;let{open:t,onClose:n,onScan:c,title:m="Ler c\xf3digo",hint:p="Aponte a c\xe2mera para o QR."}=e;const[u,x]=(0,s.useState)(""),[h,b]=(0,s.useState)(!1),[v,g]=(0,s.useState)(""),f=(0,s.useRef)(null),j=(0,s.useRef)(null),y="undefined"!==typeof navigator&&!(null===(a=navigator.mediaDevices)||void 0===a||!a.getUserMedia);(0,s.useEffect)(()=>{if(t&&(x(""),g(""),b(y),!y)){const e=setTimeout(()=>{var e;return null===(e=f.current)||void 0===e?void 0:e.focus()},120);return()=>clearTimeout(e)}},[t,y]),(0,s.useEffect)(()=>{if(!t||!h)return;let e,a,s=!1;const n=document.createElement("canvas"),r=n.getContext("2d",{willReadFrequently:!0}),o="undefined"!==typeof window&&"BarcodeDetector"in window?new window.BarcodeDetector({formats:["qr_code","code_128","ean_13","ean_8"]}):null;return(async()=>{try{if(e=await navigator.mediaDevices.getUserMedia({video:{facingMode:"environment"}}),!j.current)return;j.current.srcObject=e,await j.current.play().catch(()=>{});const t=async()=>{if(s)return;const e=j.current;if(e&&e.readyState>=2&&e.videoWidth)try{if(o){const a=await o.detect(e);if(a&&a.length)return N(a[0].rawValue)}else{n.width=e.videoWidth,n.height=e.videoHeight,r.drawImage(e,0,0,n.width,n.height);const a=r.getImageData(0,0,n.width,n.height),t=i()(a.data,a.width,a.height,{inversionAttempts:"dontInvert"});if(t&&t.data)return N(t.data)}}catch{}a=requestAnimationFrame(t)};a=requestAnimationFrame(t)}catch{g("N\xe3o foi poss\xedvel acessar a c\xe2mera. Digite o c\xf3digo abaixo."),b(!1),setTimeout(()=>{var e;return null===(e=f.current)||void 0===e?void 0:e.focus()},120)}})(),()=>{s=!0,a&&cancelAnimationFrame(a),e&&e.getTracks().forEach(e=>e.stop())}},[t,h]);const N=e=>{const a=(e||"").trim();a&&(b(!1),c(a))};return(0,d.jsx)(r.lG,{open:t,onOpenChange:e=>!e&&n(),children:(0,d.jsxs)(r.Cf,{className:"bg-[#161616] border-white/10 text-white max-w-md",children:[(0,d.jsxs)(r.c7,{children:[(0,d.jsxs)(r.L3,{className:"flex items-center gap-2",children:[(0,d.jsx)(l.A,{className:"w-5 h-5 text-orange-400"})," ",m]}),(0,d.jsx)(r.rr,{className:"text-zinc-500",children:h?p:"Digite ou use o leitor para informar o c\xf3digo."})]}),(0,d.jsxs)("div",{className:"space-y-3",children:[h&&(0,d.jsxs)("div",{className:"relative always-dark",children:[(0,d.jsx)("video",{ref:j,className:"w-full rounded-lg bg-black aspect-square object-cover",muted:!0,playsInline:!0}),(0,d.jsx)("div",{className:"pointer-events-none absolute inset-8 rounded-xl border-2 border-orange-400/80"}),(0,d.jsx)("span",{className:"absolute bottom-2 left-1/2 -translate-x-1/2 text-[11px] text-white/80 bg-black/50 px-2 py-0.5 rounded",children:"Procurando QR..."})]}),v&&(0,d.jsx)("p",{className:"text-xs text-amber-400",children:v}),(0,d.jsxs)("form",{onSubmit:e=>{e.preventDefault(),N(u)},className:"space-y-2",children:[(0,d.jsx)("input",{ref:f,value:u,onChange:e=>x(e.target.value),placeholder:h?"N\xe3o leu? Digite o c\xf3digo aqui...":"C\xf3digo da mesa/comanda...",className:"w-full bg-[#0A0A0A] border border-white/10 rounded-lg p-2.5 text-sm text-white","data-testid":"code-scanner-input",autoComplete:"off"}),(0,d.jsxs)("div",{className:"flex gap-2",children:[y&&(0,d.jsx)(o.$,{type:"button",variant:"outline",className:"flex-1 border-white/10",onClick:()=>b(e=>!e),"data-testid":"code-scanner-camera-toggle",children:h?"Parar c\xe2mera":"Ligar c\xe2mera"}),(0,d.jsx)(o.$,{type:"submit",className:"flex-1 bg-orange-500 hover:bg-orange-600","data-testid":"code-scanner-confirm",children:"Confirmar c\xf3digo"})]})]})]})]})})}},73306(e,a,t){t.d(a,{A:()=>m});var s=t(65043),n=t(22024),i=t(22754),r=t(91586),o=t(13390),l=t(65598),d=t(56328),c=t(70579);function m(e){let{tableId:a,sessionId:t,layout:m,onBrowserPrint:p,label:u="Imprimir",className:x="",variant:h,size:b,onAfterPrint:v,children:g}=e;const[f,j]=(0,s.useState)(!1),[y,N]=(0,s.useState)([]),[w,_]=(0,s.useState)(!1),[z,A]=(0,s.useState)(""),[C,k]=(0,s.use
1State)(""),[$,S]=(0,s.useState)(!1),R=(0,s.useCallback)(()=>{null===p||void 0===p||p(),null===v||void 0===v||v()},[p,v]),E=(0,s.useCallback)(async()=>{if(a){j(!0);try{var e;const[a,t,s]=await Promise.all([r.Ay.get("/company/print/sectors"),r.Ay.get("/company/print/agent/status"),r.Ay.get("/company/print/printers")]),n=(a.data||[]).length>0,i=!(null===(e=t.data)||void 0===e||!e.connected),o=(s.data||[]).filter(e=>!1!==e.is_active);if(n&&i&&o.length>0){N(o);const e=o.find(e=>e.is_default)||o[0];A(String(e.id)),_(!0)}else R()}catch{R()}finally{j(!1)}}},[a,R]),P=(0,s.useCallback)(async()=>{if(z){S(!0);try{await r.Ay.post(`/company/tables/${a}/bill/print-to-printer`,{printer_id:Number(z),document:C.trim()||null,...t?{session_id:t}:{},...m?{layout:m}:{}}),d.oR.success("Enviado para impress\xe3o. O agente vai imprimir em instantes."),_(!1),null===v||void 0===v||v()}catch(n){var e,s;d.oR.error((null===(e=n.response)||void 0===e||null===(s=e.data)||void 0===s?void 0:s.message)||"Falha ao enviar para o agente.")}finally{S(!1)}}},[a,t,m,z,C,v]);return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(o.$,{onClick:E,className:x,variant:h,size:b,disabled:f,children:[f?(0,c.jsx)(n.A,{className:`w-4 h-4 ${g||u?"mr-2":""} animate-spin`}):(0,c.jsx)(i.A,{className:"w-4 h-4 "+(g||u?"mr-2":"")}),g||u]}),(0,c.jsx)(l.lG,{open:w,onOpenChange:e=>{_(e),e||k("")},children:(0,c.jsxs)(l.Cf,{className:"bg-[#161616] border-white/10 text-white max-w-sm",children:[(0,c.jsx)(l.c7,{children:(0,c.jsx)(l.L3,{children:"Selecionar impressora"})}),(0,c.jsxs)("div",{className:"space-y-4",children:[(0,c.jsx)("p",{className:"text-sm text-zinc-400",children:"Escolha a impressora. A conta ser\xe1 impressa automaticamente pelo agente."}),(0,c.jsx)("select",{value:z,onChange:e=>A(e.target.value),className:"w-full rounded-lg border border-white/10 bg-[#0A0A0A] p-2.5 text-sm",children:y.map(e=>(0,c.jsxs)("option",{value:e.id,children:[e.name,e.is_default?" (padr\xe3o)":""]},e.id))}),(0,c.jsxs)("div",{children:[(0,c.jsx)("label",{className:"text-sm text-zinc-400 block mb-1",children:"CPF/CNPJ na nota (opcional)"}),(0,c.jsx)("input",{value:C,onChange:e=>k(e.target.value),placeholder:"000.000.000-00",className:"w-full rounded-lg border border-white/10 bg-[#0A0A0A] p-2.5 text-sm","data-testid":"bill-print-document"})]}),(0,c.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,c.jsx)(o.$,{variant:"outline",className:"border-white/10",onClick:()=>_(!1),disabled:$,children:"Cancelar"}),(0,c.jsxs)(o.$,{className:"bg-orange-500 hover:bg-orange-600",onClick:P,disabled:$,children:[$?(0,c.jsx)(n.A,{className:"w-4 h-4 mr-2 animate-spin"}):(0,c.jsx)(i.A,{className:"w-4 h-4 mr-2"}),"Imprimir"]})]})]})]})})]})}},42816(e,a,t){t.d(a,{A:()=>l});var s=t(65043),n=t(2733),i=t(99722),r=t(70579);function o(e){var a,t;let{it:s}=e;return(0,r.jsxs)("div",{className:"mb-1.5 text-lg",children:[(0,r.jsxs)("div",{className:"flex justify-between font-bold",children:[(0,r.jsxs)("span",{children:[s.quantity,"x ",s.product_name,s.pizza_size_name?` (${s.pizza_size_name})`:""]}),(0,r.jsx)("span",{children:(0,n.vv)(s.total_price)})]}),(0,r.jsx)(i.A,{flavors:s.pizza_flavors,crusts:s.pizza_crusts,crustLineClass:"print-small print-option text-base text-gray-700 pl-3",headerClass:"print-small print-option text-base text-gray-700 pl-3 font-bold",renderLine:(e,a)=>(0,r.jsxs)("div",{className:"print-small print-option text-base text-gray-700 pl-3 flex justify-between",children:[(0,r.jsxs)("span",{children:["\u2022 ","1"===e.fraction_label?"":e.fraction_label+" ",e.pizza_flavor_name]}),Number(e.calculated_flavor_price)>0&&(0,r.jsx)("span",{children:(0,n.vv)(e.calculated_flavor_price)})]},a)}),!(null!==(a=s.pizza_crusts)&&void 0!==a&&a.length)&&s.pizza_crust_name&&(0,r.jsxs)("div",{className:"print-small print-option text-base text-gray-700 pl-3 flex justify-between",children:[(0,r.jsxs)("span",{children:["\u2022 Acompanhamentos: ",s.pizza_crust_name]}),(0,r.jsx)("span",{children:(0,n.vv)(s.pizza_crust_price)})]}),null===(t=s.addons)||void 0===t?void 0:t.map(e=>(0,r.jsxs)("div",{className:"print-small print-option text-base text-gray-700 pl-3 flex justify-between",children:[(0,r.jsxs)("span",{children:["+ ",e.addon_group_name?`${e.addon_group_name}: `:"",e.quantity,"x ",e.addon_name]}),(0,r.jsx)("span",{children:(0,n.vv)(e.total_price)})]},e.id)),s.notes&&(0,r.jsxs)("div",{className:"print-small text-base italic pl-3",children:["obs: ",s.notes]})]})}function l(e){var a,t,i,l,d,c,m,p,u,x,h,b,v,g,f;let{data:j,companyName:y,logoUrl:N,groupByOrder:w=!1,showPayments:_=w,showSplit:z=!w,showSessionRef:A=w}=e;
1const[C,k]=(0,s.useState)(2);if(!j)return null;const{table:$,session:S,orders:R,totals:E}=j,P=null!==(a=null!==(t=null===E||void 0===E?void 0:E.orders_total)&&void 0!==t?t:j.subtotal)&&void 0!==a?a:0,F=null!==(i=null!==(l=null===E||void 0===E?void 0:E.discount)&&void 0!==l?l:j.discount)&&void 0!==i?i:0,D=null!==(d=null!==(c=null===E||void 0===E?void 0:E.service_fee)&&void 0!==c?c:j.service_fee)&&void 0!==d?d:0,M=null!==(m=null!==(p=null===E||void 0===E?void 0:E.couvert)&&void 0!==p?p:j.couvert)&&void 0!==m?m:0,q=null!==(u=null===E||void 0===E?void 0:E.people_count)&&void 0!==u?u:0,O="open"===(null===S||void 0===S?void 0:S.status),T=O&&Number(D)<=0&&(null===E||void 0===E?void 0:E.service_fee_enabled),I=Number(T?(null===E||void 0===E?void 0:E.service_fee_suggested)||0:D),L=O&&Number(M)<=0&&(null===E||void 0===E?void 0:E.couvert_active_now),J=Number(L?(null===E||void 0===E?void 0:E.couvert_suggested)||0:M),G=T||L?Math.max(0,Number(P)+I+J-Number(F)):null!==(x=null!==(h=null===E||void 0===E?void 0:E.total)&&void 0!==h?h:j.total)&&void 0!==x?x:0,B=C>0?G/C:0,H=_?(j.payments||[]).filter(e=>"paid"===e.status).sort((e,a)=>new Date(e.paid_at||0)-new Date(a.paid_at||0)):[],K=(R||[]).flatMap(e=>e.items||[]),U=Object.values(K.reduce((e,a)=>{const t=[a.product_id,a.product_name,a.unit_price,a.pizza_size_name||"",a.pizza_crust_name||"",(a.pizza_flavors||[]).map(e=>`${e.pizza_flavor_name}:${e.fraction_label}`).sort().join(","),(a.addons||[]).map(e=>`${e.addon_name}:${e.quantity}`).sort().join(","),a.notes||""].join("|");return e[t]||(e[t]={...a,_sig:t,quantity:0,total_price:0}),e[t].quantity+=Number(a.quantity||0),e[t].total_price+=Number(a.total_price||0),e},{}));return(0,r.jsxs)("div",{className:"bill-print bg-white text-black p-6 max-w-md mx-auto text-lg font-bold leading-snug",children:[(0,r.jsx)("style",{children:"\n                @media print {\n                    @page { margin: 0; size: 80mm auto; }\n                    html, body { height: auto !important; overflow: visible !important; }\n                    body * { visibility: hidden; }\n                    .bill-print, .bill-print * { visibility: visible; }\n                    .bill-print { position: absolute; left: 0; top: 0; width: 100%; padding: 8mm; box-sizing: border-box; font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: 700; line-height: 1.42; -webkit-print-color-adjust: exact; print-color-adjust: exact; }\n                    .bill-print h1 { font-size: 28px !important; font-weight: 900 !important; }\n                    .bill-print .print-small { font-size: 18px !important; font-weight: 700 !important; line-height: 1.38; }\n                    .bill-print .print-option { font-weight: 700 !important; }\n                    .bill-print .print-total { font-size: 26px !important; font-weight: 900 !important; }\n                    .bill-print .border-dashed { border-style: solid !important; }\n                    .no-print { display: none !important; }\n                }\n            "}),(0,r.jsxs)("div",{className:"text-center border-b-2 border-dashed border-black pb-3 mb-3",children:[(N||(null===$||void 0===$||null===(b=$.company)||void 0===b?void 0:b.logo_url))&&(0,r.jsx)("img",{src:N||$.company.logo_url,alt:"",className:"h-14 mx-auto mb-2"}),(0,r.jsx)("h1",{className:"font-bold text-2xl",children:y||(null===$||void 0===$||null===(v=$.company)||void 0===v?void 0:v.trade_name)||"Restaurante"}),(0,r.jsx)("p",{className:"print-small text-lg",children:w?"Comprovante da mesa":"Comprovante de consumo"})]}),(0,r.jsxs)("div",{className:"print-small text-lg space-y-1 mb-3",children:[(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Mesa:"}),(0,r.jsx)("span",{className:"font-bold",children:null===$||void 0===$?void 0:$.number})]}),A&&(null===S||void 0===S?void 0:S.id)&&(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Atendimento:"}),(0,r.jsxs)("span",{children:["#",S.id]})]}),(null===S||void 0===S||null===(g=S.waiter)||void 0===g?void 0:g.name)&&(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Gar\xe7om:"}),(0,r.jsx)("span",{children:S.waiter.name})]}),(null===S||void 0===S?void 0:S.opened_at)&&(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Abertura:"}),(0,r.jsx)("span",{children:(0,n.r6)(S.opened_at)})]}),(null===S||void 0===S?void 0:S.closed_at)&&(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Fechamento:"}),(0,r.jsx)("span",{children:(0,n.r6)(S.closed_at)})]})]}),w?(0,r.jsxs)("div",{className:"border-t border-dashed border-black pt-2 mb-2",children:[0===(R||[]).length&&(0,r.jsx)("p",{className:"text-lg",children:"Nenhum pedido lan\xe7ado neste atendimento."}),(R||[]).map(e=>(0,r.jsxs)("div",{className:"mb-3 pb-2 border-b border-dashed border-black last:border-0",children:[(0,r.jsxs)("div",{className:"flex justify-between font-bold text-lg mb-1",children:[(0,r.jsxs)("span",{children:["Pedido ",e.number]}),(0,r.jsx)("span",{className:"print-small",children:(0,n.r6)(e.created_at)})]}),(e.items||[]).map(e=>(0,r.jsx)(o,{it:e},e.id)),(0,r.jsxs)("div",{className:"print-small flex justify-between text-base",children:[(0,r.jsx)("span",{children:"Subtotal do pedido"}),(0,r.jsx)("span",{children:(0,n.vv)(e.total)})]})]},e.id))]}):(0,r.jsxs)("div",{className:"border-t border-dashed border-black pt-2 mb-2",children:[(0,r.jsx)("p",{className:"font-bold text-lg mb-1",children:"ITENS"}),U.map(e=>(0,r.jsx)(o,{it:e},e._sig))]}),(0,r.jsxs)("div",{className:"border-t border-dashed border-black pt-2 text-lg space-y-1",children:[(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Subtotal:"}),(0,r.jsx)("span",{children:(0,n.vv)(P)})]}),Number(I)>0&&(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Taxa de servi\xe7o:"}),(0,r.jsx)("span",{children:(0,n.vv)(I)})]}),Number(J)>0&&(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsxs)("span",{children:["Couvert",q>0?` (${q} pessoas)`:"",":"]}),(0,r.jsx)("span",{children:(0,n.vv)(J)})]}),Number(F)>0&&(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Desconto:"}),(0,r.jsxs)("span",{children:["- ",(0,n.vv)(F)]})]}),(0,r.jsxs)("div",{className:"print-total flex justify-between font-bold text-3xl border-t-2 border-dashed border-black pt-1 mt-1",children:[(0,r.jsx)("span",{children:"TOTAL:"}),(0,r.jsx)("span",{children:(0,n.vv)(G)})]})]}),H.length>0&&(0,r.jsxs)("div",{className:"border-t border-dashed border-black pt-2 mt-2 text-lg space-y-1",children:[(0,r.jsx)("p",{className:"font-bold text-lg",children:"PAGAMENTOS"}),H.map(e=>(0,r.jsxs)("div",{className:"flex justify-between print-small",children:[(0,r.jsxs)("span",{children:[n.tK[e.payment_method]||e.payment_method," \xb7 ",(0,n.r6)(e.paid_at)]}),(0,r.jsx)("span",{children:(0,n.vv)(e.amount)})]},e.id)),(0,r.jsxs)("div",{className:"flex justify-between font-bold",children:[(0,r.jsx)("span",{children:"Total pago:"}),(0,r.jsx)("span",{children:(0,n.vv)(null!==(f=null===E||void 0===E?void 0:E.paid)&&void 0!==f?f:0)})]}),Number(null===E||void 0===E?void 0:E.remaining)>0&&(0,r.jsxs)("div",{className:"flex justify-between font-bold",children:[(0,r.jsx)("span",{children:"Saldo:"}),(0,r.jsx)("span",{children:(0,n.vv)(E.remaining)})]})]}),z&&(0,r.jsxs)("div",{className:"no-print mt-4 border-t-2 border-dashed border-gray-300 pt-3",children:[(0,r.jsx)("p",{className:"font-bold text-base mb-2",children:"Dividir conta"}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("button",{type:"button",onClick:()=>k(e=>Math.max(1,e-1)),className:"w-8 h-8 rounded-full border border-gray-300 text-lg font-bold flex items-center justify-center hover:bg-gray-100",children:"\u2212"}),(0,r.jsxs)("span",{className:"text-base font-semibold w-24 text-center",children:[C," ",1===C?"pessoa":"pessoas"]}),(0,r.jsx)("button",{type:"button",onClick:()=>k(e=>e+1),className:"w-8 h-8 rounded-full border border-gray-300 text-lg font-bold flex items-center justify-center hover:bg-gray-100",children:"+"})]}),(0,r.jsxs)("div",{className:"mt-2 flex justify-between items-baseline",children:[(0,r.jsx)("span",{className:"text-sm text-gray-500",children:"Cada pessoa paga:"}),(0,r.jsx)("span",{className:"text-xl font-bold text-black",children:(0,n.vv)(B)})]})]}),(0,r.jsxs)("div",{className:"print-small text-center text-lg mt-4 border-t border-dashed border-black pt-3",children:[(0,r.jsx)("p",{children:"Obrigado pela prefer\xeancia!"}),(0,r.jsx)("p",{className:"text-base text-gray-500 mt-2",children:"Powered by Zappio"})]})]})}},27615(e,a,t){t.d(a,{A:()=>m});var s=t(65043),n=t(91586),i=t(92264),r=t(13390),o=t(56328),l=t(51884),d=t(40614),c=t(70579);function m(e){let{tableId:a,value:t,onChange:m,onCustomersChanged:p,large:u=!1}=e;
1const[x,h]=(0,s.useState)([]),[b,v]=(0,s.useState)(!1),[g,f]=(0,s.useState)(""),[j,y]=(0,s.useState)(!1);(0,s.useEffect)(()=>{(async()=>{if(a)try{const e=await n.Ay.get(`/company/tables/${a}/customers`);h(e.data||[])}catch{}})()},[a]);const N=async()=>{const e=g.trim();if(e){y(!0);try{const t=await n.Ay.post(`/company/tables/${a}/customers`,{name:e});h(e=>[...e,t.data]),m(t.data.id),null===p||void 0===p||p(),f(""),v(!1)}catch(i){var t,s;o.oR.error((null===(t=i.response)||void 0===t||null===(s=t.data)||void 0===s?void 0:s.message)||"Erro ao adicionar cliente.")}finally{y(!1)}}},w=u?"min-h-[40px] px-3.5 py-2 text-sm":"px-2.5 py-1 text-xs";return(0,c.jsxs)("div",{className:"mb-3 rounded-xl border border-white/10 bg-[#0A0A0A] p-3","data-testid":"table-customer-select",children:[(0,c.jsxs)("div",{className:"flex items-center justify-between gap-2 mb-2",children:[(0,c.jsx)("span",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:"Cliente da mesa"}),!b&&(0,c.jsxs)("button",{type:"button",onClick:()=>v(!0),className:"inline-flex items-center gap-1 text-orange-400 hover:text-orange-300 "+(u?"min-h-[40px] px-1 text-sm font-medium":"text-xs"),"data-testid":"table-customer-add-btn",children:[(0,c.jsx)(l.A,{className:u?"w-4 h-4":"w-3.5 h-3.5"})," Novo cliente"]})]}),b&&(0,c.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,c.jsx)(i.p,{autoFocus:!0,value:g,onChange:e=>f(e.target.value),onKeyDown:e=>"Enter"===e.key&&N(),placeholder:"Nome do cliente",className:"bg-[#161616] border-white/10 "+(u?"h-11":"h-8"),"data-testid":"table-customer-name"}),(0,c.jsx)(r.$,{size:"sm",onClick:N,disabled:j,className:"bg-orange-500 hover:bg-orange-600 shrink-0 "+(u?"h-11 px-4":"h-8"),"data-testid":"table-customer-save",children:"Adicionar"}),(0,c.jsx)("button",{type:"button",onClick:()=>{v(!1),f("")},className:"text-zinc-500 hover:text-zinc-300",children:(0,c.jsx)(d.A,{className:"w-4 h-4"})})]}),(0,c.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,c.jsx)("button",{type:"button",onClick:()=>m(null),className:`${w} rounded-lg font-medium border transition-colors ${t?"border-white/15 text-zinc-300 hover:bg-white/10":"bg-orange-500/15 border-orange-500/60 text-orange-300"}`,"data-testid":"table-customer-none",children:"Toda a mesa"}),x.map(e=>(0,c.jsx)("button",{type:"button",onClick:()=>m(e.id),className:`${w} rounded-lg font-medium border transition-colors ${t===e.id?"bg-orange-500/15 border-orange-500/60 text-orange-300":"border-white/15 text-zinc-300 hover:bg-white/10"}`,"data-testid":`table-customer-${e.id}`,children:e.name},e.id))]})]})}},94181(e,a,t){t.d(a,{A:()=>j,H:()=>f});var s=t(65043),n=t(91586),i=t(7020),r=t(13390),o=t(59938),l=t(65598),d=t(2733),c=t(22024),m=t(91883),p=t(56174),u=t(71360),x=t(56328),h=t(70579);const b=[],v={plans:null,sessions:[],at:0,promise:null,subs:new Set};async function g(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!1===v.plans)return;const a=Date.now()-v.at<15e3;return e||!a||null===v.plans?(v.promise||(v.promise=(async()=>{try{var e;const[a,t]=await Promise.all([n.Ay.get("/company/rodizio/plans"),n.Ay.get("/company/rodizio/sessions/active")]);v.plans=Array.isArray(a.data)?a.data:[],v.sessions=(null===(e=t.data)||void 0===e?void 0:e.sessions)||[],v.at=Date.now()}catch(t){var a;403===(null===(a=t.response)||void 0===a?void 0:a.status)&&(v.plans=!1)}finally{v.promise=null,v.subs.forEach(e=>e())}})()),v.promise):void 0}
1function f(e){const[,a]=(0,s.useState)(0);return(0,s.useEffect)(()=>{const e=()=>a(e=>e+1);return v.subs.add(e),g(),()=>v.subs.delete(e)},[]),(0,s.useMemo)(()=>e?v.sessions.filter(a=>a.table_session_id===e):b,[e,v.sessions,v.at])}function j(e){let{table:a,onChanged:t,compact:f=!1}=e;const[,j]=(0,s.useState)(0),[y,N]=(0,s.useState)(!1),[w,_]=(0,s.useState)(null),[z,A]=(0,s.useState)(2),[C,k]=(0,s.useState)(!1);(0,s.useEffect)(()=>{const e=()=>j(e=>e+1);return v.subs.add(e),g(),()=>v.subs.delete(e)},[]);const $=null===a||void 0===a?void 0:a.current_session_id,S=(0,s.useMemo)(()=>$?v.sessions.filter(e=>e.table_session_id===$):b,[$,v.sessions,v.at]),R=Array.isArray(v.plans)?v.plans.filter(e=>e.is_active):[];if(!1===v.plans)return null;if("open"!==(null===a||void 0===a?void 0:a.status)||!$)return null;if(0===S.length&&0===R.length)return null;const E=async()=>{await g(!0),null===t||void 0===t||t()},P=async(e,a)=>{const t=Math.max(1,Number(e.people_count)+a);if(t!==Number(e.people_count)){k(!0);try{await n.Ay.put(`/company/rodizio/sessions/${e.id}/people`,{people_count:t}),await E()}catch(r){var s,i;x.oR.error((null===(s=r.response)||void 0===s||null===(i=s.data)||void 0===i?void 0:i.message)||"Erro ao ajustar pessoas.")}k(!1)}},F=R.find(e=>e.id===w),D=F?"per_table"===F.charge_mode||"per_check"===F.charge_mode?Number(F.price):Number(F.price)*z:0;return(0,h.jsxs)("div",{className:"space-y-2",children:[S.map(e=>{const a=e.plan||{},t="per_table"!==a.charge_mode&&"per_check"!==a.charge_mode;return(0,h.jsxs)("div",{className:"rounded-xl border border-amber-500/30 bg-amber-500/10 p-2.5 text-xs space-y-2","data-testid":`rodizio-active-${e.id}`,children:[(0,h.jsxs)("div",{className:"flex items-center gap-1.5 font-semibold text-amber-300",children:[(0,h.jsx)(m.A,{className:"w-3.5 h-3.5"})," Rod\xedzio: ",a.name]}),(0,h.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,h.jsxs)("span",{className:"text-amber-200/80",children:[(0,d.vv)(e.total_price),t?` \xb7 ${e.people_count} pessoa${e.people_count>1?"s":""}`:" (mesa)",Number(e.served_items_count)>0?` \xb7 ${e.served_items_count} servidos`:""]}),t&&(0,h.jsxs)("span",{className:"flex items-center gap-1",children:[(0,h.jsx)("button",{type:"button",disabled:C,onClick:()=>P(e,-1),"aria-label":"Menos uma pessoa",className:"flex h-7 w-7 items-center justify-center rounded-lg border border-amber-500/30 hover:bg-amber-500/20","data-testid":`rodizio-people-dec-${e.id}`,children:(0,h.jsx)(p.A,{className:"w-3 h-3"})}),(0,h.jsx)("button",{type:"button",disabled:C,onClick:()=>P(e,1),"aria-label":"Mais uma pessoa",className:"flex h-7 w-7 items-center justify-center rounded-lg border border-amber-500/30 hover:bg-amber-500/20","data-testid":`rodizio-people-inc-${e.id}`,children:(0,h.jsx)(u.A,{className:"w-3 h-3"})})]})]}),(0,h.jsxs)("div",{className:"flex gap-2",children:[(0,h.jsx)(r.$,{type:"button",size:"sm",variant:"outline",disabled:C,onClick:()=>(async e=>{k(!0);try{await n.Ay.post(`/company/rodizio/sessions/${e.id}/end`),x.oR.success("Rod\xedzio encerrado. A cobran\xe7a segue na conta."),await E()}catch(s){var a,t;x.oR.error((null===(a=s.response)||void 0===a||null===(t=a.data)||void 0===t?void 0:t.message)||"Erro ao encerrar.")}k(!1)})(e),className:"h-8 flex-1 border-amber-500/30 text-amber-200 hover:bg-amber-500/20","data-testid":`rodizio-end-${e.id}`,children:"Encerrar"}),(0,h.jsx)(r.$,{type:"button",size:"sm",variant:"ghost",disabled:C,onClick:()=>(async e=>{if(await(0,i.Z)("Cancelar o rod\xedzio? A cobran\xe7a sai da conta da mesa.")){k(!0);try{await n.Ay.delete(`/company/rodizio/sessions/${e.id}`),x.oR.success("Rod\xedzio cancelado e cobran\xe7a removida da conta."),await E()}catch(s){var a,t;x.oR.error((null===(a=s.response)||void 0===a||null===(t=a.data)||void 0===t?void 0:t.message)||"Erro ao cancelar.")}k(!1)}})(e),className:"h-8 text-red-400 hover:bg-red-500/10","data-testid":`rodizio-cancel-${e.id}`,children:"Cancelar"})]})]},e.id)}),R.length>0&&(0,h.jsxs)(r.$,{type:"button",onClick:()=>{_(1===R.length?R[0].id:null),A(2),N(!0)},variant:"outline",className:`w-full ${f?"h-9 text-xs":"h-11"} border-amber-500/30 text-amber-300 hover:bg-amber-500/10`,"data-testid":`table-rodizio-${a.id}`,children:[(0,h.jsx)(m.A,{className:"w-4 h-4 mr-2"})," ",S.length>0?"Iniciar outro rod\xedzio":"Iniciar rod\xedzio"]}),(0,h.jsx)(l.lG,{open:y,onOpenChange:e=>{e||N(!1)},children:(0,h.jsxs)(l.Cf,{className:"bg-[#0F0F0F] border border-white/10 text-white max-w-sm",children:[(0,h.jsxs)(l.c7,{children:[(0,h.jsxs)(l.L3,{children:["Iniciar rod\xedzio \u2014 Mesa ",a.number]}),(0,h.jsx)(l.rr,{children:"A cobran\xe7a entra como pedido na conta da mesa."})]}),(0,h.jsxs)("div",{className:"space-y-3",children:[(0,h.jsxs)("div",{children:[(0,h.jsx)(o.J,{className:"mb-1 block",children:"Plano"}),(0,h.jsx)("div",{className:"space-y-2",children:R.map(e=>(0,h.jsxs)("button",{type:"button",onClick:()=>_(e.id),className:"w-full rounded-xl border p-3 text-left text-sm "+(w===e.id?"border-amber-500/60 bg-amber-500/10":"border-white/10 bg-[#161616] hover:border-white/20"),"data-testid":`rodizio-plan-option-${e.id}`,children:[(0,h.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,h.jsx)("span",{className:"font-medium",children:e.name}),(0,h.jsx)("span",{className:"font-bold text-amber-300",children:(0,d.vv)(e.price)})]}),(0,h.jsx)("div",{className:"text-[11px] text-zinc-500",children:"per_person"===e.charge_mode?"por pessoa":"per_table"===e.charge_mode?"por mesa":"por comanda"})]},e.id))})]}),F&&"per_person"===F.charge_mode&&(0,h.jsxs)("div",{children:[(0,h.jsx)(o.J,{className:"mb-1 block",children:"Pessoas"}),(0,h.jsxs)("div",{className:"flex items-center gap-3",children:[(0,h.jsx)(r.$,{type:"button",size:"icon",variant:"outline",className:"border-white/10",onClick:()=>A(Math.max(1,z-1)),"data-testid":"rodizio-start-dec",children:(0,h.jsx)(p.A,{className:"w-4 h-4"})}),(0,h.jsx)("span",{className:"w-10 text-center text-lg font-bold","data-testid":"rodizio-start-people",children:z}),(0,h.jsx)(r.$,{type:"button",size:"icon",variant:"outline",className:"border-white/10",onClick:()=>A(z+1),"data-testid":"rodizio-start-inc",children:(0,h.jsx)(u.A,{className:"w-4 h-4"})})]})]}),(0,h.jsx)(r.$,{type:"button",disabled:!w||C,onClick:async()=>
1{if(!w)return x.oR.error("Escolha o plano.");k(!0);try{await n.Ay.post("/company/rodizio/sessions",{table_session_id:$,rodizio_plan_id:w,people_count:z}),x.oR.success("Rod\xedzio iniciado \u2014 cobran\xe7a lan\xe7ada na conta."),N(!1),await E()}catch(t){var e,a;x.oR.error((null===(e=t.response)||void 0===e||null===(a=e.data)||void 0===a?void 0:a.message)||"Erro ao iniciar rod\xedzio.")}k(!1)},className:"w-full h-11 bg-amber-500 text-black font-bold hover:bg-amber-400","data-testid":"rodizio-start-confirm",children:C?(0,h.jsx)(c.A,{className:"w-4 h-4 animate-spin"}):"Iniciar"+(F?` \xb7 ${(0,d.vv)(D)}`:"")})]})]})})]})}},74451(e,a,t){t.d(a,{A:()=>w});var s=t(65043),n=t(91586),i=t(13390),r=t(65598),o=t(22024),l=t(9463),d=t(41680),c=t(65505),m=t(56898),p=t(56328),u=t(2733),x=t(92264),h=t(59938),b=t(25412),v=t(42816),g=t(73306),f=t(38144),j=t(70579);const y=["cash","pix","debit","credit","voucher","courtesy","promissory"],N={open:{label:"Aberta",c:"bg-emerald-500/10 border-emerald-500/30 text-emerald-400"},awaiting_payment:{label:"Aguardando pagamento",c:"bg-orange-500/10 border-orange-500/30 text-orange-400"},partially_paid:{label:"Parcialmente paga",c:"bg-blue-500/10 border-blue-500/30 text-blue-400"},paid:{label:"Paga",c:"bg-emerald-500/10 border-emerald-500/30 text-emerald-400"}};function w(e){var a,t;let{table:w,open:_,onOpenChange:z,companyName:A,allowPaymentFix:C=!1}=e;const[k,$]=(0,s.useState)([]),[S,R]=(0,s.useState)(null),[E,P]=(0,s.useState)(!1),[F,D]=(0,s.useState)(!1),[M,q]=(0,s.useState)(null),[O,T]=(0,s.useState)(!1),[I,L]=(0,s.useState)("total"),J="by_order"===I,[G,B]=(0,s.use
1State)(null),[H,K]=(0,s.useState)({customer_cpf_cnpj:"",customer_name:"",customer_email:""}),[U,Q]=(0,s.useState)(!1),{hasPermission:V}=(0,b.A)(),W=V("fiscal.emit"),Z=C&&V("cash.manage"),[Y,X]=(0,s.useState)(null),[ee,ae]=(0,s.useState)({}),[te,se]=(0,s.useState)(""),[ne,ie]=(0,s.useState)(!1),[re,oe]=(0,s.useState)(null),[le,de]=(0,s.useState)(""),[ce,me]=(0,s.useState)([]),[pe,ue]=(0,s.useState)([]),xe=null===w||void 0===w?void 0:w.id,he=(0,s.useCallback)(async e=>{const a=await n.Ay.get(`/company/tables/${xe}/sessions`,{params:{page:e,per_page:10}});return R(a.data),a.data.data||[]},[xe]);(0,s.useEffect)(()=>{if(!_||!xe)return;let e=!0;return $([]),R(null),q(null),L("total"),P(!0),he(1).then(a=>{e&&$(a)}).catch(a=>{var t,s;e&&p.oR.error((null===(t=a.response)||void 0===t||null===(s=t.data)||void 0===s?void 0:s.message)||"N\xe3o foi poss\xedvel carregar o hist\xf3rico.")}).finally(()=>{e&&P(!1)}),()=>{e=!1}},[_,xe,he]);const be=((null===Y||void 0===Y?void 0:Y.payments)||[]).filter(e=>ee[e.id]&&ee[e.id]!==e.payment_method),ve=be.some(e=>"promissory"===ee[e.id]),ge=S&&S.current_page<S.last_page;return(0,j.jsxs)(r.lG,{open:_,onOpenChange:e=>{e||(q(null),z(!1))},children:[(0,j.jsx)(r.Cf,{className:M?"bg-white border-0 text-black max-w-md p-0 max-h-[92dvh] overflow-hidden flex flex-col gap-0":"bg-[#161616] border-white/10 text-white max-w-lg max-h-[85dvh] overflow-y-auto",children:M?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.c7,{className:"sr-only",children:(0,j.jsxs)(r.L3,{children:["Atendimento #",null===(a=M.session)||void 0===a?void 0:a.id," \u2014 Mesa ",null===w||void 0===w?void 0:w.number]})}),(0,j.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:(0,j.jsx)(v.A,{data:M,companyName:A,groupByOrder:J,showPayments:!0,showSplit:!1,showSessionRef:!0})}),(0,j.jsxs)("div",{className:"no-print p-4 space-y-3 bg-zinc-100 shrink-0 border-t border-zinc-200",children:[(0,j.jsx)("div",{className:"grid grid-cols-2 gap-1 rounded-lg bg-zinc-200 p-1",role:"group","aria-label":"Como ver a conta",children:[{key:"total",label:"Total da mesa"},{key:"by_order",label:"Por pedido"}].map(e=>(0,j.jsx)("button",{type:"button",onClick:()=>L(e.key),"aria-pressed":I===e.key,className:"min-h-[36px] rounded-md text-sm font-semibold transition "+(I===e.key?"bg-white text-black shadow-sm":"text-zinc-600 hover:text-black"),"data-testid":`table-history-mode-${e.key}`,children:e.label},e.key))}),(0,j.jsxs)("div",{className:"flex gap-2",children:[(0,j.jsx)(g.A,{tableId:xe,sessionId:null===(t=M.session)||void 0===t?void 0:t.id,layout:J?"by_order":"consolidated",onBrowserPrint:f.h,className:"flex-1 bg-orange-500 hover:bg-orange-600 text-white"}),(0,j.jsxs)(i.$,{variant:"outline",onClick:()=>q(null),"data-testid":"table-history-back",children:[(0,j.jsx)(l.A,{className:"w-4 h-4 mr-1"})," Voltar"]})]})]})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(r.c7,{children:[(0,j.jsxs)(r.L3,{children:["Hist\xf3rico \u2014 Mesa ",null===w||void 0===w?void 0:w.number]}),(0,j.jsx)(r.rr,{className:"text-zinc-500",children:"Cada atendimento com o que foi consumido. Toque para ver a conta e imprimir o comprovante."})]}),E&&(0,j.jsx)("div",{className:"py-10 text-center text-zinc-500",children:(0,j.jsx)(o.A,{className:"w-6 h-6 mx-auto animate-spin"})}),!E&&0===k.length&&(0,j.jsx)("p",{className:"py-10 text-center text-zinc-500",children:"Esta mesa ainda n\xe3o teve atendimentos."}),(0,j.jsx)("div",{className:"space-y-2",children:k.map(e=>{var a;const t=N[e.status]||N.paid,s=0===e.orders_count&&0===Number(e.total),r=e.fiscal_invoice,o=W&&!r&&!s&&"open"!==e.status,l=Z&&(e.payments||[]).length>0;return(0,j.jsxs)("div",{className:"rounded-xl border border-white/10 transition "+(s?"opacity-60":""),children:[(0,j.jsxs)("button",{type:"button",onClick:()=>(async e=>{T(!0),L("total");try{const a=await n.Ay.get(`/company/tables/${xe}/sessions/${e.id}`);q(a.data)}catch(s){var a,t;p.oR.error((null===(a=s.response)||void 0===a||null===(t=a.data)||void 0===t?void 0:t.message)||"Atendimento n\xe3o encontrado.")}finally{T(!1)}})(e),disabled:O,className:"w-full min-h-[44px] text-left p-3 transition hover:bg-white/5 disabled:opacity-50","data-testid":`table-session-row-${e.id}`,children:[(0,j.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,j.jsxs)("span",{className:"font-semibold",children:["#",e.id]}),(0,j.jsxs)("span",{className:"flex items-center gap-1.5",children:[e.is_current&&(0,j.jsx)("span",{className:"text-[10px] px-2 py-0.5 rounded-md border border-emerald-500/30 bg-emerald-500/10 text-emerald-400",children:"Em andamento"}),(0,j.jsx)("span",{className:`text-[10px] px-2 py-0.5 rounded-md border ${t.c}`,children:t.label})]})]}),(0,j.jsxs)("div",{className:"mt-1 text-xs text-zinc-400",children:[(0,u.r6)(e.opened_at)," \u2192 ",e.closed_at?(0,u.r6)(e.closed_at):"\u2014"]}),(0,j.jsxs)("div",{className:"mt-1 flex items-center justify-between gap-2 text-sm",children:[(0,j.jsx)("span",{className:"text-zinc-300",children:s?"Sem consumo (liberada automaticamente)":`${e.orders_count} pedido${1===e.orders_count?"":"s"}`}),(0,j.jsx)("span",{className:"font-semibold",children:(0,u.vv)(e.total)})]}),(0,j.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-[11px] text-zinc-500",children:[(null===(a=e.waiter)||void 0===a?void 0:a.name)&&(0,j.jsxs)("span",{children:["\ud83d\udc64 ",e.waiter.name]}),(e.payment_methods||[]).map(e=>(0,j.jsx)("span",{className:"px-1.5 py-0.5 rounded bg-white/5 text-zinc-400",children:u.tK[e]||e},e)),Number(e.remaining)>0&&(0,j.jsxs)("span",{className:"text-orange-400",children:["Falta ",(0,u.vv)(e.remaining)]})]})]}),(r||o||l)&&(0,j.jsxs)("div",{className:"px-3 pb-3 -mt-1 flex items-center justify-between gap-2 flex-wrap",children:[r?(0,j.jsxs)("span",{className:"text-[11px] text-emerald-400/90 inline-flex items-center gap-1","data-testid":`table-session-invoice-${e.id}`,children:[(0,j.jsx)(d.A,{className:"w-3.5 h-3.5"}),"nfe"===r.document_type?"NF-e":"Cupom"," ",r.invoice_number?`#${r.invoice_number}`:"em processamento"]}):(0,j.jsx)("span",{className:"text-[11px] text-zinc-500",children:"Sem cupom fiscal"}),(0,j.jsxs)("span",{className:"flex items-center gap-2",children:[l&&(0,j.jsxs)(i.$,{size:"sm",variant:"outline",onClick:()=>{return a=e,ae({}),se(""),oe(null),de(""),me([]),ue([]),void X(a);var a},className:"h-8 border-white/10 text-zinc-200 hover:bg-white/5",title:"Corrigir a forma de pagamento \u2014 ajusta o caixa daquele dia","data-testid":`table-session-fix-payment-${e.id}`,children:[(0,j.jsx)(c.A,{className:"w-3.5 h-3.5 mr-1"})," Forma de pagamento"]}),o&&(0,j.jsxs)(i.$,{size:"sm",onClick:()=>{return a=e,K({customer_cpf_cnpj:"",customer_name:"",customer_email:""}),void B(a);var a},className:"h-8 bg-orange-500 hover:bg-orange-600 text-white","data-testid":`table-session-emit-${e.id}`,children:[(0,j.jsx)(m.A,{className:"w-3.5 h-3.5 mr-1"})," Emitir cupom"]})]})]})]},e.id)})}),ge&&(0,j.jsxs)(i.$,{variant:"outline",onClick:async()=>{D(!0);try{const e=await he(((null===S||void 0===S?void 0:S.current_page)||1)+1);$(a=>[...a,...e])}catch(t){var e,a;p.oR.error((null===(e=t.response)||void 0===e||null===(a=e.data)||void 0===a?void 0:a.message)||"N\xe3o foi poss\xedvel carregar mais atendimentos.")}finally{D(!1)}},disabled:F,className:"w-full h-11 border-white/10 text-zinc-200 hover:bg-white/5","data-testid":"table-history-more",children:[F?(0,j.jsx)(o.A,{className:"w-4 h-4 mr-2 animate-spin"}):(0,j.jsx)(m.A,{className:"w-4 h-4 mr-2"}),"Carregar mais"]})]})}),(0,j.jsx)(r.lG,{open:!!Y,onOpenChange:e=>{e||ne||X(null)},children:(0,j.jsxs)(r.Cf,{className:"bg-[#161616] border-white/10 text-white max-w-md max-h-[85dvh] overflow-y-auto","data-testid":"table-session-payments-dialog",children:[(0,j.jsxs)(r.c7,{children:[(0,j.jsx)(r.L3,{children:"Corrigir forma de pagamento"}),(0,j.jsxs)(r.rr,{className:"text-zinc-500",children:["Atendimento #",null===Y||void 0===Y?void 0:Y.id,". A corre\xe7\xe3o ajusta o caixa do dia em que a mesa foi paga \u2014 n\xe3o lan\xe7a nada hoje."]})]}),(0,j.jsxs)("div",{className:"space-y-3",children:[((null===Y||void 0===Y?void 0:Y.payments)||[]).map(e=>{var a,t;return(0,j.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border border-white/10 p-2","data-testid":`table-payment-row-${e.id}`,children:[(0,j.jsxs)("div",{className:"min-w-[92px]",children:[(0,j.jsx)("div",{className:"font-semibold text-sm",children:(0,u.vv)(e.amount)}),(0,j.jsx)("div",{className:"text-[11px] text-zinc-500",children:(0,u.r6)(e.paid_at)})]}),(0,j.jsxs)("select",{value:null!==(a=null!==(t=ee[e.id])&&void 0!==t?t:e.payment_method)&&void 0!==a?a:"",onCh
1ange:a=>ae(t=>({...t,[e.id]:a.target.value})),disabled:ne,className:"flex-1 bg-[#0A0A0A] border border-white/10 rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-orange-500/50","data-testid":`table-payment-method-${e.id}`,children:[!y.includes(e.payment_method)&&(0,j.jsxs)("option",{value:e.payment_method||"",children:[u.tK[e.payment_method]||e.payment_method||"\u2014"," (atual)"]}),y.map(e=>(0,j.jsx)("option",{value:e,children:u.tK[e]||e},e))]})]},e.id)}),ve&&(0,j.jsxs)("div",{className:"relative",children:[(0,j.jsx)(h.J,{className:"text-zinc-400",children:"Cliente da promiss\xf3ria (fiado)"}),(0,j.jsx)(x.p,{value:re?re.name:le,onChange:e=>{oe(null),(async e=>{if(de(e),e.trim().length<2)me([]);else try{var a;const t=await n.Ay.get("/company/customers",{params:{search:e.trim()}});me(((null===(a=t.data)||void 0===a?void 0:a.data)||t.data||[]).slice(0,6))}catch{me([])}})(e.target.value)},placeholder:"Buscar cliente liberado para fiado",className:"bg-[#0A0A0A] border-white/10","data-testid":"table-payment-customer"}),ce.length>0&&!re&&(0,j.jsx)("div",{className:"absolute z-20 mt-1 w-full max-h-40 overflow-auto rounded-lg border border-white/10 bg-[#0A0A0A] shadow-xl",children:ce.map(e=>(0,j.jsxs)("button",{type:"button",onClick:()=>{oe(e),me([])},className:"block w-full text-left px-3 py-2 text-sm hover:bg-white/5",children:[e.name,e.phone?(0,j.jsxs)("span",{className:"text-zinc-500",children:[" \xb7 ",e.phone]}
1):null]},e.id))})]}),(0,j.jsxs)("div",{children:[(0,j.jsx)(h.J,{className:"text-zinc-400",children:"Motivo da corre\xe7\xe3o"}),(0,j.jsx)(x.p,{value:te,onChange:e=>se(e.target.value),placeholder:"Ex.: cliente pagou no cr\xe9dito, lan\xe7ado como dinheiro",className:"bg-[#0A0A0A] border-white/10","data-testid":"table-payment-reason"}),(0,j.jsx)("p",{className:"text-[11px] text-zinc-500 mt-1",children:"Fica registrado com seu usu\xe1rio no pagamento e no movimento do caixa."})]}),pe.length>0&&(0,j.jsx)("div",{className:"rounded-lg border border-amber-500/20 bg-amber-500/5 p-2 space-y-1","data-testid":"table-payment-warnings",children:pe.map(e=>(0,j.jsxs)("p",{className:"text-[11px] text-amber-300/90",children:["\u26a0 ",e.message]},e.code))}),(0,j.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,j.jsx)(i.$,{variant:"outline",onClick:()=>X(null),disabled:ne,className:"border-white/10 text-zinc-200 hover:bg-white/5",children:pe.length?"Fechar":"Cancelar"}),(0,j.jsxs)(i.$,{onClick:async()=>{if(!be.length||ne)return;if(te.trim().length<3)return void p.oR.error("Descreva o motivo da corre\xe7\xe3o.");if(ve&&!re)return void p.oR.error("Selecione o cliente da promiss\xf3ria (fiado).");ie(!0);let e=null;const a=[],t=[],s=[];for(const d of be)try{var i;const{data:t}=await n.Ay.put(`/company/tables/${xe}/payments/${d.id}/method`,{payment_method:ee[d.id],reason:te.trim(),customer_id:"promissory"===ee[d.id]?null===re||void 0===re?void 0:re.id:void 0});e=t,a.push(d),s.push(...(null===t||void 0===t||null===(i=t.correction)||void 0===i?void 0:i.warnings)||[])}catch(l){var r,o;t.push({p:d,message:(null===(r=l.response)||void 0===r||null===(o=r.data)||void 0===o?void 0:o.message)||"Falha ao corrigir."})}if(ie(!1),a.length){const e=s.some(e=>"cash_movement_missing"===e.code);p.oR.success(`${a.length} pagamento(s) corrigido(s).${e?"":" O caixa daquele dia foi ajustado."}`)}if(t.forEach(e=>p.oR.error(`${(0,u.vv)(e.p.amount)}: ${e.message}`)),ue(s.filter((e,a,t)=>t.findIndex(a=>a.code===e.code)===a)),e){const a=(e.payments||[]).filter(e=>"paid"===e.status).map(e=>({id:e.id,payment_method:e.payment_method,amount:Number(e.amount),paid_at:e.paid_at}));$(e=>e.map(e=>e.id===Y.id?{...e,payments:a,payment_methods:[...new Set(a.map(e=>e.payment_method))]}:e)),X(e=>e?{...e,payments:a}:e),ae({})}},disabled:ne||!be.length,className:"bg-orange-500 hover:bg-orange-600","data-testid":"table-payment-save",children:[ne?(0,j.jsx)(o.A,{className:"w-4 h-4 mr-1 animate-spin"}):(0,j.jsx)(c.A,{className:"w-4 h-4 mr-1"}),"Corrigir ",be.length||""]})]})]})]})}),(0,j.jsx)(r.lG,{open:!!G,onOpenChange:e=>{e||U||B(null)},children:(0,j.jsxs)(r.Cf,{className:"bg-[#161616] border-white/10 text-white max-w-sm","data-testid":"table-session-fiscal-dialog",children:[(0,j.jsxs)(r.c7,{children:[(0,j.jsx)(r.L3,{children:"Emitir cupom fiscal"}),(0,j.jsxs)(r.rr,{className:"text-zinc-500",children:["Atendimento #",null===G||void 0===G?void 0:G.id," \u2014 ",(0,u.vv)(null===G||void 0===G?void 0:G.total),". O cupom sai com todos os pedidos, a taxa de servi\xe7o e o couvert da mesa."]})]}),(0,j.jsxs)("div",{className:"space-y-3",children:[(0,j.jsxs)("div",{children:[(0,j.jsx)(h.J,{className:"text-zinc-400",children:"CPF/CNPJ do cliente (opcional)"}),(0,j.jsx)(x.p,{value:H.customer_cpf_cnpj,onChange:e=>K(a=>({...a,customer_cpf_cnpj:(0,u.ux)(e.target.value)})),placeholder:"Deixe em branco para consumidor n\xe3o identificado",className:"bg-[#0A0A0A] border-white/10","data-testid":"table-session-fiscal-doc"})]}),(0,j.jsxs)("div",{children:[(0,j.jsx)(h.J,{className:"text-zinc-400",children:"Nome (opcional)"}),(0,j.jsx)(x.p,{value:H.customer_name,onChange:e=>K(a=>({...a,customer_name:e.target.value})),className:"bg-[#0A0A0A] border-white/10"})]}),(0,j.jsxs)("div",{children:[(0,j.jsx)(h.J,{className:"text-zinc-400",children:"E-mail (opcional)"}),(0,j.jsx)(x.p,{type:"email",value:H.customer_email,onChange:e=>K(a=>({...a,customer_email:e.target.value})),className:"bg-[#0A0A0A] border-white/10"})]}),(0,j.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,j.jsx)(i.$,{variant:"outline",onClick:()=>B(null),disabled:U,className:"border-white/10 text-zinc-200 hover:bg-white/5",children:"Cancelar"}),(0,j.jsxs)(i.$,{onClick:async()=>
1{if(G&&!U){Q(!0);try{const{data:e}=await n.Ay.post(`/company/fiscal/table-sessions/${G.id}/invoice`,{customer_cpf_cnpj:H.customer_cpf_cnpj.replace(/\D/g,"")||null,customer_name:H.customer_name||null,customer_email:H.customer_email||null,print:!1});p.oR.success("Cupom fiscal solicitado."),$(a=>a.map(a=>a.id===G.id?{...a,fiscal_invoice:{id:e.id,invoice_number:e.invoice_number,status:e.status,document_type:e.document_type}}:a)),B(null)}catch(t){var e,a;p.oR.error((null===(e=t.response)||void 0===e||null===(a=e.data)||void 0===a?void 0:a.message)||"N\xe3o foi poss\xedvel emitir o cupom.")}finally{Q(!1)}}},disabled:U,className:"bg-orange-500 hover:bg-orange-600","data-testid":"table-session-fiscal-submit",children:[U?(0,j.jsx)(o.A,{className:"w-4 h-4 mr-1 animate-spin"}):(0,j.jsx)(m.A,{className:"w-4 h-4 mr-1"}),"Emitir cupom"]})]})]})]})})]})}},38144(e,a,t){t.d(a,{h:()=>s});function s(){const e=document.querySelector(".bill-print");if(!e)return;const a=window.open("","_blank");a&&(a.document.write(`<!DOCTYPE html>\n<html>\n<head>\n<meta charset="utf-8">\n<title>Conta</title>\n<style>\n*, ::before, ::after { box-sizing: border-box; border-width: 0; border-style: solid; border-color: black; }\nhtml, body { margin: 0; padding: 0; background: white; font-family: Arial, Helvetica, sans-serif; }\n.flex { display: flex; }\n.justify-between { justify-content: space-between; }\n.items-baseline { align-items: baseline; }\n.text-center { text-align: center; }\n.font-bold { font-weight: bold; }\n.italic { font-style: italic; }\n.flex-1 { flex: 1 1 0%; }\n.text-2xl { font-size: 1.5rem; }\n.text-3xl { font-size: 1.875rem; }\n.text-xl { font-size: 1.25rem; }\n.text-lg { font-size: 1.125rem; }\n.text-base { font-size: 1rem; }\n.text-sm { font-size: 0.875rem; }\n.p-6 { padding: 1.5rem; }\n.bg-white { background: white; }\n.text-black { color: black; }\n.max-w-md { max-width: 28rem; margin-left: auto; margin-right: auto; }\n.leading-snug { line-height: 1.375; }\n.pb-3 { padding-bottom: 0.75rem; }\n.mb-3 { margin-bottom: 0.75rem; }\n.mb-2 { margin-bottom: 0.5rem; }\n.mb-1 { margin-bottom: 0.25rem; }\n.mt-1 { margin-top: 0.25rem; }\n.mt-4 { margin-top: 1rem; }\n.pt-2 { padding-top: 0.5rem; }\n.pt-1 { padding-top: 0.25rem; }\n.pt-3 { padding-top: 0.75rem; }\n.pl-3 { padding-left: 0.75rem; }\n.border-b-2 { border-bottom-width: 2px; }\n.border-t { border-top-width: 1px; }\n.border-t-2 { border-top-width: 2px; }\n.border-dashed { border-style: dashed; }\n.border-black { border-color: black; }\n.text-gray-500 { color: #6b7280; }\n.text-gray-600 { color: #4b5563; }\n.text-gray-700 { color: #374151; }\n.space-y-1 > * + * { margin-top: 0.25rem; }\n.h-14 { height: 3.5rem; }\n.no-print { display: none !important; }\n\n@page { margin: 0; size: 80mm auto; }\n.bill-print {\n    position: static !important;\n    width: 100% !important;\n    padding: 8mm !important;\n    box-sizing: border-box !important;\n    font-family: Arial, Helvetica, sans-serif !important;\n    font-size: 20px !important;\n    font-weight: 700 !important;\n    line-height: 1.42 !important;\n    -webkit-print-color-adjust: exact !important;\n    print-color-adjust: exact !important;\n}\n.bill-print h1 { font-size: 28px !important; font-weight: 900 !important; }\n.bill-print .print-small { font-size: 18px !important; font-weight: 700 !important; line-height: 1.38 !important; }\n.bill-print .print-option { font-weight: 700 !important; }\n.bill-print .print-total { font-size: 26px !important; font-weight: 900 !important; }\n.bill-print .border-dashed { border-style: solid !important; }\n.no-print { display: none !important; }\n</style>\n</head>\n<body>${e.outerHTML}</body>\n</html>`),a.document.close(),setTimeout(()=>{a.print(),a.close()},150))}}}]);
2//# sourceMappingURL=7840.ddbae82a.chunk.js.map

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.