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]="18504c38-8714-5abd-8e0f-14be506a21f0")}catch(e){}}(); 3import{r as f,bL as y,V as d,Q as _,R as t,bY as N,l as c,ai as C,cT as F,bt as Y,cd as p,aL as D}from"./index-Cs-In7Vx.js";import{S as M}from"./SearchInput-6k8qtIIx.js";const g=f.createContext(),P=g.Provider,i=()=>f.useContext(g),R=a=>_.get(a).then(e=>{if(e.status!==200||e.data.status===500)throw Error(e.data.message);return{total:e.headers.total,data:e.data}}),S="/api/v1/painel/company_data";function T(a){const e=d.queryParamsObjectToString(a);return`${S}?${e}`}function O(a){const{data:e,error:r,mutate:o}=y(T(a),R,{dedupingInterval:6e4});return{data:e?.data,totalRecords:e?.total||0,isLoading:!r&&!e,isError:r,mutate:o}}function k(a){return Intl.NumberFormat("pt-BR").format(a)}function q(a){return a?.toLowerCase().replace(/(^\w{1})|(\s+\w{1})/g,e=>e.toUpperCase())}function I(){const{filters:a,formattedFilters:e,setFilters:r}=i(),{data:o,totalRecords:s,isLoading:l,isError:E}=O(e),[u,x]=t.useState(null);t.useEffect(()=>{o&&x(o)},[o]);const h=(n,w)=>{r({order_by:n,order:w})},v=n=>{r({page:n})},b=n=>{r({per_page:n})};return t.createElement(N,{data:u,totalRows:s,onRequestSort:h,onChangePage:v,onChangeRowsPerPage:b,resetCurrentPage:a.page===0,loading:o&&!u||l,loadingRowsQuantity:10,showError:E,stickyHeader:!0,columns:[{Header:"Empresa",accessor:"name",sortable:!1,className:"min-w-288 max-w-320 font-bold truncate",formatDataFunction:n=>q(n)},{Header:"Operando desde",accessor:"created_at",sortable:!0,formatDataFunction:n=>c(n).format("DD/MM/YYYY")},{Header:"Situação",accessor:"active",sortable:!1,align:"center",formatDataFunction:n=>n?t.createElement("span",{className:"font-bold text-green-dark"},"Ativa"):t.createElement("span",{className:"font-bold text-red-dark"},"Inativa")},{Header:"Total de pedidos",accessor:"total_quantity_of_orders",sortable:!0,align:"center",formatDataFunction:n=>k(n)},{Header:"Faturamento",accessor:"total_amount",sortable:!0,align:"center",formatDataFunction:n=>d.formatMonetaryValue(n)}]})}const L=t.memo(I);function V(){const{setFilters:a}=i(),[e,r]=t.useState(""),o=t.useMemo(()=>C(s=>{a({search_text:s})},800),[a]);return t.useEffect(()=>{o(e)},[e,o]),t.createElement(M,{placeholder:"Pesquise pelo nome ou e-mail da empresa",value:e,onChange:s=>r(s.target.value),className:"w-full sm:w-400"})}const $=t.memo(V),H=a=>_.get(a).then(e=>{if(e.status!==200||e.data.status===500)throw Error(e.data.message);return e.data}),B="/api/v1/painel/general_data";function U(a){const e=d.queryParamsObjectToString(a);return`${B}
3?${e}`}function A(a){const{data:e,error:r,mutate:o}=y(U(a),H,{dedupingInterval:6e4});return{data:e,isLoading:!r&&!e,isError:r,mutate:o}}function m(a){return Intl.NumberFormat("pt-BR").format(a)}function j({title:a,primary:e,secondary:r,loading:o,error:s}){const l=o?t.createElement(t.Fragment,null,t.createElement("div",{className:"my-3 h-36 w-3/5 animate-pulse rounded-4 bg-gray-200"}),t.createElement("div",{className:"h-20 w-2/5 animate-pulse rounded-4 bg-gray-200"})):s?t.createElement(t.Fragment,null,t.createElement("div",{className:"text-32 font-semibold text-red"},"0"),t.createElement("div",{className:"text-17 text-red"},"houve um erro")):t.createElement(t.Fragment,null,t.createElement("div",{className:"text-36 font-semibold text-gray-600"},e),t.createElement("div",{className:"text-17 text-gray-600"},r));return t.createElement("div",{className:"w-full"},t.createElement(Y,{className:"flex flex-1 flex-col rounded-8 p-16",variant:"outlined"},t.createElement("div",{className:"text-16 text-gray-500"},a),l))}function W(){const{formattedFilters:a}=i(),{data:e,isLoading:r,isError:o}=A(F(a,["company_start_date","company_end_date","order_start_date","order_end_date","situation"])),s=t.useMemo(()=>[{title:"Total de pedidos",primary:m(e?.total_quantity_of_orders||0),secondary:d.formatMonetaryValue(e?.total_amount||0)},{title:"Pedidos delivery",primary:m(e?.delivery_quantity||0),secondary:d.formatMonetaryValue(e?.delivery_amount||0)},{title:"Pedidos retirada",primary:m(e?.takeout_quantity||0),secondary:d.formatMonetaryValue(e?.takeout_amount||0)},{title:"Pedidos consumo no local",primary:m(e?.onsite_quantity||0),secondary:d.formatMonetaryValue(e?.onsite_amount||0)},{title:"Pedidos mesa",primary:m(e?.closed_table_quantity||0),secondary:d.formatMonetaryValue(e?.closed_table_amount||0)},{title:"Pedidos agendados",primary:m(e?.scheduled_quantity||0),secondary:d.formatMonetaryValue(e?.scheduled_amount||0)}].map(l=>({...l,loading:r,error:o})),[e,o,r]);return t.createElement("div",{className:"grid grid-cols-1 gap-16 sm:grid-cols-3 lg:grid-cols-4"},s.map(l=>t.createElement(j,{key:l.title,...l})))}const G=t.memo(W);c.locale("pt-BR");function K(){const{filters:a,setFilters:e}=i();return t.createElement("div",{className:"flex w-full flex-col flex-wrap space-x-0 space-y-12 sm:w-auto sm:flex-row sm:items-end sm:space-x-16 sm:space-y-0"},t.createElement("div",{className:"space-y-1"},t.createElement("div",{className:"text-12 text-gray-600"},"Filtro por inÃcio da operação"),t.createElement(p,{value:[a.company_start_date,a.company_end_date],onChange:r=>e({company_start_date:r[0],company_end_date:r[1]}),maxDaysAllowed:null,className:"w-full"})),t.createElement("div",{className:"space-y-1"},t.createElement("div",{className:"text-12 text-gray-600"},"Filtro por data do pedido"),t.createElement(p,{value:[a.order_start_date,a.order_end_date],onChange:r=>e({order_start_date:r[0],order_end_date:r[1]}),maxDaysAllowed:200,className:"w-full"})),t.createElement("div",{className:"pt-12"},t.createElement(D,{name:"situation",label:"Status da empresa",value:a.situation,onChange:r=>e({situation:r.target.value}),optionValueKey:"key",optionLabelKey:"label",options:[{key:"true",label:"Ativa"},{key:"false",label:"Inativa"}],className:"w-full bg-white sm:w-208"})))}const Q=t.memo(K);function X(){const[a,e]=t.useState({page:0,per_page:10,order:"desc",order_by:"total_quantity_of_orders",company_start_date:c("01/01/2020","DD/MM/YYYY").toDate(),company_end_date:c().endOf("month").toDate(),order_start_date:c().startOf("month").toDate(),order_end_date:c().endOf("month").toDate(),situation:"true",search_text:""}),r=t.useCallback(s=>{Object.prototype.hasOwnProperty.call(s,"page")?e(l=>({...l,...s})):e(l=>({...l,...s,page:0}))},[]),o=t.useMemo(()=>({...a,page:a.page+1,company_start_date:c(a.company_start_date).format("YYYY-MM-DDT00:00:00.000"),company_end_date:c(a.company_end_date).format("YYYY-MM-DDT23:59:59.999"),order_start_date:c(a.order_start_date).format("YYYY-MM-DDT00:00:00.000"),order_end_date:c(a.order_end_date).format("YYYY-MM-DDT23:59:59.999")}),[a]);return t.createElement(P,{value:{filters:a,formattedFilters:o,setFilters:r}},t.createElement("div",{className:"flex w-full flex-1 flex-col space-y-24 overflow-auto px-12 py-24 sm:px-28"},t.createElement(Q,null),t.createElement(G,null),t.createElement($,null),t.createElement("div",{className:"max-h-full"},t.createElement(L,null))))}export{X as default}; 4 5//# debugId=18504c38-8714-5abd-8e0f-14be506a21f0
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.