PageSourceSearch

https://alinhafood.com.br/_next/static/chunks/2558.b9ff5efa12ebc69a.js

js alinhafood.com.br collected 2026-09-24 14:35:09 UTC 17,784 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2558],{12558:(e,t,a)=>{a.r(t),a.d(t,{default:()=>z});var s=a(95155),l=a(12115),r=a(14272),o=a(67592),n=a(78384),c=a(28394),i=a(35637),d=a(89559),x=a(6191),u=a(86651),b=a(19408),p=a(69141),m=a(23664),h=a(45345),f=a(26983),g=a(61362),j=a(78874),v=a(21190),N=a(71360),w=a(65229);async function k(){var e,t;let{data:a}=await (0,r.U)("admin").auth.getSession();return null!=(t=null==(e=a.session)?void 0:e.access_token)?t:""}let y=["Alimentos","Bebidas","Embalagens","Limpeza","G\xe1s e Combust\xedvel","Equipamentos","Servi\xe7os","Outros"],C=()=>({nome:"",cnpj:"",cpf:"",telefone:"",email:"",categoria:"",endereco:"",contato:"",prazo_pagamento:30,observacao:"",ativo:!0,lead_time_dias:0,pedido_minimo_valor:0,pedido_minimo_quantidade:0});function z(){var e,t,a,r,z,_,A,S,E,F,P,L,q;let{showToast:T}=(0,o.d)(),{restaurantId:B}=(0,n.p)(),[J,O]=(0,l.useState)([]),[I,D]=(0,l.useState)(!0),[H,M]=(0,l.useState)(""),[R,U]=(0,l.useState)("all"),[G,Q]=(0,l.useState)(!1),[V,$]=(0,l.useState)(null),[K,W]=(0,l.useState)(C()),[X,Y]=(0,l.useState)(!1),[Z,ee]=(0,l.useState)(null),et=async()=>{if(!B){O([]),D(!1);return}D(!0);let e=await k(),t=(0,c.H)("/api/admin/financeiro/fornecedores",B,{includeInactive:!0});if(!t)return void D(!1);let a=await fetch(t,{headers:{authorization:"Bearer ".concat(e)}});a.ok&&O(await a.json()),D(!1)};(0,l.useEffect)(()=>{et()},[B]);let ea=async()=>{var e,t;if(!(null==(e=K.nome)?void 0:e.trim()))return T("Nome \xe9 obrigat\xf3rio.","error");if(!B)return T("Selecione um restaurante.","error");Y(!0);let a=await k(),s=V?"/api/admin/financeiro/fornecedores/".concat(V.id):"/api/admin/financeiro/fornecedores",l=V?"PUT":"POST",r=(0,c.H)(s,B);if(!r)return Y(!1),T("Selecione um restaurante.","error");let o=await fetch(r,{method:l,headers:{authorization:"Bearer ".concat(a),"content-type":"application/json"},body:JSON.stringify((0,c.o)(B,K))});Y(!1),o.ok?(T(V?"Fornecedor atualizado!":"Fornecedor cadastrado!","success"),Q(!1),et()):T(null!=(t=(await o.json()).error)?t:"Erro ao salvar","error")},es=async()=>{if(!Z)return;if(!B)return T("Selecione um restaurante.","error");let e=await k(),t=(0,c.H)("/api/admin/financeiro/fornecedores/".concat(Z.id),B);if(!t)return T("Selecione um restaurante.","error");(await fetch(t,{method:"DELETE",headers:{authorization:"Bearer ".concat(e)}})).ok?(T("Fornecedor desativado.","success"),ee(null),et()):T("Erro ao desativar.","error")},el=[...new Set(J.map(e=>e.categoria).filter(Boolean))],er=J.filter(e=>{var t,a;let s=H.toLowerCase(),l=!s||e.nome.toLowerCase().includes(s)||(null!=(t=e.cnpj)?t:"").includes(s)||(null!=(a=e.email)?a:"").toLowerCase().includes(s),r="all"===R||e.categoria===R;return l&&r}),eo=J.filter(e=>e.ativo).length,en=J.filter(e=>!e.ativo).length;return(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-xl font-black text-slate-900",children:"Fornecedores"}),(0,s.jsxs)("p",{className:"text-xs text-slate-400 mt-0.5",children:[eo," ativos \xb7 ",en," inativos"]})]}),(0,s.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,s.jsxs)("button",{onClick:et,className:"flex items-center gap-2 px-4 py-2 bg-white border border-slate-200 rounded-xl text-sm font-bold text-slate-600 hover:bg-slate-50 cursor-pointer transition-colors",children:[(0,s.jsx)(d.A,{size:14})," Atualizar"]}),(0,s.jsxs)("button",{onClick:()=>{$(null),W(C()),Q(!0)},className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-xl text-sm font-black cursor-pointer hover:bg-blue-700 transition-colors shadow-md shadow-blue-600/20",children:[(0,s.jsx)(x.A,{size:14})," Novo Fornecedor"]})]})]}),(0,s.jsx)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[{label:"Total",value:J.length,cls:"text-slate-700",bg:"bg-slate-50"},{label:"Ativos",value:eo,cls:"text-emerald-600",bg:"bg-emerald-50"},{label:"Categorias",value:el.length,cls:"text-blue-600",bg:"bg-blue-50"},{label:"Inativos",value:en,cls:"text-slate-400",bg:"bg-slate-50"}].map((e,t)=>(0,s.jsxs)("div",{className:"rounded-2xl border border-slate-100 p-4 ".concat(e.bg),children:[(0,s.jsx)("p",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-1",children:e.label}),(0,s.jsx)("p",{className:"text-2xl font-black ".concat(e.cls),children:e.value})]},t))}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,s.jsxs)("div",{className:"relative flex-1 min-w-[200px]",children:[(0,s.jsx)(u.A,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-400"}),(0,s.jsx)("input",{value:H,onChange:e=>M(e.target.value),placeholder:"Buscar por nome, CNPJ ou e-mail...",className:"w-full pl-9 pr-4 py-2.5 border border-slate-200 rounded-xl text-sm focus:outline-none focus:border-blue-400 bg-white"})]}),(0,s.jsxs)("select",{value:R,onChange:e=>U(e.target.value),className:"px-3 py-2.5 border border-slate-200 rounded-xl text-sm bg-white focus:outline-none focus:border-blue-400 cursor-pointer",children:[(0,s.jsx)("option",{value:"all",children:"Todas categorias"}),el.map(e=>(0,s.jsx)("option",{value:e,children:e},e))]})]}),I?(0,s.jsx)("div",{className:"flex justify-center py-16",children:(0,s.jsx)("div",{className:"w-8 h-8 border-4 border-blue-200 border-t-blue-600 rounded-full animate-spin"})}):0===er.length?(0,s.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-100 p-12 text-center",children:[(0,s.jsx)(b.A,{size:32,className:"mx-auto text-slate-200 mb-3"}),(0,s.jsx)("p",{className:"text-slate-400 font-bold",children:"Nenhum fornecedor encontrado"}),(0,s.jsx)("p",{className:"text-sm text-slate-400 mt-1",children:'Clique em "Novo Fornecedor" para cadastrar'})]}):(0,s.jsx)("div",{className:"bg-white rounded-2xl border border-slate-200 shadow-sm overflow-hidden",children:(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full text-left text-sm",children:[(0,s.jsx)("thead",{className:"bg-slate-50 text-[10px] uppercase tracking-widest text-slate-400 font-black",children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{className:"px-4 py-3 border-b border-slate-200",children:"Fornecedor"}),(0,s.jsx)("th",{className:"px-4 py-3 border-b border-slate-200",children:"Contato"}),(0,s.jsx)("th",{className:"px-4 py-3 border-b border-slate-200",children:"Categoria"}),(0,s.jsx)("th",{className:"px-4 py-3 border-b border-slate-200 text-center",children:"Prazo"}),(0,s.jsx)("th",{className:"px-4 py-3 border-b border-slate-200 text-center",children:"Status"}),(0,s.jsx)("th",{className:"px-4 py-3 border-b border-slate-200 text-center",children:"A\xe7\xf5es"})]})}),(0,s.jsx)("tbody",{children:er.map((e,t)=>(0,s.jsxs)("tr",{className:"".concat(t%2==0?"bg-white":"bg-slate-50/40"," hover:bg-blue-50/20 transition-colors"),children:[(0,s.jsxs)("td",{className:"px-4 py-3 border-b border-slate-100",children:[(0,s.jsx)("p",{className:"font-bold text-slate-800",children:e.nome}),e.cnpj&&(0,s.jsxs)("p",{className:"text-[11px] text-slate-400 mt-0.5",children:["CNPJ: ",e.cnpj]}),e.cpf&&(0,s.jsxs)("p",{className:"text-[11px] text-slate-400 mt-0.5",children:["CPF: ",e.cpf]})]}),(0,s.jsxs)("td",{className:"px-4 py-3 border-b border-slate-100",children:[e.telefone&&(0,s.jsxs)("div",{className:"flex items-center gap-1 text-xs text-slate-600",children:[(0,s.jsx)(p.A,{size:11}),e.telefone]}),e.email&&(0,s.jsxs)("div",{className:"flex items-center gap-1 text-xs text-slate-500 mt-0.5",children:[(0,s.jsx)(m.A,{size:11}),e.email]}),e.contato&&(0,s.jsx)("p",{className:"text-[11px] text-slate-400 mt-0.5",children:e.contato})]}),(0,s.jsx)("td",{className:"px-4 py-3 border-b border-slate-100",children:e.categoria?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-blue-50 text-blue-700 rounded-full text-[10px] font-black",children:[(0,s.jsx)(h.A,{size:9}),e.categoria]}):(0,s.jsx)("span",{className:"text-slate-300",children:"—"})}),(0,s.jsx)("td",{className:"px-4 py-3 border-b border-slate-100 text-center",children:e.prazo_pagamento?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-slate-600",children:[(0,s.jsx)(f.A,{size:11}),e.prazo_pagamento,"d"]}):"—"}),(0,s.jsx)("td",{className:"px-4 py-3 border-b border-slate-100 text-center",children:e.ativo?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] font-black text-emerald-600 bg-emerald-50 px-2 py-0.5 rounded-full",children:[(0,s.jsx)(g.A,{size:10}),"Ativo"]}):(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] font-black text-slate-400 bg-slate-100 px-2 py-0.5 rounded-full",children:[(0,s.jsx)(j.A,{size:10}),"Inativo"]})}),(0,s.jsx)("td",{className:"px-4 py-3 border-b border-slate-100",children:(0,s.jsxs)("div",{className:"flex items-center justify-center gap-1",children:[(0,s.jsx)("button",{onClick:()=>{$(e),W({...e}),Q(!0)},className:"p-1.5 rounded-lg bg-slate-100 hover:bg-blue-100 hover:text-blue-600 text-slate-500 cursor-pointer transition-colors",children:(0,s.jsx)(v.A,{size:13})}),e.ativo&&(0,s.jsx)("button",{onClick:()=>ee(e),className:"p-1.5 rounded-lg bg-slate-100 hover:bg-red-100 hover:text-red-600 text-slate-500 cursor-pointer transition-colors",children:(0,s.jsx)(N.A,{size:13})})]})})]},e.id))})]})})}),G&&(0,s.jsx)("div",{className:"fixed inset-0 bg-black/50 z-[200] flex items-center justify-center p-4",children:(0,s.jsxs)("div",{className:"bg-white rounded-2xl w-full max-w-lg shadow-2xl max-h-[90vh] overflow-y-auto",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-slate-100 sticky top-0 bg-white z-10",children:[(0,s.jsx)("h3",{className:"text-lg font-black text-slate-800",children:V?"Editar Fornecedor":"Novo Fornecedor"}),(0,s.jsx)("button",{onClick:()=>Q(!1),className:"text-slate-400 hover:text-slate-600 cursor-pointer",children:(0,s.jsx)(w.A,{size:20})})]}),(0,s.jsxs)("div",{className:"p-6 space-y-4",children:[(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1.5",children:"Nome *"}),(0,s.jsx)("input",{value:null!=(e=K.nome)?e:"",onChange:e=>W(t=>({...t,nome:e.target.value})),placeholder:"Nome do fornecedor",className:"w-full px-3 py-2.5 border border-slate-200 rounded-xl text-sm focus:outline-none focus:border-blue-400"})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1.5",children:"CNPJ"}),(0,s.jsx)("input",{value:null!=(t=K.cnpj)?t:"",onChange:e=>W(t=>({...t,cnpj:e.target.value})),placeholder:"00.000.000/0000-00",className:"w-full px-3 py-2.5 border border-slate-200 rounded-xl text-sm focus:outline-none focus:border-blue-400"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1.5",children:"CPF"}
1),(0,s.jsx)("input",{value:null!=(a=K.cpf)?a:"",onChange:e=>W(t=>({...t,cpf:e.target.value})),placeholder:"000.000.000-00",className:"w-full px-3 py-2.5 border border-slate-200 rounded-xl text-sm focus:outline-none focus:border-blue-400"})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1.5",children:"Telefone"}),(0,s.jsx)("input",{value:null!=(r=K.telefone)?r:"",onChange:e=>W(t=>({...t,telefone:e.target.value})),placeholder:"(00) 00000-0000",className:"w-full px-3 py-2.5 border border-slate-200 rounded-xl text-sm focus:outline-none focus:border-blue-400"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1.5",children:"E-mail"}),(0,s.jsx)("input",{value:null!=(z=K.email)?z:"",onChange:e=>W(t=>({...t,email:e.target.value})),placeholder:"[email protected]",className:"w-full px-3 py-2.5 border border-slate-200 rounded-xl text-sm focus:outline-none focus:border-blue-400"})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1.5",children:"Categoria"}),(0,s.jsxs)("select",{value:null!=(_=K.categoria)?_:"",onChange:e=>W(t=>({...t,categoria:e.target.value})),className:"w-full px-3 py-2.5 border border-slate-200 rounded-xl text-sm focus:outline-none focus:border-blue-400 bg-white cursor-pointer",children:[(0,s.jsx)("option",{value:"",children:"Selecionar..."}),y.map(e=>(0,s.jsx)("option",{value:e,children:e},e))]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1.5",children:"Prazo de Pagamento (dias)"}),(0,s.jsx)("input",{type:"number",min:0,value:null!=(A=K.prazo_pagamento)?A:30,onChange:e=>W(t=>({...t,prazo_pagamento:Number(e.target.value)})),className:"w-full px-3 py-2.5 border border-slate-200 rounded-xl text-sm focus:outline-none focus:border-blue-400"})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1.5",children:"Lead Time (dias)"}),(0,s.jsx)("input",{type:"number",min:0,value:null!=(S=K.lead_time_dias)?S:0,onChange:e=>W(t=>({...t,lead_time_dias:Number(e.target.value)})),className:"w-full px-3 py-2.5 border border-slate-200 rounded-xl text-sm focus:outline-none focus:border-blue-400"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1.5",children:"Pedido M\xedn. (Qtd)"}),(0,s.jsx)("input",{type:"number",min:0,step:"0.001",value:null!=(E=K.pedido_minimo_quantidade)?E:0,onChange:e=>W(t=>({...t,pedido_minimo_quantidade:Number(e.target.value)})),className:"w-full px-3 py-2.5 border border-slate-200 rounded-xl text-sm focus:outline-none focus:border-blue-400"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1.5",children:"Pedido M\xedn. (R$)"}),(0,s.jsx)(i.A,{value:null!=(F=K.pedido_minimo_valor)?F:0,onValueChange:e=>W(t=>({...t,pedido_minimo_valor:null!=e?e:0})),className:"w-full pr-3 py-2.5 border border-slate-200 rounded-xl text-sm focus:outline-none focus:border-blue-400"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1.5",children:"Nome do Contato"}),(0,s.jsx)("input",{value:null!=(P=K.contato)?P:"",onChange:e=>W(t=>({...t,contato:e.target.value})),placeholder:"Ex: Jo\xe3o Silva",className:"w-full px-3 py-2.5 border border-slate-200 rounded-xl text-sm focus:outline-none focus:border-blue-400"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1.5",children:"Endere\xe7o"}
1),(0,s.jsx)("input",{value:null!=(L=K.endereco)?L:"",onChange:e=>W(t=>({...t,endereco:e.target.value})),placeholder:"Rua, n\xfamero, bairro...",className:"w-full px-3 py-2.5 border border-slate-200 rounded-xl text-sm focus:outline-none focus:border-blue-400"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1.5",children:"Observa\xe7\xe3o"}),(0,s.jsx)("textarea",{value:null!=(q=K.observacao)?q:"",onChange:e=>W(t=>({...t,observacao:e.target.value})),rows:2,placeholder:"Informa\xe7\xf5es adicionais...",className:"w-full px-3 py-2.5 border border-slate-200 rounded-xl text-sm focus:outline-none focus:border-blue-400 resize-none"})]})]}),(0,s.jsxs)("div",{className:"flex gap-3 pt-2",children:[(0,s.jsx)("button",{onClick:()=>Q(!1),className:"flex-1 py-3 border border-slate-200 rounded-xl text-sm font-bold text-slate-500 hover:bg-slate-50 cursor-pointer transition-colors",children:"Cancelar"}),(0,s.jsx)("button",{onClick:ea,disabled:X,className:"flex-1 py-3 bg-blue-600 text-white rounded-xl text-sm font-black cursor-pointer hover:bg-blue-700 transition-colors disabled:opacity-50",children:X?"Salvando...":V?"Salvar Altera\xe7\xf5es":"Cadastrar Fornecedor"})]})]})]})}),Z&&(0,s.jsx)("div",{className:"fixed inset-0 bg-black/50 z-[300] flex items-center justify-center p-4",children:(0,s.jsxs)("div",{className:"bg-white rounded-2xl w-full max-w-sm p-6 shadow-2xl",children:[(0,s.jsx)("h3",{className:"text-lg font-black text-slate-800 mb-2",children:"Desativar fornecedor?"}),(0,s.jsxs)("p",{className:"text-sm text-slate-500 mb-6",children:[(0,s.jsx)("strong",{children:Z.nome})," ser\xe1 desativado. Os dados hist\xf3ricos s\xe3o preservados."]}),(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsx)("button",{onClick:()=>ee(null),className:"flex-1 py-3 border border-slate-200 rounded-xl text-sm font-bold cursor-pointer hover:bg-slate-50",children:"Cancelar"}),(0,s.jsx)("button",{onClick:es,className:"flex-1 py-3 bg-red-600 text-white rounded-xl text-sm font-black cursor-pointer hover:bg-red-700",children:"Desativar"})]})]})})]})}},21190:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(71847).A)("pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]])},23664:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(71847).A)("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]])}}]);

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.