1 2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c734a459-7a69-591d-9fce-bc2fab61689f")}catch(e){}}(); 3import{R as e,Y as C,d0 as F,d1 as A,aM as I,bx as T,d2 as P,c$ as L,b2 as B,bN as Y,l as o,bL as z,bM as $,V as O,a5 as R,bk as N,n as j,bh as V,d3 as H,S as U,r as S,Q as W,ai as q,E as D,aY as G,L as Q,C as X,aO as y,cd as Z,bt as M}from"./index-Cs-In7Vx.js";import{C as J}from"./CheckBoxOutlineBlankRounded-B4fof7Ef.js";import{C as K}from"./CheckBoxRounded-9nIk-vPl.js";import{h as ee}from"./react-apexcharts.esm-BeyC2Cqp.js";import{D as te}from"./Done-CqMP_G1M.js";import{S as ae}from"./SearchInput-6k8qtIIx.js";import{S as ne}from"./StoreRounded-rFkBW34T.js";const le=L(t=>({inputBase:{padding:14,width:"100%",borderBottom:"1px solid #dfe2e5","& input":{borderRadius:4,backgroundColor:t.palette.common.white,padding:8,transition:t.transitions.create(["border-color","box-shadow"]),border:"1px solid #ced4da",fontSize:14}},option:{minHeight:"auto",alignItems:"flex-start",padding:8,'&[aria-selected="true"]':{backgroundColor:"transparent"},'&[data-focus="true"]':{backgroundColor:t.palette.action.hover}}}));function re({value:t,setValue:a,options:l,buttons:r,onClose:c=void 0}){const m=le(),[d,p]=e.useState(null),_=s=>{p(s.currentTarget)},u=(s,n)=>{n!=="toggleInput"&&(d&&d.focus(),c&&c(),p(null))},f=!!d,i=f?"autocomplete":void 0;return e.createElement(e.Fragment,null,e.createElement(C,{variant:"outlined",className:"min-w-208",disableRipple:!0,startIcon:e.createElement(F,null),onClick:_},e.createElement("span",null,t.length>0?`${t.length} eventos selecionados`:"Nenhum evento selecionado")),e.createElement(A,{id:i,open:f,anchorEl:d,placement:"bottom-start",className:"z-10 mt-8 min-w-320 rounded-8 border-1 border-solid border-grey-border bg-white text-16 shadow"},e.createElement(I,{open:!0,onClose:u,multiple:!0,classes:{paper:"shadow-0 text-gray-600",option:m.option,popperDisablePortal:"relative"},value:t,onChange:(s,n)=>{a(n)},disableCloseOnSelect:!0,disablePortal:!0,renderTags:()=>null,noOptionsText:"Evento não encontrado",renderOption:(s,{selected:n})=>e.createElement(e.Fragment,null,e.createElement(te,{className:"ml-2 mr-6 h-20 opacity-60",style:{visibility:n?"visible":"hidden"}}),e.createElement("div",{className:"flex flex-grow text-15"},s.label,e.createElement("br",null),s.description),e.createElement(P,{className:"h-20 opacity-60",style:{visibility:n?"visible":"hidden"}})),options:l,getOptionSelected:(s,n)=>s.id===n.id,getOptionLabel:s=>s.label,renderInput:s=>e.createElement(e.Fragment,null,e.createElement("div",{className:"padding flex items-center justify-center space-x-16 pl-16 pr-2 pt-4"},e.createElement("div",null,"Selecione os eventos para filtrar"),e.createElement("div",{className:"flex"},r.map(n=>n))),e.createElement(T,{ref:s.InputProps.ref,inputProps:s.inputProps,autoFocus:!0,className:m.inputBase}))})))}const g={create_subscription:{kind:"create_subscription",label:"Assinatura criada"},change_subscription_plan:{kind:"change_subscription_plan",label:"Mudança de plano"},add_extra_module:{kind:"add_extra_module",label:"Módulo contratado"},unsubscribe_extra_module:{kind:"unsubscribe_extra_module",label:"Módulo cancelado"},reactivated_subscription:{kind:"reactivated_subscription",label:"Assinatura reativada"},renewed_subscription:{kind:"renewed_subscription",label:"Assinatura renovada"},unsubscribe_subscription:{kind:"unsubscribe_subscription",label:"Assinatura cancelada"},subscription_inactivated:{kind:"subscription_inactivated",label:"Assinatura inativada"},apply_new_coupon:{kind:"apply_new_coupon",label:"Cupom aplicado"},remove_coupon:{kind:"remove_coupon",label:"Cupom removido"},add_credit_card:{kind:"add_credit_card",label:"Cartão adicionado"},remove_credit_card:{kind:"remove_credit_card",label:"Cartão removido"},change_payment_method:{kind:"change_payment_method",label:"Forma de pagamento alterada"},change_payday:{kind:"change_payday",label:"Dia de pagamento alterado"},change_document_info:{kind:"change_document_info",label:"Documentos alterados"},change_billing_address:{kind:"change_billing_address",label:"Endereço de faturamento alterado"},generated_billing:{kind:"generated_billing",label:"Fatura gerada"},deleted_billing:{kind:"deleted_billing",label:"Fatura excluÃda"},error_processing_billing:{kind:"error_processing_billing",label:"Erro ao processar fatura"},billing_was_paid:{kind:"billing_was_paid",label:"Fatura paga"},billing_was_paid_with_credit_card:{kind:"billing_was_paid_with_credit_card",label:"Fatura paga com cartão de crédito"},switch_billing_installment_type:{kind:"switch_billing_installment_type",label:"Alterado o tipo de parcelamento da cobrança"},create_one_time_charge:{kind:"create_one_time_charge",label:"Cobrança avulsa criada"},payment_extended:{kind:"payment_extended",label:"Tolerância de pagamento estendida"},pause_subscription:{kind:"pause_subscription",label:"Assinatura pausada"},unpause_subscription:{kind:"unpause_subscription",label:"Assinatura despausada"},update_subscription_plan_price:{kind:"update_subscription_plan_price",label:"Preço de assinatura atualizado"},update_subscription_extra_module_price:{kind:"update_subscription_extra_module_price",label:"Preço de módulo atualizado"},enable_subscription_automatic_renew:{kind:"enable_subscription_automatic_renew",label:"Renovação de assinatura reativada"},enable_extra_module_automatic_renew:{kind:"enable_extra_module_automatic_renew",label:"Renovação de módulo reativada"},disable_subscription_automatic_renew:{kind:"disable_subscription_automatic_renew",label:"Renovação de assinatura cancelada"},disable_extra_module_automatic_renew:{kind:"disable_extra_module_automatic_renew",label:"Renovação de módulo cancelada"}},k=B(Object.keys(g),["generated_billing","billing_was_paid"]),w=Y(t=>({filters:{created_at:null,kind:null,search_text:null},updateFilter:a=>t(l=>({...l,filters:{...l.filters,...a}}))})),x=Y(t=>({filters:{start_date:new Date(o().startOf("week")),end_date:new Date(o().endOf("week"))},updateFilter:(a,l)=>t(r=>({...r,filters:{...r.filters,[a]:l}}))})),se="/api/v2/admin/subscription/subscription_events";function oe(t){const a={...t};a.start_date=a.start_date?o(a.start_date).format("YYYY-MM-DDT00:00:00.000"):null,a.end_date=a.end_date?o(a.end_date).format("YYYY-MM-DDT23:59:59.999"):null;const l=O.queryParamsObjectToString(a);return`${se}?${l}`}function ie(t){const{data:a,error:l,mutate:r}=z(oe(t),$,{dedupingInterval:1e4});return{data:a?.data,totalRecords:a?.total||0,isLoading:!l&&!a,isError:l,mutate:r}}const ce={chart:{type:"bar",height:280,stacked:!0,toolbar:{show:!1,tools:{download:!1}},zoom:{enabled:!1}}
3,colors:["#2E93fA","#66DA26","#E91E63","#FF9800","#fd7f6f","#546E7A","#7eb0d5","#b2e061","#bd7ebe","#ffb55a","#ffee65","#beb9db","#fdcce5","#8bd3c7"],dataLabels:{enabled:!1},responsive:[{breakpoint:480,options:{legend:{position:"bottom",offsetX:-10,offsetY:0}}}],plotOptions:{bar:{horizontal:!1,borderRadius:10}},xaxis:{type:"category",categories:[]},legend:{position:"bottom"},fill:{opacity:1}};function de(t,a){return t.map(l=>a?.[l]||0)}function ue(){const[t,a]=e.useState(k),[l,r]=e.useState(ce),c=w(n=>n.updateFilter),m=x(n=>n.filters),{data:d,isLoading:p}=ie(m),[_,u]=e.useState(k.map(n=>({id:n,label:g[n].label}))),f=()=>{a(_.map(n=>n.id))},i=e.useMemo(()=>{const{start_date:n,end_date:h}=m;let E=o(n);const v=[];for(;E.isSameOrBefore(h);)v.push(E.format("YYYY-MM-DD")),E=E.clone().add(1,"day");return v},[m]),s=e.useMemo(()=>i&&d?Object.keys(d).filter(n=>t.includes(n)).map(n=>({kind:g?.[n]?.kind,name:g?.[n]?.label||"Desconhecido",data:de(i,d[n])})):[],[i,d,t]);return e.useEffect(()=>{r(n=>({...n,chart:{...n.chart,events:{dataPointSelection:function(h,E,v){c({created_at:i[v.dataPointIndex],kind:s[v.seriesIndex]?.kind})}}},xaxis:{type:"datetime",categories:i}}))},[i,s,c]),p?e.createElement(R,null):e.createElement("div",{className:"flex h-full w-full flex-col space-y-16"},e.createElement("div",{className:"flex w-full space-x-12"},e.createElement(re,{value:_,setValue:u,onClose:f,options:Object.values(g).map(n=>({id:n.kind,label:n.label}))||[],buttons:[e.createElement(N,{key:"select-all",tooltip:"Marcar Todos",onClick:()=>u(k.map(n=>({id:n,label:g[n].label}))),color:"default"},e.createElement(K,null)),e.createElement(N,{key:"deselect-all",tooltip:"Desmarcar Todos",onClick:()=>u([]),color:"default"},e.createElement(J,null))]})),e.createElement("div",{key:`chart-${t.length}`,className:"h-full w-full flex-1"},e.createElement(ee,{options:l,series:s,type:"bar",width:"100%"})))}function me({event:t}){const a=j();return e.createElement("div",{className:"flex-1 cursor-pointer space-y-12 px-20 py-16 hover:bg-gray-50",onClick:()=>a.push(`/contas/${t?.owner_id}`)},e.createElement("div",{className:"text-16 font-medium text-gray-600"},t.description),e.createElement("div",{className:"space-y-8"},t.owner&&e.createElement("div",{className:"flex items-center space-x-8 text-16 text-gray-400"},e.createElement(V,{className:"text-gray-300"}),e.createElement("div",{className:"truncate"},t.owner)),t.company&&e.createElement("div",{className:"flex items-center space-x-8 text-16 text-gray-400"},e.createElement(ne,{className:"text-gray-300"}),e.createElement("div",{className:"truncate"},t.company)),t.created_at&&e.createElement("div",{className:"flex items-center space-x-8 text-16 text-gray-400"},e.createElement(H,{className:"text-gray-300"}),e.createElement("div",{className:"truncate"},o(t.created_at).format("DD/MM/YYYY HH:mm")))))}const pe=10,be=t=>(a,l)=>{const r=O.queryParamsObjectToString(t);return l&&!l.data?.length?null:a===0?`/api/v2/admin/subscription/subscription_events_details?${r}`:`/api/v2/admin/subscription/subscription_events_details?${r}&cursor=${l.data[l.data.length-1].id}`},_e=t=>W.get(t).then(a=>a.status!==200||a.data.status===500?{data:[]}:{data:a.data});function fe(t){const{data:a,error:l,mutate:r,size:c,setSize:m,isValidating:d}=U(t?.created_at&&t?.kind?be(t):null,_e,{revalidateOnFocus:!1}),p=S.useCallback(()=>m(c+1),[m,c]),_=S.useMemo(()=>{try{return a?[].concat(...a.map(h=>h.data)):[]}catch{return[]}},[a]),u=!a&&!l,f=u||c>0&&a&&typeof a[c-1]>"u",i=a?.[0]?.data?.length===0,s=i||a&&a[a.length-1]?.data?.length<pe,n=d&&a&&a.length===c;return{events:_,isLoading:u,isLoadingMore:f,isEmpty:i,isReachingEnd:s,isRefreshing:n,loadMore:p,mutate:r}}function ge(){const t=w(n=>n.filters),a=w(n=>n.updateFilter),{events:l,isLoading:r,isError:c,isEmpty:m,isReachingEnd:d,isLoadingMore:p,loadMore:_}=fe(t),[u,f]=e.useState(""),i=e.useMemo(()=>q(n=>{a({search_text:n})},600),[a]),s=e.useRef(!0);return e.useEffect(()=>{s.current?(s.current=!1,a({search_text:""})):i(u)},[u,i,a]),!t?.created_at||!t?.kind?e.createElement(D,{title:"Selecione algum evento no gráfico"}):r&&!l?e.createElement(R,null):c?e.createElement(G,{title:"Problema ao buscar os eventos"}):e.createElement(e.Fragment,null,e.createElement("div",{className:"h-4 rounded-t-8"},r&&e.createElement(Q,{color:"primary",className:"w-full"})),e.createElement("div",{className:"space-y-12 border-0 border-b-1 border-solid border-gray-200 p-20"},e.createElement("div",{className:"text-center text-24 font-bold text-gray-600"},"Detalhes dos eventos"),e.createElement("div",{className:"space-y-4"},t.created_at?e.createElement("div",{className:"text-16 font-medium text-gray-500"},"do dia ",e.createElement("strong",null,o(t.created_at).format("DD/MM/YYYY"))):e.createElement("div",{className:"text-16 font-medium text-gray-500"},"Escolha um dia no gráfico"),t.kind&&g[t.kind]?e.createElement("div",{className:"text-16 font-medium text-gray-500"},"do tipo ",e.createElement("strong",null,g[t.kind].label)):e.createElement("div",{className:"text-16 font-medium text-gray-500"},"Escolha um tipo no gráfico")),e.createElement(ae,{placeholder:"Pesquise pela descrição ou empresa",value:u,onChange:n=>
3f(n.target.value),wrapperClassName:"w-full"})),e.createElement("div",{className:"overflow-auto"},m&&e.createElement(D,{title:"Nenhum evento encontrado"}),e.createElement("div",{className:"divide-x-0 divide-y-1 divide-solid divide-gray-200"},l.map(n=>e.createElement(me,{key:n.id,event:n}))),l?.length>0&&!d&&e.createElement("div",{className:"px-20 py-12"},e.createElement(C,{fullWidth:!0,onClick:_,disabled:p,className:"text-gray-500"},p?e.createElement(X,{color:"primary",size:20}):"Carregar mais"))))}function b(t,a){return a?[o().subtract(a,t).startOf(t).toDate(),o().subtract(a,t).endOf(t).toDate()]:[o().startOf(t).toDate(),o().endOf(t).toDate()]}const Ee=[{label:"Hoje",value:b("day"),placement:"left"},{label:"Ontem",value:b("day",1),placement:"left"},{label:"Esta semana",value:b("week"),placement:"left"},{label:"Semana passada",value:b("week",1),placement:"left"},{label:"Este mês",value:b("month"),placement:"left"},{label:"Mês passado",value:b("month",1),placement:"left"},{label:y(o().subtract(2,"months").format("MMMM/YYYY")),value:b("month",2),placement:"left"},{label:y(o().subtract(3,"months").format("MMMM/YYYY")),value:b("month",3),placement:"left"},{label:y(o().subtract(4,"months").format("MMMM/YYYY")),value:b("month",4),placement:"left"},{label:"Ãltimos 65 dias",value:[o().subtract(64,"day").startOf("day").toDate(),o().endOf("day").toDate()],placement:"left"}];o.locale("pt-BR");function ve(){const t=x(r=>r.filters.start_date),a=x(r=>r.filters.end_date),l=x(r=>r.updateFilter);return e.createElement("div",{className:"flex w-full flex-wrap rounded-8 border border-solid border-grey-border bg-white py-6 pl-12"},e.createElement(Z,{value:[t,a],onChange:r=>{l("start_date",r[0]),l("end_date",r[1])},className:"my-6 mr-12",ranges:Ee,appearance:"subtle",maxDaysAllowed:65,allowFuture:!0}))}function De(){return e.createElement("div",{className:"flex w-full flex-1 flex-col space-y-20 overflow-auto px-12 py-24 sm:px-28"},e.createElement(ve,null),e.createElement("div",{className:"flex max-w-full flex-1 flex-col space-x-0 space-y-16 overflow-auto md:flex-row md:space-x-16 md:space-y-0"},e.createElement(M,{variant:"outlined",className:"flex h-full flex-1 items-center rounded-8 p-16"},e.createElement(ue,null)),e.createElement(M,{variant:"outlined",className:"h-full w-full flex-shrink-0 overflow-auto rounded-8 md:w-400"},e.createElement(ge,null))))}export{De as default}; 4 5//# debugId=c734a459-7a69-591d-9fce-bc2fab61689f
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.