1import{j as e,a7 as s,X as P,ai as k,Z as E,aq as q,O as B,H as u,T as r,ao as h,Q as x,ad as A,I as L}from"./mui-CRsYZxVY.js";import{r as b}from"./vendor-Dwao9eNC.js";import{u as N,w as R,J as S,b as F,T as M,bo as W,dO as z,dS as H}from"./index-TALscxEc.js";import{u as O}from"./query-8ViTdhdk.js";import{u as Q}from"./useDeleteProducts-iKMbBu96.js";import{L as y}from"./lab-DSem1Osk.js";import"./datePickers-BIJXYOKG.js";import"./icons-D8aatgQ4.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:{},a=new o.Error().stack;a&&(o._sentryDebugIds=o._sentryDebugIds||{},o._sentryDebugIds[a]="534d41f7-63b1-49ce-8f32-8f91a558558b",o._sentryDebugIdIdentifier="sentry-dbid-534d41f7-63b1-49ce-8f32-8f91a558558b")})()}catch{}const U=o=>{const{user:a}=N(),l=a==null?void 0:a.id;return O({queryKey:["import",o],queryFn:async()=>{if(!l)throw new Error("Usuário não autenticado");const{data:n,error:d}=await R.from("importacao").select(` 2 id, 3 user_id, 4 quantidade_produtos, 5 criado_em, 6 produtos:produto( 7 id, 8 nome, 9 descricao, 10 preco, 11 categoria_id, 12 sku, 13 importacao_id, 14 image_url, 15 deletado_em, 16 oculto, 17 destaque, 18 criado_em, 19 categoria:categoria!fk_categoria( 20 id, 21 nome 22 ) 23 ) 24 `).eq("id",o).eq("user_id",l).order("oculto",{ascending:!0,referencedTable:"produto"}).order("destaque",{ascending:!1,referencedTable:"produto"}).order("criado_em",{ascending:!1,referencedTable:"produto"}).order("id",{ascending:!1,referencedTable:"produto"}).single();if(d)throw new Error(d.message);return n}
24,enabled:!!o&&!!l})},ee=()=>{const{importId:o}=S(),a=F(),[l,n]=b.useState(!1),[d,g]=b.useState(!1),{data:m,isLoading:j,error:w,refetch:v}=U(Number(o)),_=Q(),D=()=>{if(j)return e.jsxs(e.Fragment,{children:[e.jsxs(u,{elevation:0,sx:{p:2,mb:2,bgcolor:"white"},children:[e.jsx(r,{variant:"h6",gutterBottom:!0,color:"primary",fontWeight:"bold",children:"Informações da importação"}),["Data","Total de produtos","Produtos ativos","Produtos excluÃdos"].map((t,c)=>e.jsxs(s,{display:"flex",alignItems:"center",mb:1,children:[e.jsxs(r,{variant:"body2",color:"text.secondary",width:150,children:[t,":"]}),e.jsx(h,{width:100})]},c))]}),e.jsxs(u,{elevation:0,sx:{p:2,bgcolor:"white"},children:[e.jsx(r,{variant:"h6",gutterBottom:!0,color:"primary",fontWeight:"bold",children:"Produtos importados"}),e.jsx(x,{children:[1,2,3].map(t=>e.jsx(h,{variant:"rectangular",height:80,sx:{mb:1,borderRadius:1}},t))})]})]});if(w||!m)return e.jsx(A,{severity:"error",children:"Error loading import details"});const{criado_em:f,produtos:i,quantidade_produtos:T}=m,p=i.filter(t=>!t.deletado_em),C=i.filter(t=>t.deletado_em);return e.jsxs(e.Fragment,{children:[e.jsxs(u,{elevation:0,sx:{p:2,mb:2,bgcolor:"white"},children:[e.jsx(r,{variant:"h6",gutterBottom:!0,color:"primary",fontWeight:"bold",children:"Informações da importação"}),e.jsxs(s,{display:"flex",alignItems:"center",mb:1,justifyContent:"space-between",children:[e.jsx(r,{variant:"body2",color:"text.secondary",width:150,children:"Data:"}),e.jsx(r,{variant:"body1",children:W(new Date(f),"dd/MM/yy 'à s' HH:mm")})]}),e.jsxs(s,{display:"flex",alignItems:"center",mb:1,justifyContent:"space-between",children:[e.jsx(r,{variant:"body2",color:"text.secondary",width:150,children:"Total de produtos:"}),e.jsx(r,{variant:"body1",children:T})]}),e.jsxs(s,{display:"flex",alignItems:"center",mb:1,justifyContent:"space-between",children:[e.jsx(r,{variant:"body2",color:"text.secondary",width:150,children:"Produtos ativos:"}),e.jsx(r,{variant:"body1",children:p.length})]}),e.jsxs(s,{display:"flex",alignItems:"center",mb:1,justifyContent:"space-between",children:[e.jsx(r,{variant:"body2",color:"text.secondary",width:150,children:"Produtos excluÃdos:"}),e.jsx(r,{variant:"body1",textAlign:"right",children:C.length})]})]}),e.jsxs(u,{elevation:0,sx:{p:2,bgcolor:"white"},children:[e.jsxs(s,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[e.jsx(r,{variant:"h6",color:"primary",fontWeight:"bold",children:"Produtos importados"}),p.length>0&&e.jsx(L,{color:"error",onClick:()=>n(!0),size:"small",children:e.jsx(z,{})})]}),e.jsx(x,{children:i.map(t=>{var c;return e.jsx(H,{id:t.id,productName:t.nome,categoryName:(c=t.categoria)==null?void 0:c.nome,sku:t.sku||void 0,price:new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL"}).format(t.preco),imageUrl:t.image_url?t.image_url[0]:"",onClick:()=>a(`/products/${t.id}`),deleted:!!t.deletado_em,disabled:!!t.deletado_em},t.id)})})]})]})},I=async()=>{g(!0);const f=m.produtos.filter(i=>!i.deletado_em).map(i=>i.id);await _.mutateAsync({ids:f}),await v(),g(!1),n(!1)};return e.jsxs(s,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(M,{title:"Detalhes da importação",navigateBack:!0}),e.jsx(s,{sx:{flex:1,overflowY:"auto",padding:2},children:D()}),e.jsxs(P,{open:l,onClose:()=>!d&&n(!1),"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsx(k,{id:"alert-dialog-title",children:"Confirmar exclusão"}),e.jsx(E,{children:e.jsx(q,{id:"alert-dialog-description",children:"Tem certeza que deseja excluir todos os produtos ativos desta importação? Esta ação não pode ser desfeita."})}),e.jsxs(B,{children:[e.jsx(y,{onClick:()=>n(!1),disabled:d,children:"Cancelar"}),e.jsx(y,{onClick:I,loading:d,color:"error",autoFocus:!0,children:"Confirmar"})]})]})]})};export{ee 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.