PageSourceSearch

https://alinhafood.com.br/_next/static/chunks/42465.13436e356175c95b.js

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

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[42465],{42465:(e,t,a)=>{a.r(t),a.d(t,{default:()=>v});var s=a(95155),r=a(12115),l=a(14272),d=a(78384),n=a(67592),i=a(28394),c=a(73482),o=a(47937),x=a(29502),m=a(85843),h=a(86651),b=a(89559),u=a(61362);let p=e=>Number(null!=e?e:0).toLocaleString("pt-BR",{style:"currency",currency:"BRL"}),f=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;return Number(null!=e?e:0).toLocaleString("pt-BR",{minimumFractionDigits:0,maximumFractionDigits:t})};async function g(){var e,t;let{data:a}=await (0,l.U)("admin").auth.getSession();return null!=(t=null==(e=a.session)?void 0:e.access_token)?t:""}function v(){let{restaurantId:e}=(0,d.p)(),{showToast:t}=(0,n.d)(),[a,l]=(0,r.useState)("fichas");return(0,s.jsxs)("div",{className:"flex flex-col h-full bg-bg-base",children:[(0,s.jsxs)("div",{className:"border-b border-border-brand bg-white px-6 max-md:px-3 py-5",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-2xl font-black text-text-main font-[family-name:var(--font-heading)]",children:"Diagn\xf3stico operacional"}),(0,s.jsx)("p",{className:"mt-1 text-sm text-text-sec",children:"Encontre buracos de cadastro que est\xe3o comprometendo seu DRE e estoque."})]}),(0,s.jsx)("div",{className:"mt-4 inline-flex max-md:flex max-md:w-full max-md:overflow-x-auto rounded-xl border border-border-brand bg-bg-base p-1 gap-1",children:[{id:"fichas",label:"Produtos sem ficha",icon:(0,s.jsx)(o.A,{size:14})},{id:"validade",label:"Validade de insumos",icon:(0,s.jsx)(x.A,{size:14})},{id:"divergencias",label:"Diverg\xeancias de saldo",icon:(0,s.jsx)(m.A,{size:14})}].map(e=>(0,s.jsxs)("button",{onClick:()=>l(e.id),className:"inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-sm font-bold transition max-md:shrink-0 max-md:whitespace-nowrap ".concat(a===e.id?"bg-white text-primary shadow-sm":"text-text-sec hover:text-text-main"),children:[e.icon," ",e.label]},e.id))})]}),(0,s.jsxs)("div",{className:"flex-1 overflow-hidden",children:["fichas"===a&&(0,s.jsx)(j,{restaurantId:e,showToast:t}),"validade"===a&&(0,s.jsx)(N,{restaurantId:e,showToast:t}),"divergencias"===a&&(0,s.jsx)(y,{restaurantId:e,showToast:t})]})]})}function j(e){let{restaurantId:t,showToast:a}=e,[l,d]=(0,r.useState)([]),[n,c]=(0,r.useState)(null),[o,x]=(0,r.useState)(!0),[m,f]=(0,r.useState)("sem_ficha"),[v,j]=(0,r.useState)(""),N=(0,r.useCallback)(async()=>{if(!t)return void x(!1);x(!0);let e=await g(),s=(0,i.H)("/api/admin/financeiro/diagnostico-fichas",t,{somente_sem_ficha:"sem_ficha"===m?"true":"false",somente_ativos:"true"});if(!s)return void x(!1);try{var r,l;let t=await fetch(s,{headers:{authorization:"Bearer ".concat(e)}});if(!t.ok)return void a("Falha ao carregar: "+await t.text(),"error");let n=await t.json();d(null!=(r=n.rows)?r:[]),c(null!=(l=n.resumo)?l:null)}finally{x(!1)}},[t,m,a]);(0,r.useEffect)(()=>{N()},[N]);let y=(0,r.useMemo)(()=>{let e=v.trim().toLowerCase();return e?l.filter(t=>{var a;return t.nome.toLowerCase().includes(e)||(null!=(a=t.categoria)?a:"").toLowerCase().includes(e)}):l},[l,v]);return(0,s.jsxs)("div",{className:"flex flex-col h-full",children:[n&&(0,s.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 px-6 max-md:px-3 py-3",children:[(0,s.jsx)(_,{label:"Produtos ativos",value:n.total,tone:"slate"}),(0,s.jsx)(_,{label:"Sem ficha t\xe9cnica",value:n.sem_ficha,tone:n.sem_ficha?"red":"green"}),(0,s.jsx)(_,{label:"Sem ficha + vendendo",value:n.sem_ficha_com_vendas,tone:n.sem_ficha_com_vendas?"red":"green"}),(0,s.jsx)(_,{label:"Com ficha",value:n.com_ficha,tone:"green"})]}),(0,s.jsx)("div",{className:"px-6 max-md:px-3 pb-2",children:(0,s.jsxs)("div",{className:"rounded-2xl border border-border-brand bg-white p-3 flex flex-wrap gap-2 items-center",children:[(0,s.jsxs)("div",{className:"inline-flex rounded-xl border border-border-brand bg-bg-base p-1 gap-1",children:[(0,s.jsx)("button",{onClick:()=>f("sem_ficha"),className:"rounded-lg px-3 py-1.5 text-sm font-bold transition ".concat("sem_ficha"===m?"bg-white text-primary shadow-sm":"text-text-sec"),children:"Apenas sem ficha"}),(0,s.jsx)("button",{onClick:()=>f("todos"),className:"rounded-lg px-3 py-1.5 text-sm font-bold transition ".concat("todos"===m?"bg-white text-primary shadow-sm":"text-text-sec"),children:"Todos"})]}),(0,s.jsxs)("div",{className:"relative flex-1 min-w-[200px]",children:[(0,s.jsx)(h.A,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-sec"}
1),(0,s.jsx)("input",{value:v,onChange:e=>j(e.target.value),placeholder:"Buscar produto...",className:"w-full rounded-xl border border-border-brand bg-white pl-9 pr-3 py-2 text-sm font-bold focus:outline-none focus:border-primary"})]}),(0,s.jsx)("button",{onClick:N,disabled:o,className:"inline-flex items-center gap-2 rounded-xl border border-border-brand bg-white px-3 py-2 text-sm font-bold hover:bg-bg-base disabled:opacity-50",children:(0,s.jsx)(b.A,{size:14,className:o?"animate-spin":""})})]})}),(0,s.jsx)("div",{className:"flex-1 overflow-hidden px-6 max-md:px-3 pb-4",children:(0,s.jsx)("div",{className:"h-full overflow-auto rounded-2xl border border-border-brand bg-white cel-tabela-fixa",children:(0,s.jsxs)("table",{className:"w-full text-sm",children:[(0,s.jsx)("thead",{className:"bg-bg-base sticky top-0 z-10",children:(0,s.jsxs)("tr",{className:"text-left text-[11px] uppercase tracking-wide text-text-sec font-black border-b border-border-brand",children:[(0,s.jsx)("th",{className:"px-3 py-2",children:"Produto"}),(0,s.jsx)("th",{className:"px-3 py-2",children:"Categoria"}),(0,s.jsx)("th",{className:"px-3 py-2 text-right",children:"Pre\xe7o"}),(0,s.jsx)("th",{className:"px-3 py-2 text-right",children:"Vendidos"}),(0,s.jsx)("th",{className:"px-3 py-2",children:"Ficha"})]})}),(0,s.jsxs)("tbody",{children:[o&&0===y.length&&(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:5,className:"px-3 py-12 text-center text-text-sec",children:"Carregando…"})}),!o&&0===y.length&&(0,s.jsx)("tr",{children:(0,s.jsxs)("td",{colSpan:5,className:"px-3 py-12 text-center",children:[(0,s.jsx)(u.A,{size:28,className:"mx-auto text-emerald-600 mb-2"}),(0,s.jsx)("p",{className:"text-sm font-bold",children:"Nenhum produto neste filtro"})]})}),y.map(e=>{var t;return(0,s.jsxs)("tr",{className:"border-b border-border-brand last:border-b-0 hover:bg-bg-base",children:[(0,s.jsx)("td",{className:"px-3 py-2 font-bold text-text-main",children:e.nome}),(0,s.jsx)("td",{className:"px-3 py-2 text-text-sec text-xs",children:null!=(t=e.categoria)?t:"—"}),(0,s.jsx)("td",{className:"px-3 py-2 text-right text-text-sec",children:null!=e.preco?p(Number(e.preco)):"—"}),(0,s.jsx)("td",{className:"px-3 py-2 text-right font-bold ".concat(Number(e.vezes_vendido)>5?"text-rose-700":"text-text-main"),children:e.vezes_vendido}),(0,s.jsx)("td",{className:"px-3 py-2",children:e.tem_ficha?(0,s.jsx)(w,{tone:"green",children:"com ficha"}):(0,s.jsx)(w,{tone:"red",children:"sem ficha"})})]},e.produto_id)})]})]})})})]})}function N(e){let{restaurantId:t,showToast:a}=e,[l,d]=(0,r.useState)([]),[n,o]=(0,r.useState)(null),[x,m]=(0,r.useState)(!0),h=(0,r.useCallback)(async()=>{if(!t)return void m(!1);m(!0);let e=await g(),s=(0,i.H)("/api/admin/estoque/validade",t);if(!s)return void m(!1);try{var r,l;let t=await fetch(s,{headers:{authorization:"Bearer ".concat(e)}});if(!t.ok)return void a("Falha ao carregar: "+await t.text(),"error");let n=await t.json();d(null!=(r=n.rows)?r:[]),o(null!=(l=n.resumo)?l:null)}finally{m(!1)}},[t,a]);return(0,r.useEffect)(()=>{h()},[h]),(0,s.jsxs)("div",{className:"flex flex-col h-full",children:[n&&(0,s.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-3 px-6 max-md:px-3 py-3",children:[(0,s.jsx)(_,{label:"Insumos com validade",value:n.total,tone:"slate"}),(0,s.jsx)(_,{label:"Vencidos",value:n.vencidos,tone:n.vencidos?"red":"green"}),(0,s.jsx)(_,{label:"Vence em 3 dias",value:n.vencendo_3d,tone:n.vencendo_3d?"red":"green"}),(0,s.jsx)(_,{label:"Vence em 7 dias",value:n.vencendo_7d,tone:n.vencendo_7d?"amber":"green"}),(0,s.jsx)(_,{label:"Vence em 30 dias",value:n.vencendo_30d,tone:"slate"})]}),(0,s.jsx)("div",{className:"flex-1 overflow-hidden px-6 max-md:px-3 pb-4",children:(0,s.jsx)("div",{className:"h-full overflow-auto rounded-2xl border border-border-brand bg-white cel-tabela-fixa",children:(0,s.jsxs)("table",{className:"w-full text-sm",children:[(0,s.jsx)("thead",{className:"bg-bg-base sticky top-0 z-10",children:(0,s.jsxs)("tr",{className:"text-left text-[11px] uppercase tracking-wide text-text-sec font-black border-b border-border-brand",children:[(0,s.jsx)("th",{className:"px-3 py-2",children:"Insumo"}),(0,s.jsx)("th",{className:"px-3 py-2 text-right",children:"Saldo"}),(0,s.jsx)("th",{className:"px-3 py-2 text-right",children:"Validade"}),(0,s.jsx)("th",{className:"px-3 py-2 text-right",children:"Dias"}),(0,s.jsx)("th",{className:"px-3 py-2",children:"Status"}),(0,s.jsx)("th",{className:"px-3 py-2 text-right",children:"Valor em risco"})]})}),(0,s.jsxs)("tbody",{children:[x&&0===l.length&&(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:6,className:"px-3 py-12 text-center text-text-sec",children:"Carregando…"})}),!x&&0===l.length&&(0,s.jsx)("tr",{children:(0,s.jsxs)("td",{colSpan:6,className:"px-3 py-12 text-center",children:[(0,s.jsx)(u.A,{size:28,className:"mx-auto text-emerald-600 mb-2"}),(0,s.jsx)("p",{className:"text-sm font-bold",children:"Nenhum insumo cadastrado com validade"}),(0,s.jsx)("p",{className:"text-xs text-text-sec mt-1",children:'Preencha o campo "validade" em Estoque → Insumos para receber alertas aqui.'})]})}),l.map(e=>{var t,a,r,l;let d=Number(null!=(t=e.dias_ate_vencer)?t:0),n=Number(null!=(a=e.saldo)?a:0)*Number(null!=(r=e.custo_medio)?r:0);return(0,s.jsxs)("tr",{className:"border-b border-border-brand last:border-b-0 hover:bg-bg-base",children:[(0,s.jsxs)("td",{className:"px-3 py-2 font-bold text-text-main",children:[e.insumo,(0,s.jsxs)("span",{className:"text-text-sec text-xs font-normal",children:[" (",null!=(l=e.unidade)?l:"—",")"]})]}),(0,s.jsx)("td",{className:"px-3 py-2 text-right text-text-main",children:f(e.saldo)}),(0,s.jsx)("td",{className:"px-3 py-2 text-right text-text-sec",children:(e=>{let t=(0,c.H)(e);return t?t.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"2-digit"}):"—"})(e.validade)}),(0,s.jsx)("td",{className:"px-3 py-2 text-right font-bold ".concat(e.vencido||e.vencendo_3d?"text-rose-700":e.vencendo_7d?"text-amber-700":"text-text-sec"),children:e.vencido?"−".concat(Math.abs(d)):d}),(0,s.jsxs)("td",{className:"px-3 py-2",children:[e.vencido&&(0,s.jsx)(w,{tone:"red",children:"vencido"}),e.vencendo_3d&&(0,s.jsx)(w,{tone:"red",children:"vence em ≤3d"}),e.vencendo_7d&&(0,s.jsx)(w,{tone:"amber",children:"vence em ≤7d"}
1),e.vencendo_30d&&!e.vencendo_7d&&!e.vencendo_3d&&!e.vencido&&(0,s.jsx)(w,{tone:"slate",children:"vence em ≤30d"})]}),(0,s.jsx)("td",{className:"px-3 py-2 text-right font-bold ".concat(e.vencido?"text-rose-700":"text-text-main"),children:n>0?p(n):"—"})]},e.inventory_id)})]})]})})})]})}function y(e){let{restaurantId:t,showToast:a}=e,[l,d]=(0,r.useState)([]),[n,c]=(0,r.useState)(null),[o,x]=(0,r.useState)(!0),m=(0,r.useCallback)(async()=>{if(!t)return void x(!1);x(!0);let e=await g(),s=(0,i.H)("/api/admin/estoque/divergencias",t);if(!s)return void x(!1);try{var r,l;let t=await fetch(s,{headers:{authorization:"Bearer ".concat(e)}});if(!t.ok)return void a("Falha ao carregar: "+await t.text(),"error");let n=await t.json();d(null!=(r=n.rows)?r:[]),c(null!=(l=n.resumo)?l:null)}finally{x(!1)}},[t,a]);return(0,r.useEffect)(()=>{m()},[m]),(0,s.jsxs)("div",{className:"flex flex-col h-full",children:[n&&(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 px-6 max-md:px-3 py-3",children:[(0,s.jsx)(_,{label:"Insumos com problema",value:n.total,tone:n.total?"red":"green"}),(0,s.jsx)(_,{label:"Vencidos com estoque > 0",value:n.vencidos_com_estoque,tone:n.vencidos_com_estoque?"red":"green"}),(0,s.jsx)(_,{label:"Saldo divergente",value:n.com_divergencia,tone:n.com_divergencia?"red":"green"})]}),(0,s.jsx)("div",{className:"flex-1 overflow-hidden px-6 max-md:px-3 pb-4",children:(0,s.jsx)("div",{className:"h-full overflow-auto rounded-2xl border border-border-brand bg-white cel-tabela-fixa",children:(0,s.jsxs)("table",{className:"w-full text-sm",children:[(0,s.jsx)("thead",{className:"bg-bg-base sticky top-0 z-10",children:(0,s.jsxs)("tr",{className:"text-left text-[11px] uppercase tracking-wide text-text-sec font-black border-b border-border-brand",children:[(0,s.jsx)("th",{className:"px-3 py-2",children:"Insumo"}),(0,s.jsx)("th",{className:"px-3 py-2 text-right",children:"Saldo sistema"}),(0,s.jsx)("th",{className:"px-3 py-2 text-right",children:"Saldo por movs"}),(0,s.jsx)("th",{className:"px-3 py-2 text-right",children:"Diverg\xeancia"}),(0,s.jsx)("th",{className:"px-3 py-2",children:"Sinal"})]})}),(0,s.jsxs)("tbody",{children:[o&&0===l.length&&(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:5,className:"px-3 py-12 text-center text-text-sec",children:"Carregando…"})}),!o&&0===l.length&&(0,s.jsx)("tr",{children:(0,s.jsxs)("td",{colSpan:5,className:"px-3 py-12 text-center",children:[(0,s.jsx)(u.A,{size:28,className:"mx-auto text-emerald-600 mb-2"}),(0,s.jsx)("p",{className:"text-sm font-bold",children:"Tudo certo — sem diverg\xeancias"})]})}),l.map(e=>(0,s.jsxs)("tr",{className:"border-b border-border-brand last:border-b-0 hover:bg-bg-base",children:[(0,s.jsx)("td",{className:"px-3 py-2 font-bold text-text-main",children:e.insumo}),(0,s.jsx)("td",{className:"px-3 py-2 text-right text-text-main",children:f(e.saldo_atual)}),(0,s.jsx)("td",{className:"px-3 py-2 text-right text-text-sec",children:f(e.saldo_pelos_movimentos)}),(0,s.jsxs)("td",{className:"px-3 py-2 text-right font-bold ".concat(0===Number(e.divergencia)?"text-text-sec":"text-rose-700"),children:[Number(e.divergencia)>0?"+":"",f(e.divergencia)]}),(0,s.jsxs)("td",{className:"px-3 py-2",children:[e.vencido&&(0,s.jsx)(w,{tone:"red",children:"vencido"}),Math.abs(Number(e.divergencia))>.001&&(0,s.jsx)(w,{tone:"amber",children:"saldo diverge"})]})]},e.inventory_id))]})]})})})]})}function w(e){let{children:t,tone:a}=e;return(0,s.jsx)("span",{className:"inline-flex items-center rounded-full border px-2 py-0.5 text-[11px] font-bold ".concat({green:"bg-emerald-50 text-emerald-700 border-emerald-200",red:"bg-rose-50 text-rose-700 border-rose-200",amber:"bg-amber-50 text-amber-700 border-amber-200",slate:"bg-slate-100 text-slate-700 border-slate-200"}[a]),children:t})}function _(e){let{label:t,value:a,tone:r}=e;return(0,s.jsxs)("div",{className:"rounded-2xl border border-border-brand bg-white p-3",children:[(0,s.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-text-sec font-bold",children:t}),(0,s.jsx)("p",{className:"mt-1 text-xl font-black ".concat({green:"text-emerald-700",red:"text-rose-700",amber:"text-amber-700",slate:"text-text-main"}
1[r]),children:Number(null!=a?a:0).toLocaleString("pt-BR")})]})}}}]);

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.