PageSourceSearch

https://app.stoqui.com.br/assets/SuppliersPage-0ECZKcZN.js

js stoqui.com.br collected 2026-09-24 11:58:41 UTC 5,531 bytes, 1 lines download raw bytes

1import{j as e,a7 as g,I as b,Q as T,aw as z,at as _,n as j,ar as S,ac as y,an as V,X as G,ai as X,Z as Y,aq as Z,O as J,N as O}from"./mui-CRsYZxVY.js";import{r as u}from"./vendor-Dwao9eNC.js";import{u as W,w as ee,t as ne,l as se,b as te,v as oe,bK as m,ca as re,T as ae,e9 as le,K as ie,bG as ce,bm as de}from"./index-TALscxEc.js";import{S as A}from"./SupplierListItem-1bVa5msP.js";import{u as ue}from"./useSuppliers-CrWpT6AC.js";import{a as fe,b as he}from"./query-8ViTdhdk.js";import{C as pe,M as B,e as me,H as xe,D as ge}from"./icons-D8aatgQ4.js";import"./datePickers-BIJXYOKG.js";import"./lab-DSem1Osk.js";(function(){try{var o=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};o.SENTRY_RELEASE={id:"2ad85febf9735404429b0670d4acf56a0af5a0a2"}}catch{}})();try{(function(){var o=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},i=new o.Error().stack;i&&(o._sentryDebugIds=o._sentryDebugIds||{},o._sentryDebugIds[i]="8ad4d13c-0181-47b5-9b9b-dc20248b57a8",o._sentryDebugIdIdentifier="sentry-dbid-8ad4d13c-0181-47b5-9b9b-dc20248b57a8")})()}catch{}const be=()=>{const o=fe(),{user:i}=W(),a=i==null?void 0:i.id;return he({mutationFn:async({supplier_ids:l})=>{if(!a)throw new Error("User must be logged in to delete suppliers.");const{error:t}=await ee.from("fornecedor").update({deletado_em:new Date().toISOString()}).in("id",l);if(t)throw t;return l.map(s=>({id:s}))},onMutate:async l=>{await o.cancelQueries({queryKey:["suppliers"]});const t=o.getQueryData(["suppliers"])||[];return o.setQueryData(["suppliers"],s=>s?s.filter(d=>!l.supplier_ids.includes(d.id)):[]),{previousSuppliers:t}},onError:(l,t,s)=>{console.error("Error deleting suppliers:",l.message),s!=null&&s.previousSuppliers&&o.setQueryData(["suppliers"],s.previousSuppliers)},onSuccess:(l,t)=>{ne(se.DELETE.SUPPLIER_BULK,{supplierIds:t.supplier_ids,count:t.supplier_ids.length})},onSettled:()=>{o.invalidateQueries({queryKey:["suppliers"]})},retry:0})},we=()=>{const o=te(),[i]=oe(),a=i.get("query")||"",{data:f=[],isLoading:l}=ue(),t=u.useMemo(()=>f?a.trim()?f.filter(n=>m(a,n.nome)||n.telefone&&m(a,n.telefone)||n.email&&m(a,n.email)||n.nome_responsavel&&m(a,n.nome_responsavel)):f:[],[f,a]),[s,d]=u.useState([]),[x,h]=u.useState(!1),[C,E]=u.useState(null),[k,D]=u.useState(null),[L,p]=u.useState(!1),v=be(),q=re(()=>{de(),h(!0)},{cancelOnMovement:!0}),P=n=>{E(n.currentTarget)},I=()=>{E(null)},F=n=>{D(n.currentTarget)},w=()=>{D(null)},Q=()=>{h(!0),w()},R=()=>{h(!1),d([])},H=()=>{p(!0),I()},K=()=>{const n=(t==null?void 0:t.map(r=>r.id))||[],c=n.length>0&&n.every(r=>s.includes(r));d(c?s.filter(r=>!n.includes(r)):[...s.filter(r=>!n.includes(r)),...n])},M=()=>{const n=(t==null?void 0:t.map(r=>r.id))||[],c=n.filter(r=>s.includes(r)).length;return c===0?{checked:!1,indeterminate:!1}:c===n.length?{checked:!0,indeterminate:!1}:{checked:!1,indeterminate:!0}},N=async()=>{await v.mutateAsync({supplier_ids:s}),p(!1),h(!1),d([])},U=n=>{d(c=>c.includes(n)?c.filter(r=>r!==n):[...c,n])},$=!l&&t.length===0&&!a;return e.jsxs(g,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(ae,{title:"Fornecedores",navigateBack:!0,children:x?e.jsxs(e.Fragment,{children:[e.jsx(b,{color:"inherit",onClick:R,children:e.jsx(pe,{})}),e.jsx(b,{color:"inherit",onClick:P,children:e.jsx(B,{})})]}):e.jsxs(e.Fragment,{children:[e.jsx(le,{}),e.jsx(b,{color:"inherit",onClick:F,sx:{ml:1},disabled:!t||t.length===0,children:e.jsx(B,{})})]})}),e.jsx(g,{sx:{flex:1,overflow:"auto",p:2,pb:2},children:l?e.jsx(T,{children:[1,2,3].map(n=>e.jsx(A,{supplier:{id:n,nome:"",telefone:"",email:"",observacoes:"",endereco:"",cpf_cnpj:"",nome_responsavel:"",criado_em:new Date().toISOString(),atualizado_em:new Date().toISOString(),deletado_em:null},onClick:()=>{},isLoading:!0},n))}):t.length===0?e.jsx(g,{sx:{mt:8},children:e.jsx(ie,{primaryText:a?"Nenhum fornecedor encontrado":"Nenhum fornecedor cadastrado",secondaryText:a?"Tente remover a palavra-chave de busca":"Clique no botão de adicionar para cadastrar um novo fornecedor"})}):e.jsx(T,{children:t.map(n=>e.jsx(A,{supplier:n,onClick:()=>{x?U(n.id):o(`/suppliers/${n.id}`)}
1,selected:s.includes(n.id),selectEnabled:x,longPressEvents:q},n.id))})}),e.jsx(z,{color:"primary",sx:{position:"fixed",right:16,bottom:"calc(var(--safe-area-inset-bottom) + 16px)"},onClick:()=>o("/suppliers/new"),children:e.jsx(me,{})}),e.jsx(ce,{text:"Clique no botão de + para cadastrar um fornecedor",visible:$,fabBottom:"calc(var(--safe-area-inset-bottom) + 16px)",fabRight:16}),e.jsx(_,{anchorEl:k,open:!!k,onClose:w,children:e.jsxs(j,{onClick:Q,children:[e.jsx(S,{children:e.jsx(xe,{})}),e.jsx(y,{children:"Selecionar"})]})}),e.jsxs(_,{anchorEl:C,open:!!C,onClose:I,children:[e.jsxs(j,{onClick:K,children:[e.jsx(S,{children:e.jsx(V,{checked:M().checked,indeterminate:M().indeterminate,tabIndex:-1,disableRipple:!0,sx:{p:"0px"}})}),e.jsx(y,{primary:"Selecionar todos"})]}),e.jsxs(j,{onClick:H,disabled:s.length===0,children:[e.jsx(S,{children:e.jsx(ge,{})}),e.jsx(y,{primary:s.length>0?`Excluir (${s.length})`:"Excluir"})]})]}),e.jsxs(G,{open:L,onClose:()=>p(!1),children:[e.jsx(X,{children:"Excluir fornecedores"}),e.jsx(Y,{children:e.jsxs(Z,{children:["Tem certeza que deseja excluir"," ",s.length===1?"este fornecedor":`estes ${s.length} fornecedores`,"?"]})}),e.jsxs(J,{children:[e.jsx(O,{onClick:()=>p(!1),children:"Cancelar"}),e.jsx(O,{onClick:N,color:"error",disabled:v.isPending,children:"Excluir"})]})]})]})};export{we as default};

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.