PageSourceSearch

https://alinhafood.com.br/_next/static/chunks/69044.93b86d85c279ff44.js

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

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[69044],{21190:(e,s,a)=>{a.d(s,{A:()=>t});let t=(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"}]])},69044:(e,s,a)=>{a.r(s),a.d(s,{default:()=>j});var t=a(95155),r=a(12115),o=a(6191),i=a(79397),l=a(26617),n=a(52056),c=a(45345),d=a(21190),x=a(71360),m=a(35299),u=a(65229),p=a(5917),h=a(67592),g=a(14272),f=a(1790);async function b(){var e,s;let{data:a}=await (0,g.U)("admin").auth.getSession();return null!=(s=null==(e=a.session)?void 0:e.access_token)?s:""}function j(){let{showToast:e}=(0,h.d)(),[s,a]=(0,r.useState)([]),[g,j]=(0,r.useState)([]),[N,v]=(0,r.useState)(!0),[w,y]=(0,r.useState)(!0),[E,F]=(0,r.useState)(!1),[A,k]=(0,r.useState)(null),[C,z]=(0,r.useState)({nome:"",cor:"#1A56DB",descricao:""}),[B,S]=(0,r.useState)(!1),[D,G]=(0,r.useState)(null),[T,q]=(0,r.useState)(null),[I,L]=(0,r.useState)(null),O=(0,r.useCallback)(async()=>{v(!0);try{let e=await b(),s=await fetch("/api/admin/estoque/grupos",{headers:{Authorization:"Bearer ".concat(e)}});if(!s.ok)throw Error("Erro ao carregar grupos");let t=await s.json();a(t)}catch(s){e("Erro ao carregar grupos de ingredientes","error")}finally{v(!1)}},[e]),_=(0,r.useCallback)(async()=>{y(!0);try{let e=await b(),s=await fetch("/api/admin/estoque/insumos",{headers:{Authorization:"Bearer ".concat(e)}});if(!s.ok)throw Error("Erro ao carregar insumos");let a=await s.json();j(a)}catch(s){e("Erro ao carregar insumos","error")}finally{y(!1)}},[e]);function U(){k(null),z({nome:"",cor:"#1A56DB",descricao:""}),F(!0)}function P(){F(!1),k(null)}async function H(){if(!C.nome.trim())return void e("O nome do grupo \xe9 obrigat\xf3rio","error");S(!0);try{let a=await b(),t=A?"/api/admin/estoque/grupos/".concat(A.id):"/api/admin/estoque/grupos",r=A?"PUT":"POST",o=await fetch(t,{method:r,headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(a)},body:JSON.stringify({nome:C.nome.trim(),cor:C.cor,descricao:C.descricao.trim()||null})});if(!o.ok){var s;let e=await o.json();throw Error(null!=(s=e.error)?s:"Erro ao salvar")}e(A?"Grupo atualizado com sucesso":"Grupo criado com sucesso","success"),P(),await O()}catch(s){e(s instanceof Error?s.message:"Erro ao salvar grupo","error")}finally{S(!1)}}async function J(s){G(s);try{let t=await b(),r=await fetch("/api/admin/estoque/grupos/".concat(s),{method:"DELETE",headers:{Authorization:"Bearer ".concat(t)}});if(!r.ok){var a;let e=await r.json();throw Error(null!=(a=e.error)?a:"Erro ao deletar")}e("Grupo removido com sucesso","success"),q(null),await O()}catch(s){e(s instanceof Error?s.message:"Erro ao remover grupo","error")}finally{G(null)}}async function R(s,a){L(s);try{let r=await b(),o=await fetch("/api/admin/estoque/insumos/".concat(s),{method:"PUT",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(r)},body:JSON.stringify({category:a})});if(!o.ok){var t;let e=await o.json();throw Error(null!=(t=e.error)?t:"Erro ao atualizar")}j(e=>e.map(e=>e.id===s?{...e,category:a}:e)),e("Grupo do insumo atualizado","success")}catch(s){e(s instanceof Error?s.message:"Erro ao atualizar insumo","error")}finally{L(null)}}(0,r.useEffect)(()=>{O(),_()},[O,_]);let M=g.length,K=g.filter(e=>e.category&&""!==e.category.trim()).length,Q=s.filter(e=>!g.some(s=>s.category===e.nome)).length;return(0,t.jsxs)("div",{className:"min-h-screen bg-[#F5F6F8] p-6 max-md:p-3 space-y-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-2xl font-black text-[#0F172A] font-[family-name:var(--font-heading)] tracking-tight",children:"Grupos de Ingredientes"}),(0,t.jsx)("p",{className:"text-sm text-[#475569] mt-0.5",children:"Organize seus insumos em grupos para facilitar a gest\xe3o"})]}),(0,t.jsxs)("button",{onClick:U,className:"flex items-center gap-2 bg-[#1A56DB] text-white font-bold px-5 py-2.5 rounded-xl hover:bg-[#1E3A8A] transition-all duration-200 shadow-md hover:shadow-lg hover:scale-[1.02] active:scale-[0.98]",children:[(0,t.jsx)(o.A,{size:18}),"Novo Grupo"]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4 max-md:grid-cols-3 max-md:gap-2",children:[(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-[#
1E2E8F0] p-5 flex items-center gap-4 shadow-sm max-md:p-2.5",children:[(0,t.jsx)("div",{className:"bg-[#EFF6FF] p-3 rounded-xl max-md:hidden",children:(0,t.jsx)(i.A,{size:22,className:"text-[#1A56DB]"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs font-semibold text-[#475569] uppercase tracking-wide max-md:text-[0.72rem] max-md:normal-case max-md:tracking-normal max-md:leading-tight",children:"Total Grupos"}),(0,t.jsx)("p",{className:"text-2xl font-black text-[#0F172A] max-md:text-lg",children:N?"—":s.length})]})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-[#E2E8F0] p-5 flex items-center gap-4 shadow-sm max-md:p-2.5",children:[(0,t.jsx)("div",{className:"bg-[#ECFDF5] p-3 rounded-xl max-md:hidden",children:(0,t.jsx)(l.A,{size:22,className:"text-[#10B981]"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs font-semibold text-[#475569] uppercase tracking-wide max-md:text-[0.72rem] max-md:normal-case max-md:tracking-normal max-md:leading-tight",children:"Insumos Agrupados"}),(0,t.jsx)("p",{className:"text-2xl font-black text-[#0F172A] max-md:text-lg",children:w?"—":"".concat(K," / ").concat(M)})]})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-[#E2E8F0] p-5 flex items-center gap-4 shadow-sm max-md:p-2.5",children:[(0,t.jsx)("div",{className:"bg-amber-50 p-3 rounded-xl max-md:hidden",children:(0,t.jsx)(n.A,{size:22,className:"text-amber-500"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs font-semibold text-[#475569] uppercase tracking-wide max-md:text-[0.72rem] max-md:normal-case max-md:tracking-normal max-md:leading-tight",children:"Grupos sem Insumos"}),(0,t.jsx)("p",{className:"text-2xl font-black text-[#0F172A] max-md:text-lg",children:N||w?"—":Q})]})]})]}),N?(0,t.jsx)(f.He,{}):0===s.length?(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-[#E2E8F0] p-12 text-center shadow-sm",children:[(0,t.jsx)("div",{className:"bg-[#EFF6FF] w-16 h-16 rounded-2xl flex items-center justify-center mx-auto mb-4",children:(0,t.jsx)(c.A,{size:28,className:"text-[#1A56DB]"})}),(0,t.jsx)("h3",{className:"font-bold text-[#0F172A] text-lg mb-1",children:"Nenhum grupo criado"}),(0,t.jsx)("p",{className:"text-[#475569] text-sm mb-5",children:"Crie grupos para organizar seus ingredientes por categoria."}),(0,t.jsxs)("button",{onClick:U,className:"inline-flex items-center gap-2 bg-[#1A56DB] text-white font-bold px-5 py-2.5 rounded-xl hover:bg-[#1E3A8A] transition-all",children:[(0,t.jsx)(o.A,{size:16}),"Criar primeiro grupo"]})]}):(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:s.map(e=>{var s;let a=(s=e.nome,g.filter(e=>e.category===s).length),r=T===e.id,o=D===e.id;return(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-[#E2E8F0] p-5 shadow-sm hover:shadow-md transition-all duration-200 group",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,t.jsx)("div",{className:"w-4 h-4 rounded-full flex-shrink-0 ring-2 ring-offset-2",style:{backgroundColor:e.cor,outlineColor:e.cor}}),(0,t.jsx)("h3",{className:"font-bold text-[#0F172A] text-sm truncate",children:e.nome})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,t.jsx)("button",{onClick:()=>{var s;k(e),z({nome:e.nome,cor:e.cor,descricao:null!=(s=e.descricao)?s:""}),F(!0)},className:"p-1.5 rounded-lg hover:bg-[#EFF6FF] text-[#475569] hover:text-[#1A56DB] transition-colors",title:"Editar grupo",children:(0,t.jsx)(d.A,{size:14})}),(0,t.jsx)("button",{onClick:()=>q(e.id),className:"p-1.5 rounded-lg hover:bg-red-50 text-[#475569] hover:text-red-500 transition-colors",title:"Remover grupo",children:(0,t.jsx)(x.A,{size:14})})]})]}),e.descricao&&(0,t.jsx)("p",{className:"text-xs text-[#475569] line-clamp-2 mb-3 leading-relaxed",children:e.descricao}),(0,t.jsx)("div",{className:"flex items-center justify-between",children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-xs font-semibold",style:{backgroundColor:"".concat(e.cor,"18"),color:e.cor},children:[(0,t.jsx)(l.A,{size:11}),a," insumo",1!==a?"s":""]})}
1),r&&(0,t.jsxs)("div",{className:"mt-3 pt-3 border-t border-[#E2E8F0]",children:[(0,t.jsx)("p",{className:"text-xs text-[#475569] mb-2",children:"Tem certeza? Insumos vinculados perder\xe3o o grupo."}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsxs)("button",{onClick:()=>J(e.id),disabled:o,className:"flex-1 flex items-center justify-center gap-1 bg-red-500 text-white text-xs font-bold px-3 py-1.5 rounded-lg hover:bg-red-600 transition-colors disabled:opacity-60",children:[o?(0,t.jsx)(m.A,{size:12,className:"animate-spin"}):(0,t.jsx)(x.A,{size:12}),"Confirmar"]}),(0,t.jsxs)("button",{onClick:()=>q(null),disabled:o,className:"flex-1 flex items-center justify-center gap-1 bg-[#F5F6F8] text-[#475569] text-xs font-bold px-3 py-1.5 rounded-lg hover:bg-[#E2E8F0] transition-colors",children:[(0,t.jsx)(u.A,{size:12}),"Cancelar"]})]})]})]},e.id)})}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-[#E2E8F0] shadow-sm overflow-hidden",children:[(0,t.jsxs)("div",{className:"px-6 py-4 border-b border-[#E2E8F0]",children:[(0,t.jsx)("h2",{className:"font-bold text-[#0F172A] text-base",children:"Atribuir Insumos a Grupos"}),(0,t.jsx)("p",{className:"text-xs text-[#475569] mt-0.5",children:"Altere o grupo de cada insumo diretamente pela lista abaixo"})]}),w?(0,t.jsx)(f.He,{}):0===g.length?(0,t.jsx)("div",{className:"py-10 text-center text-[#475569] text-sm",children:"Nenhum insumo cadastrado"}):(0,t.jsx)("div",{className:"overflow-x-auto cel-tabela-fixa",children:(0,t.jsxs)("table",{className:"w-full text-sm",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"bg-[#F5F6F8]",children:[(0,t.jsx)("th",{className:"text-left px-6 py-3 text-xs font-semibold text-[#475569] uppercase tracking-wide",children:"Insumo"}),(0,t.jsx)("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[#475569] uppercase tracking-wide",children:"Estoque"}),(0,t.jsx)("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[#475569] uppercase tracking-wide",children:"Unidade"}),(0,t.jsx)("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[#475569] uppercase tracking-wide w-56",children:"Grupo"})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-[#E2E8F0]",children:g.map(e=>{var a;let r=s.find(s=>s.nome===e.category),o=I===e.id;return(0,t.jsxs)("tr",{className:"hover:bg-[#F5F6F8] transition-colors",children:[(0,t.jsx)("td",{className:"px-6 py-3 font-medium text-[#0F172A]",children:e.name}),(0,t.jsx)("td",{className:"px-4 py-3 text-[#475569]",children:e.stock.toLocaleString("pt-BR",{maximumFractionDigits:2})}),(0,t.jsx)("td",{className:"px-4 py-3 text-[#475569]",children:e.unit}),(0,t.jsx)("td",{className:"px-4 py-3",children:(0,t.jsxs)("div",{className:"relative flex items-center gap-2",children:[r&&(0,t.jsx)("div",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:r.cor}}),(0,t.jsxs)("select",{value:null!=(a=e.category)?a:"",onChange:s=>R(e.id,s.target.value||null),disabled:o,className:"w-full border border-[#E2E8F0] rounded-lg px-2.5 py-1.5 text-xs text-[#0F172A] bg-white focus:outline-none focus:ring-2 focus:ring-[#1A56DB] focus:border-transparent disabled:opacity-60 transition-all appearance-none cursor-pointer",children:[(0,t.jsx)("option",{value:"",children:"— Sem grupo —"}),s.map(e=>(0,t.jsx)("option",{value:e.nome,children:e.nome},e.id))]}),o&&(0,t.jsx)(m.A,{size:14,className:"animate-spin text-[#1A56DB] flex-shrink-0"})]})})]},e.id)})})]})})]}),E&&(0,t.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[(0,t.jsx)("div",{className:"absolute inset-0 bg-[#0F172A]/50 backdrop-blur-sm",onClick:P}),(0,t.jsxs)("div",{className:"relative bg-white rounded-2xl shadow-2xl w-full max-w-md p-6 animate-in fade-in slide-in-from-bottom-4 duration-200",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-5",children:[(0,t.jsx)("h2",{className:"font-black text-[#0F172A] text-lg font-[family-name:var(--font-heading)]",children:A?"Editar Grupo":"Novo Grupo"}),(0,t.jsx)("button",{onClick:P,className:"p-2 rounded-xl hover:bg-[#F5F6F8] text-[#475569] hover:text-[#0F172A] transition-colors",children:(0,t.jsx)(u.A,{size:18})})]}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("label",{className:"block text-xs font-semibold text-[#475569] uppercase tracking-wide mb-1.5",children:["Nome ",(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsx)("input",{type:"text",value:C.nome,onChange:e=>z(s=>({...s,nome:e.target.value})),placeholder:"Ex: Latic\xednios, Carnes, Temperos...",maxLength:100,className:"w-full border border-[#
1E2E8F0] rounded-xl px-4 py-2.5 text-sm text-[#0F172A] placeholder-[#475569]/50 focus:outline-none focus:ring-2 focus:ring-[#1A56DB] focus:border-transparent transition-all"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-xs font-semibold text-[#475569] uppercase tracking-wide mb-1.5",children:"Cor de identifica\xe7\xe3o"}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("input",{type:"color",value:C.cor,onChange:e=>z(s=>({...s,cor:e.target.value})),className:"w-12 h-10 rounded-xl border border-[#E2E8F0] cursor-pointer p-0.5 bg-white"}),(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-1",children:[(0,t.jsx)("div",{className:"w-6 h-6 rounded-full ring-2 ring-offset-2 ring-[#E2E8F0]",style:{backgroundColor:C.cor}}),(0,t.jsx)("span",{className:"text-sm font-mono text-[#475569]",children:C.cor})]})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("label",{className:"block text-xs font-semibold text-[#475569] uppercase tracking-wide mb-1.5",children:["Descri\xe7\xe3o ",(0,t.jsx)("span",{className:"text-[#475569]/50 font-normal",children:"(opcional)"})]}),(0,t.jsx)("textarea",{value:C.descricao,onChange:e=>z(s=>({...s,descricao:e.target.value})),placeholder:"Descreva o tipo de insumos que pertencem a este grupo...",rows:3,className:"w-full border border-[#E2E8F0] rounded-xl px-4 py-2.5 text-sm text-[#0F172A] placeholder-[#475569]/50 focus:outline-none focus:ring-2 focus:ring-[#1A56DB] focus:border-transparent transition-all resize-none"})]})]}),(0,t.jsxs)("div",{className:"flex gap-3 mt-6",children:[(0,t.jsx)("button",{onClick:P,disabled:B,className:"flex-1 px-4 py-2.5 rounded-xl border border-[#E2E8F0] text-[#475569] font-semibold text-sm hover:bg-[#F5F6F8] transition-all disabled:opacity-60",children:"Cancelar"}),(0,t.jsxs)("button",{onClick:H,disabled:B||!C.nome.trim(),className:"flex-1 flex items-center justify-center gap-2 bg-[#1A56DB] text-white font-bold px-4 py-2.5 rounded-xl hover:bg-[#1E3A8A] transition-all disabled:opacity-60 shadow-md",children:[B?(0,t.jsx)(m.A,{size:16,className:"animate-spin"}):(0,t.jsx)(p.A,{size:16}),A?"Salvar altera\xe7\xf5es":"Criar grupo"]})]})]})]})]})}}}]);

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.