1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4785],{90121:function(e,a,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/integrador/meus-pedidos",function(){return n(60709)}])},60709:function(e,a,n){"use strict";n.r(a),n.d(a,{__N_SSG:function(){return P},default:function(){return O}});var t=n(85893),s=n(9008),i=n.n(s),r=n(33299),l=n(47451),d=n(33032),o=n(18266),c=n(69047),u=n(38787),x=n(83865),p=n(67294);n(59734),n(11163);var m=n(99005),h=n(13282),f=n(94087),g=n(74150),j=n(87740),b=n(86597),v=n(96476),_=n(41664),N=n.n(_),w=n(81856),E=n(53416);function C(e){let{onOpenChange:a,isOpen:n,data:s}=e;async function i(e){if(2===e.status_number)try{let a=await fetch("/api/integrador/solicitar-pedido?pedidov=".concat(e.pedidov)).then(e=>e.json());console.log(a),alert("Solicita\xe7\xe3o de compra enviada")}catch(e){}}return console.log("d",s),(0,t.jsx)("div",{children:(0,t.jsx)(f.R,{isOpen:n,onOpenChange:a,placement:"top-center",size:"4xl",classNames:{wrapper:"z-[70]"},children:(0,t.jsx)(g.A,{children:e=>(0,t.jsxs)("form",{onSubmit:a=>handleSubmit(a,e),children:[(0,t.jsxs)(j.k,{className:"flex flex-col gap-1 text-white text-center",children:["Detalhes do Pedido ",s.cod_pedidov]}),(0,t.jsxs)(b.I,{className:"max-h-[80vh] overflow-y-scroll text-white",children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-4 text-sm break-words gap-2",children:[(0,t.jsxs)("div",{className:"bg-zinc-800 p-2 rounded-lg text-center",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Status"}),(0,t.jsx)("div",{className:"flex flex-col gap-2 items-center",children:s.status_number<=0?(0,t.jsx)("div",{className:"bg-zinc-600 p-2 max-w-[150px] w-full text-center rounded-lg",children:s.status}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(N(),{href:"https://plataforma-v3.vercel.app/prospectIntegrador/PropostaComercialIntegrador.html?pedido=".concat(s.cod_pedidov),target:"_blank",rel:"noopener noreferrer",prefetch:!1,className:"max-w-[150px] w-full",children:(0,t.jsxs)("div",{className:"p-2 max-w-[150px] w-full text-center rounded-lg hover:underline\n ".concat(1===s.status_number?"fluxo-etapa-in":""," ").concat(s.status_number>1?"fluxo-etapa-passed":"fluxo-etapa-coming"," \n "),children:["Or\xe7amento ",(0,t.jsx)("i",{className:"bi bi-file-earmark-arrow-up"})]})}),(0,t.jsxs)("div",{className:"p-2 max-w-[150px] w-full text-center rounded-lg\n ".concat(2===s.status_number?"fluxo-etapa-in cursor-pointer":""," ").concat(s.status_number>2?"fluxo-etapa-passed":"fluxo-etapa-coming"," \n "),onClick:e=>i(s),children:["Comprar Pedido ",2===s.status_number?(0,t.jsx)("i",{className:"bi bi-cart"}):""]}),(0,t.jsx)("div",{className:"p-2 max-w-[150px] w-full text-center rounded-lg\n ".concat(3===s.status_number?"fluxo-etapa-in":""," ").concat(s.status_number>3?"fluxo-etapa-passed":"fluxo-etapa-coming"," \n "),children:"Em revis\xe3o"}),(0,t.jsx)("div",{className:"p-2 max-w-[150px] w-full text-center rounded-lg\n ".concat(4===s.status_number?"fluxo-etapa-in":""," ").concat(s.status_number>4?"fluxo-etapa-passed":"fluxo-etapa-coming"," \n "),children:"Aguardando Pagamento"}),(0,t.jsx)("div",{className:"p-2 max-w-[150px] w-full text-center rounded-lg\n ".concat(5===s.status_number?"fluxo-etapa-in":""," ").concat(s.status_number>5?"fluxo-etapa-passed":"fluxo-etapa-coming"," \n "),children:"Pagamento Aprovado"}),(0,t.jsx)("div",{className:"p-2 max-w-[150px] w-full text-center rounded-lg\n ".concat(5===s.status_number?"fluxo-etapa-in":""," ").concat(s.status_number>6?"fluxo-etapa-passed":"fluxo-etapa-coming"," \n "),children:"Faturado"}),(0,t.jsx)("div",{className:"p-2 max-w-[150px] w-full text-center rounded-lg\n ".concat(5===s.status_number?"fluxo-etapa-in":""," ").concat(s.status_number>7?"fluxo-etapa-passed":"fluxo-etapa-coming"," \n "),children:"Enviado"}),(0,t.jsx)("div",{className:"p-2 max-w-[150px] w-full text-center rounded-lg\n ".concat(5===s.status_number?"fluxo-etapa-in":""," ").concat(s.status_number>8?"fluxo-etapa-passed":"fluxo-etapa-coming"," \n "),children:"Entregue"})]})})]}),(0,t.jsxs)("div",{className:"bg-zinc-800 p-2 rounded-lg flex flex-col gap-2",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Cliente"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:"Nome:"})," ",s.nome_cliente]}),s.cnpj?(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:"CNPJ:"})," ",s.cnpj?s.cnpj:"-"]}):(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:"CPF:"})," ",s.cpf?s.cpf:"-"]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:"Telefone:"})," ",s.ddd?"(".concat(s.ddd,")"):""," ",s.cel?s.cel:"-"]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:"Email:"})," ",s.e_mail]})]}),(0,t.jsxs)("div",{className:"bg-zinc-800 p-2 rounded-lg flex flex-col gap-2",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Transporte"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:"Transportadora:"})," ",s.transportadora?s.transportadora:"-"]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:"Valor do frete:"})," ",s.v_frete?(0,w.xG)(s.v_frete):"-"]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:"Prazo de entrega:"})," ",s.prazoentregadias?"Em at\xe9 ".concat(s.prazoentregadias," dias \xfateis"):"-"]})]}),(0,t.jsxs)("div",{className:"bg-zinc-800 p-2 rounded-lg",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Total do pedido"}),(0,t.jsxs)("div",{children:["Total: ",(0,w.xG)(s.total)]})]})]}),(0,t.jsx)("div",{children:(0,t.jsx)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:s.produtos.map((e,a)=>{var n;return(0,t.jsxs)("div",{className:"border-l-2 border-amber-500 rounded-lg p-4 bg-zinc-800",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:"Nome:"})," ",e.cod_produto," - ",e.descricao1]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:"Quantidade: "}),e.quantidade]}),(null==e?void 0:null===(n=e.componentes)||void 0===n?void 0:n.length)>0?e.componentes.map(e=>(0,t.jsxs)("div",{className:"ml-4 text-sm flex flex-col gap-2 my-6",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:"Nome:"})," ",e.cod_produto," - ",e.descricao1]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:"Quantidade: "}),e.quantidade]})]},(0,E.x0)())):""]},"".concat(e.cod_produto,"-").concat(a))})})})]}),(0,t.jsx)(v.R,{children:(0,t.jsx)(u.A,{color:"danger",variant:"light",onPress:e,children:"Fechar"})})]})})})})}var k=n(67957);let T=e=>{let{representante:a,session:n}=e,[s,i]=(0,p.useState)(!1),{isOpen:r,onOpen:l,onOpenChange:x}=(0,k.q)(),[f,g]=(0,p.useState)(null),[j,b]=(0,p.useState)({representante:a[0].representante,buscaRepresentante:"CODIGO",cliente:"",buscaCliente:"COD_CLIENTE",data_inicial:(0,h.Lg)((0,h.iT)()),data_final:(0,h.Lg)((0,h.iT)())}),[v,_]=(0,p.useState)(null);async function N(){let e="start=0&end=50";j.cliente.length>0?e+="&COD_CLIENTE=".concat(j.cliente):e+=j.representante.toString().length>0?"&REPRESENTANTE=".concat(j.representante):"",e+=0===e.length?"datai=".concat(j.data_inicial,"&dataf=").concat(j.data_final):"&datai=".concat(j.data_inicial,"&dataf=").concat(j.data_final),i(!0);let a=await fetch("/api/integrador/historico-pedido",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({query:e})}).then(e=>e.json());if(console.log(a),i(!1),null==a?void 0:a.error)return alert("Ocorreu um erro ao buscar o hist\xf3rico");for(let e of a.value){switch(e.produtos=e.produtos.filter(e=>e.quantidade>0),e.status_number=0,e.status.toLowerCase().trim()){case"cancelado":e.status_number=0;break;case"orcamento":e.status_number=2;break;case"em revis\xe3o":e.status_number=3;break;case"ag. pagamento":e.status_number=4;break;case"pgto aprovado":e.status_number=5;break;case"faturado":e.status_number=6;break;case"enviado":e.status_number=7;break;case"entregue":e.status_number=8;break;default:e.status_number=-827,e.status="N\xe3o mapeado"}2===e.status&&"4.1 - REVIS\xc3O INTEG"===e.tipo_pedido&&(e.status="Em revis\xe3o",e.status_number=3);let a=e.produtos.filter(e=>e.cod_produto.includes("G")||e.componente_kit),n=[];if(a.length>0){for(let a of structuredClone(e.produtos)){if(a.cod_produto.includes("G")&&!a.componente_kit){let t=a.item,s=e.produtos.filter(e=>e.item.includes(t)&&!e.cod_produto.includes("G"));a.componentes=s,n.push(a)}if(!a.componente_kit&&!a.cod_produto.includes("G")){console.log("sc"),n.push(a);continue}}console.log("nn",n),e.produtos=n}}_(a.value)}return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(C,{onOpenChange:x,isOpen:r,data:f}),(0,t.jsxs)("div",{className:"w-[90%] bg-zinc-950 p-6 flex flex-col gap-[20px] mt-[5vh]",children:[(0,t.jsx)("h1",{className:"text-3xl text-center font-semibold",children:"Hist\xf3rico de Pedidos"}),(0,t.jsx)("h5",{className:"text-xs text-center",children:"(a quantidade maxima de pedidos retornada ser\xe1 50)"}),(0,t.jsx)("h3",{className:"text-xl text-center font-semibold",children:"Pesquisa por integrador/representante"}),(0,t.jsx)("div",{className:"",children:(0,t.jsx)(d.g,{label:"Integrador",placeholder:"Integrador",selectedKeys:[j.representante.toString()],disallowEmptySelection:!0,onChange:e=>b({...j,representante:e.target.value}),children:a.map(e=>(0,t.jsx)(o.R,{value:e.representante,className:"text-white",children:e.nome},e.representante))})}),(0,t.jsx)("h3",{className:"text-xl text-center font-semibold",children:"Pesquisa por cliente"}),(0,t.jsx)("div",{className:"",children:(0,t.jsx)(c.Y,{label:"Insira o c\xf3digo",placeholder:"Ex: 354446",value:j.cliente,onKeyDown:e=>{13===e.keyCode&&N()},onChange:e=>b({...j,cliente:e.target.value})})}),(0,t.jsx)("h3",{className:"text-xl text-center font-semibold",children:"Pesquisa por data"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,t.jsx)(m.J,{label:"Data inicial",value:j.data_inicial,onCh
1ange:e=>b({...j,data_inicial:e}),maxValue:(0,h.zO)((0,h.iT)())}),(0,t.jsx)(m.J,{label:"Data final",value:j.data_final,onChange:e=>b({...j,data_final:e}),maxValue:(0,h.zO)((0,h.iT)())})]}),(0,t.jsx)(u.A,{onPress:e=>N(),color:"warning",isLoading:s,isDisabled:s,children:"Buscar"})]}),(0,t.jsxs)("div",{className:"w-[90%] bg-zinc-950 p-6 flex flex-col gap-[20px] my-[5vh] min-h-[100px]",children:[(0,t.jsx)("h3",{className:"text-xl font-semibold",children:v?"Qtd encontrada: ".concat(v.length):"O resultado aparecer\xe1 aqui"}),(0,t.jsx)("div",{className:"max-h-[400px] grid grid-cols-2 gap-4 overflow-y-scroll",children:v?v.map((e,a)=>(0,t.jsxs)("div",{className:"bg-zinc-800 min-h-[300px] p-4 rounded",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:"C\xf3digo do pedido:"})," ",e.cod_pedidov]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:"Cliente:"})," ",e.cliente]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:"Tipo de pedido:"})," ",e.tipo_pedido]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:"Condi\xe7\xe3o de pagamento:"})," ",e.condicao_pagamento]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:"Data de emiss\xe3o:"})," ",e.data_emissao]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:"Representante:"})," ",e.representante]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:"Tipo frete:"})," ",e.tipo_frete]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:"Transportadora:"})," ",e.transportadora]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:"Vendedor:"})," ",e.vendedor]}),(0,t.jsx)("div",{className:"mt-2",children:(0,t.jsx)(u.A,{color:"warning",onPress:a=>{g(e),l()},children:"Detalhes do Pedido"})})]},a)):""})]})]})};var P=!0;function O(e){let{}=e,{data:a,status:n}=(0,r.useSession)(),[s,d]=(0,p.useState)(null);return((0,p.useEffect)(()=>{async function e(){try{let e=await fetch("/api/dimensionador/cliente/find-representante?tipoDocumento=REPRESENTANTE¶m=".concat(a.accessToken.id_representante)).then(e=>e.json()).then(e=>e.value);d(e)}catch(e){console.log(e)}}a&&!s&&e()},[a,s]),"loading"!==n&&s)?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(i(),{children:[(0,t.jsx)("title",{children:"Hist\xf3rico de Pedidos"}),(0,t.jsx)("meta",{name:"description"}),(0,t.jsx)("meta",{name:"viewport",content:"width=device-width, initial-scale=1"}),(0,t.jsx)("link",{rel:"icon",href:"/favicon.ico"})]}),(0,t.jsx)(l.Z,{session:a,newUI:!0,isDark:!0,noVerticalAlign:!0,children:(0,t.jsx)(T,{session:a,representante:s})})]}):(0,t.jsx)(x.e,{session:a})}}},function(e){e.O(0,[2370,9047,8443,5675,8628,9643,9734,1220,9005,9531,2142,2888,9774,179],function(){return e(e.s=90121)}),_N_E=e.O()}]);
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.