1import{j as e,P as y,R as j,T as N,C as v,a9 as C}from"./ui-916dc9d9.js";import{E as P}from"./EmptyPageGeneric-231f5a18.js";import{E as T}from"./ErrorRequestGeneric-f308c427.js";import{c as D,H as w,f as b,a as L,aG as E,aH as S,a8 as h,aI as k,aJ as F,aK as M}from"./index-b93ebc97.js";import{r as n}from"./vendor-aea060b0.js";import{c as R,b as A}from"./SkeletonsPortal-4886f27c.js";import{a as O,D as f}from"./CreditCardPaymentError-6a904eab.js";import{P as V}from"./PortalContent-685029ff.js";import{P as H}from"./PortalWrapperContent-060be1ae.js";import"./pdf-viewer-9b371a90.js";import"./motion-b076d11a.js";import"./index-9cd944d6.js";import"./index-72cc605b.js";import"./luxon-cc86f6dc.js";import"./QuickAccess-3c3dd55b.js";import"./PayInvoiceDrawerPortal-e6991f07.js";import"./useInvoicePixStatus-c13bff6b.js";import"./IconCircleCheck-f8f43b13.js";import"./InvoiceInRecurrenceInfo-d99f2dcd.js";import"./EmbedPortalProvider-7afc0bbf.js";import"./IconBrandWhatsapp-38cdc0da.js";import"./HelmetTitle-6d149794.js";import"./PaymentMethodConfig-7ce80ffd.js";import"./AutomaticPixQrCode-04795775.js";import"./IconCheck-78a7cf1f.js";import"./IconCircleX-bed3c750.js";import"./swiper-442b9b58.js";import"./scroll-area-295de0fa.js";import"./IconCirclePlus-440222cd.js";import"./FloatAlertSignContract-1271883a.js";var G=D("file-x","IconFileX",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z",key:"svg-1"}],["path",{d:"M10 12l4 4m0 -4l-4 4",key:"svg-2"}]]);function J(){const{permissions:s}=w(),[t,a]=n.useState(!1),[l,o]=n.useState(!1),[r,i]=n.useState(new Date().toISOString().split("T")[0]),[x,c]=n.useState(!1),d=b(u=>u.contracts.activeContract),{data:p,error:g,isLoading:m}=L(["getPhoneCalls",d==null?void 0:d.id,r],async({queryKey:u})=>!(s!=null&&s.viewTelecomInfo)||!d||d==null?[]:await E(u[1],r),{refetchOnWindowFocus:!1,refetchOnMount:!1,retry:3,staleTime:30*1e3,enabled:!!(l&&(s!=null&&s.viewTelecomInfo)&&(d!=null&&d.id)),refetchInterval:t?3e3:!1,onSuccess:()=>{a(!1),c(!1)},onError:()=>{a(!1),c(!1)}});return n.useEffect(()=>{d&&o(!0)},[d]),n.useEffect(()=>{a(!0)},[r]),{phoneCallsList:p,phoneCallsError:g,isLoading:m,dateFilter:r,setDateFilter:i,setRefetchPhoneCalls:a,isUpdating:x,setIsUpdating:c}}function X({setDateFilter:s,setIsUpdating:t}){const[a,l]=n.useState(new Date().getMonth()+1),[o,r]=n.useState(new Date().getFullYear()),i=c=>{l(Number(c.target.value)),t(!0)},x=c=>{r(Number(c.target.value)),t(!0)};return n.useEffect(()=>{const c=new Date(o,a-1,1);s(c.toISOString().split("T")[0]),t(!0)},[a,s,o]),e.jsxs("div",{className:"flex flew-row mb-6",children:[e.jsxs("div",{className:"flex flex-col mr-4 ",children:[e.jsx("label",{htmlFor:"month",className:"text-sm font-medium text-defaultText mb-1",children:"Mês"}),e.jsxs("select",{name:"month",id:"month",className:"input-txid border border-gray-200 rounded-md !bg-white !px-4 !py-2 !mt-0 text-sm font-medium text-defaultText",value:a,onChange:i,children:[e.jsx("option",{value:"1",children:"Janeiro"}),e.jsx("option",{value:"2",children:"Fevereiro"}),e.jsx("option",{value:"3",children:"Março"}),e.jsx("option",{value:"4",children:"Abril"}),e.jsx("option",{value:"5",children:"Maio"}),e.jsx("option",{value:"6",children:"Junho"}),e.jsx("option",{value:"7",children:"Julho"}),e.jsx("option",{value:"8",children:"Agosto"}),e.jsx("option",{value:"9",children:"Setembro"}),e.jsx("option",{value:"10",children:"Outubro"}),e.jsx("option",{value:"11",children:"Novembro"}),e.jsx("option",{value:"12",children:"Dezembro"})]})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"year",className:"text-sm font-medium text-defaultText mb-1 ",children:"Ano"}),e.jsx("input",{type:"number",maxLength:1,name:"year",id:"year",className:"input-txid border border-gray-200 rounded-md !mt-0 !px-2 !pl-3 !py-[9px] text-sm font-medium !bg-white text-defaultText !w-[80px]",value:o,onChange:x})]})]})}const Y={LC:"Fixo Local",LDE:"Fixo Longa Distância",LDN:"Fixo Longa Distância",LDI:"Longa Distância Internacional",ITL:"Longa Distância Internacional",VC1:"Móvel Local",VC2:"Móvel Longa Distância",VC3:"Móvel Longa Distância",VCX:"Recebidas no 0800",800:"800"};function q({phoneCallsList:s,isUpdating:t}){const[a,l]=n.useState(0),{isAdylCompany:o}=S();return n.useEffect(()=>{if(s&&s.length>0){const r=s.reduce((i,x)=>i+x.value,0);l(r)}},[s]),e.jsx("div",{className:"border border-gray-100 rounded bg-white overflow-auto",children:e.jsxs("table",{className:"table-auto",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"lg:text-sm text-xs leading-6 font-bold text-defaultTextDark bg-gradient-to-r from-primaryTransparent to-secondaryTransparent",children:[e.jsx("th",{className:"border-b border-gray-200 px-4 py-2",children:"Data"}),e.jsx("th",{className:"border-b border-gray-200 px-4 py-2",children:"Hora"}),o&&e.jsx("th",{className:"border-b border-gray-200 px-4 py-2",children:"Origem"}),e.jsx("th",{className:"border-b border-gray-200 px-4 py-2",children:"Destino"}),!o&&e.jsx("th",{className:"border-b border-gray-200 px-4 py-2",children:"Descrição"}),o&&e.jsx("th",{className:"border-b border-gray-200 px-4 py-2",children:"Tipo de Ligação"}),e.jsx("th",{className:"border-b border-gray-200 px-4 py-2",children:"Duração"}),e.jsx("th",{className:"border-b border-gray-200 px-4 py-2",children:"Valor"})]})}),e.jsxs("tbody",{children:[!t&&s.map((r,i)=>e.jsxs("tr",{className:"lg:text-sm text-xs font-medium text-defaultText",children:[e.jsx("td",{className:"border-b border-gray-200 px-4 py-2",children:O.formatDueDate(r==null?void 0:r.date)}),e.jsx("td",{className:"border-b border-gray-200 px-4 py-2",children:r==null?void 0:r.hour}),o&&e.jsx("td",{className:"border-b border-gray-200 px-4 py-2",children:h.formatPhoneNumber(r==null?void 0:r.origin)}),e.jsxs("td",{className:"border-b border-gray-200 px-4 py-2",children:[" ",h.formatPhoneNumber(r==null?void 0:r.destination)]}),!o&&e.jsx("td",{className:"flex border-b border-gray-200 px-4 py-2",children:r==null?void 0:r.description}),o&&e.jsx("td",{className:"border-b border-gray-200 px-4 py-2",children:Y[r==null?void 0:r.type]??(r==null?void 0:r.type)}),e.jsx("td",{className:"border-b border-gray-200 px-4 py-2",children:r==null?void 0:r.duration}),e.jsx("td",{className:"border-b border-gray-200 px-4 py-2",children:f.formatAmou
1nt(r==null?void 0:r.value)})]},i)),e.jsxs("tr",{className:"lg:text-sm text-xs font-medium text-defaultText",children:[e.jsx("td",{className:"border-b border-gray-200 px-4 py-2"}),e.jsx("td",{className:"border-b border-gray-200 px-4 py-2"}),o&&e.jsx("td",{className:"border-b border-gray-200 px-4 py-2"}),e.jsx("td",{className:"border-b border-gray-200 px-4 py-2"}),!o&&e.jsx("td",{className:"border-b border-gray-200 px-4 py-2"}),o&&e.jsx("td",{className:"border-b border-gray-200 px-4 py-2"}),e.jsx("td",{className:" border-gray-200 bg-gray-200 font-bold px-4 py-2",children:"Total:"}),e.jsxs("td",{className:" border-gray-200 bg-gray-200 px-4 py-2",children:[" R$ ",f.formatAmount(a)]})]}),t&&e.jsx(R,{})]})]})})}function Q(){return e.jsx("div",{className:"skeleton-bg h-[18px] w-[100px] animate-pulse rounded-sm"})}function z({origin:s,isLoading:t}){var o;const a=b(r=>r.contracts.activeContract),l=n.useCallback(r=>r.split(", ").map(i=>h.formatPhoneNumber(i)).join(", "),[]);return e.jsxs("div",{className:"text-sm font-semibold flex items-start pb-3 flex-col gap-1",children:[e.jsxs("span",{children:["Nome do cliente: ",e.jsx("a",{className:"font-normal",children:(o=a==null?void 0:a.customer)==null?void 0:o.name})]}),e.jsxs("span",{children:["Origem:",t?e.jsx(Q,{}):s?e.jsxs("span",{className:"font-medium",children:[" ",l(s)]}):""]})]})}function B(){const[s,t]=n.useState(!1),a=b(r=>r.contracts.activeContract),l=k();return{fetchExportPhoneCalls:n.useCallback(async({competence:r})=>{t(!0);const i=await l.fetchQuery(["exportPhoneCalls",a==null?void 0:a.id,r],()=>F(a==null?void 0:a.id,r));return t(!1),i},[a==null?void 0:a.id,l]),isLoading:s}}function W({dateFilter:s}){const{fetchExportPhoneCalls:t,isLoading:a}=B(),l=n.useCallback(async()=>{try{const o=await t({competence:s});M(o,`registros-telefonicos-${s}.xlsx`,"application/vnd.ms-excel")}catch(o){console.error(o)}},[s,t]);return e.jsx(y,{children:e.jsxs(j,{children:[e.jsx(N,{asChild:!0,children:e.jsx("div",{onClick:l,className:"p-2 rounded-full cursor-pointer bg-gray-300 w-10 h-10 flex items-center",children:e.jsx(G,{})})}),e.jsxs(v,{className:"bg-black text-white p-2 rounded",children:["Exportar relatório em xlsx",e.jsx(C,{className:"fill-black"})]})]})})}function _(){var d;const{phoneCallsList:s,phoneCallsError:t,isLoading:a,setDateFilter:l,dateFilter:o,isUpdating:r,setIsUpdating:i}=J(),x=((d=s==null?void 0:s.portalTelecomRecordPhoneCalls)==null?void 0:d.length)>0,c=[...new Set(((s==null?void 0:s.portalTelecomRecordPhoneCalls)||[]).map(p=>p.origin).filter(Boolean))].map(p=>h.formatPhoneNumber(p)).join(", ");return e.jsxs(e.Fragment,{children:[e.jsx(z,{origin:c,isLoading:a}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(X,{setDateFilter:l,setIsUpdating:i}),e.jsx(W,{dateFilter:o}),a&&e.jsx(A,{})]}),!a&&!r&&t&&e.jsx(T,{message:"Erro ao carregar registros telefônicos."}),!a&&!r&&!t&&!x&&e.jsx(P,{message:"Nenhum registro encontrado"}),!r&&e.jsx("div",{className:"max-w-fit flex flex-col gap-6 overflow-auto",children:x&&e.jsx(q,{phoneCallsList:s.portalTelecomRecordPhoneCalls,isUpdating:r})})]})}function De(){return e.jsx(H,{pageTitle:"Registros Telefônicos",children:e.jsx(V,{quickAccess:!1,children:e.jsx(_,{})})})}export{De 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.