@zydon/common 2.9.86 → 2.9.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/chunk-43EX76EH.js +16 -0
- package/dist/chunk-43EX76EH.js.map +1 -0
- package/dist/chunk-HVLIOIAP.js +34 -0
- package/dist/chunk-HVLIOIAP.js.map +1 -0
- package/dist/chunk-NJ266SSN.js +12 -0
- package/dist/chunk-NJ266SSN.js.map +1 -0
- package/dist/chunk-U7DEJBXJ.js +32 -0
- package/dist/chunk-U7DEJBXJ.js.map +1 -0
- package/dist/components/Analytics/Carts/index.js +5 -5
- package/dist/components/Analytics/OverviewAnalytics/index.js +6 -6
- package/dist/components/Analytics/PartnerAnalysis/index.js +4 -4
- package/dist/components/AvatarButton/index.js +1 -1
- package/dist/components/AvatarButton/index.js.map +1 -1
- package/dist/components/BulkEditModal/index.js +1 -1
- package/dist/components/DataView/index.d.ts +17 -47
- package/dist/components/DataView/index.js +2 -2
- package/dist/components/DynamicDataView/index.d.ts +6 -3
- package/dist/components/DynamicDataView/index.js +11 -11
- package/dist/components/DynamicDataView/index.js.map +1 -1
- package/dist/components/SelectList/index.js +1 -1
- package/dist/components/StepUpDialog/index.js +1 -1
- package/dist/components/form/Codes/index.js +1 -1
- package/dist/components/form/SelectList/index.js +1 -1
- package/dist/props-72e91525.d.ts +86 -0
- package/package.json +1 -1
- package/dist/bulkActions-29cd56a9.d.ts +0 -28
- package/dist/chunk-BT3FTBTT.js +0 -12
- package/dist/chunk-BT3FTBTT.js.map +0 -1
- package/dist/chunk-NM3VHC2R.js +0 -27
- package/dist/chunk-NM3VHC2R.js.map +0 -1
- package/dist/chunk-ONEVETV4.js +0 -34
- package/dist/chunk-ONEVETV4.js.map +0 -1
- package/dist/chunk-XUDTPZHF.js +0 -16
- package/dist/chunk-XUDTPZHF.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e, c as c$1, f, a as a$d, d as d$
|
|
1
|
+
import { e, c as c$1, f as f$1, a as a$d, d as d$2 } from '../../../chunk-Z3HTIXB2.js';
|
|
2
2
|
import { a as a$b } from '../../../chunk-Q7VIAAF7.js';
|
|
3
3
|
import { i, h as h$2 } from '../../../chunk-BBVOF2BY.js';
|
|
4
4
|
import { a as a$2 } from '../../../chunk-Q2R3X4EB.js';
|
|
@@ -9,9 +9,9 @@ import { a as a$5 } from '../../../chunk-YL4WEBNG.js';
|
|
|
9
9
|
import { a as a$4 } from '../../../chunk-VYBJ5SNV.js';
|
|
10
10
|
import { a as a$6 } from '../../../chunk-C2T2YAFC.js';
|
|
11
11
|
import { a as a$a } from '../../../chunk-4XN57SLB.js';
|
|
12
|
-
import { d as d$
|
|
12
|
+
import { d as d$1, h as h$1, m } from '../../../chunk-2W5FGLTC.js';
|
|
13
13
|
import { h, c as c$2 } from '../../../chunk-OF6623HG.js';
|
|
14
|
-
import {
|
|
14
|
+
import { f } from '../../../chunk-U7DEJBXJ.js';
|
|
15
15
|
import '../../../chunk-33LSXTPO.js';
|
|
16
16
|
import '../../../chunk-4F2NKGF6.js';
|
|
17
17
|
import { a as a$7 } from '../../../chunk-MTJT2RGA.js';
|
|
@@ -21,7 +21,7 @@ import '../../../chunk-5NLFXSCK.js';
|
|
|
21
21
|
import '../../../chunk-6U5LS7MP.js';
|
|
22
22
|
import '../../../chunk-JUAHRU5E.js';
|
|
23
23
|
import '../../../chunk-NIQW2J3M.js';
|
|
24
|
-
import '../../../chunk-
|
|
24
|
+
import '../../../chunk-43EX76EH.js';
|
|
25
25
|
import '../../../chunk-UVPQR2Q2.js';
|
|
26
26
|
import '../../../chunk-RBTYTONM.js';
|
|
27
27
|
import '../../../chunk-I4PPSW36.js';
|
|
@@ -56,7 +56,7 @@ import { ResponsiveContainer, BarChart, XAxis, YAxis, Bar } from 'recharts';
|
|
|
56
56
|
import or from '@mui/material/Badge';
|
|
57
57
|
import Wo from '@mui/material/Radio';
|
|
58
58
|
|
|
59
|
-
var Et=createContext(null),_e=({adapters:t,slots:e,children:o})=>{let a=a$1(),n=useMemo(()=>({adapters:t,slots:e,filters:a}),[t,e,a]);return jsx(Et.Provider,{value:n,children:o})},d=()=>{let t=useContext(Et);if(!t)throw new Error("useCartsContext must be used within a CartsProvider");return t},w=()=>d().filters;var Me=({label:t,value:e})=>jsxs(c,{direction:"row",justifyContent:"space-between",gap:1.5,overflow:"hidden",children:[jsxs(p,{variant:"body2",color:"text.secondary",flexShrink:0,children:[t,":"]}),jsx(p,{component:"div",variant:"body2",fontWeight:500,color:"text.primary",noWrap:!0,children:e})]}),k=memo(Me);var Oe=({cart:t})=>{let{slots:e}=d();return jsxs(c,{gap:3,children:[jsxs(c,{gap:.5,children:[jsx(k,{label:"Criado em",value:t.created_at?d$2(t.created_at,"DD/MM/YYYY [\xE0s] HH:mm"):"-"}),jsx(k,{label:"Usu\xE1rio",value:e.renderDetailUserName(t)}),jsx(k,{label:"Tipo de usu\xE1rio",value:f(t.user?.profile)||"-"}),jsx(k,{label:"\xDAltima atualiza\xE7\xE3o",value:h$1(t.updated_at,"instant")??"-"})]}),jsx(yt,{sx:{borderStyle:"dashed"}}),jsxs(c,{gap:.5,children:[jsx(k,{label:"Cliente",value:jsxs(c,{alignItems:"flex-end",minWidth:0,children:[e.renderDetailPartnerName(t),t.partner?.tax_id&&jsx(p,{variant:"body2",fontSize:13,color:"text.secondary",maxWidth:"100%",noWrap:!0,children:i(t.partner.tax_id)})]})}),jsx(k,{label:"E-mail",value:t.partner?.email||"-"}),jsx(k,{label:"Contato",value:t.partner?.phone?h$2(t.partner.phone):"-"})]}),jsx(yt,{sx:{borderStyle:"dashed"}}),jsxs(c,{gap:.5,children:[jsx(k,{label:"Forma de pagamento",value:t.payment_method?.name||"-"}),jsx(k,{label:"Subtotal",value:t.total!=null?h(t.total):"-"})]})]})},zt=Oe;var $t=styled(c)(({theme:t})=>({position:"sticky",borderBottom:`1px solid ${t.palette.divider}`}));var Be=t=>!t.product_name&&!t.product_sku&&!t.unit_name?jsx(p,{variant:"body2",color:"text.primary",noWrap:!0,children:"-"}):jsxs(c,{justifyContent:"center",height:1,children:[t.product_name&&jsx(p,{variant:"body2",color:"text.primary",noWrap:!0,children:t.product_name}),jsxs(c,{direction:"row",alignItems:"center",gap:1,children:[jsxs(p,{variant:"caption",color:"text.secondary",noWrap:!0,children:["C\xF3d.: ",t.product_sku||"-"]}),jsx(yt,{orientation:"vertical",flexItem:!0,sx:{borderStyle:"dashed"}}),jsxs(p,{variant:"caption",color:"text.secondary",noWrap:!0,children:["Unidade: ",t.unit_name||"-"]})]})]}),Ne=(t,e$1)=>jsx(a$7,{children:jsxs(c,{gap:1,children:[e$1.renderProductImage(t),t.product_name&&jsx(p,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:t.product_name||"-"}),jsxs(c,{children:[jsxs(p,{variant:"body2",color:"text.secondary",noWrap:!0,children:["C\xF3d.: ",t.product_sku||"-"]}),jsxs(p,{variant:"body2",color:"text.secondary",noWrap:!0,children:["Unidade: ",t.unit_name||"-"]}),jsxs(p,{variant:"body2",color:"text.secondary",noWrap:!0,children:["Valor:"," ",jsx(p,{component:"span",variant:"subtitle2",color:"text.primary",noWrap:!0,children:e(t.price)})]}),jsxs(p,{variant:"body2",color:"text.secondary",noWrap:!0,children:["Qtd. de itens:"," ",jsx(p,{component:"span",variant:"subtitle2",color:"text.primary",noWrap:!0,children:t.quantity})]})]}),jsx(c,{children:jsxs(p,{variant:"body2",color:"text.secondary",children:["Subtotal:"," ",jsx(p,{component:"span",variant:"subtitle2",color:"text.primary",children:e(t.total)})]})})]})},t.id),Ve=({cart:t})=>{let{slots:e$1}=d();return jsx(d$1,{title:"Itens",header:jsxs(c,{direction:"row",alignItems:"center",gap:1,children:[jsx(p,{variant:"subtitle2",color:"text.primary",children:"Itens"}),jsx(a$4,{variant:"soft",color:"primary",children:t.items.length||0})]}),headerProps:{p:{xs:3,md:0},pb:{md:1.5}},columns:[{field:"image",headerName:"Imagem",flex:1,sortable:!1,align:"center",headerAlign:"center",renderCell:({row:o})=>jsx(Fragment,{children:e$1.renderProductImage(o)})},{field:"product_name",headerName:"Produtos",flex:3,sortable:!1,renderCell:({row:o})=>Be(o)},{field:"price",headerName:"Valor",flex:1,sortable:!1,renderCell:({row:o})=>e(o.price)},{field:"quantity",headerName:"Qtd. de itens",flex:1,sortable:!1},{field:"total",headerName:"Subtotal",flex:1,sortable:!1,renderCell:({row:o})=>e(o.total)}],rows:t.items,mobileSlots:jsx($t,{}),mobileRender:o=>Ne(o,e$1),hideFooter:!0,disableRowSelectionOnClick:!0,disableColumnFilter:!0,disableColumnMenu:!0,disableColumnSorting:!0,disableColumnResize:!0,disableColumnPinning:!0,containerProps:{height:"100%",sx:{p:{xs:0,md:3}}}})},qt=Ve;var ut=styled(qe)({width:"100%",height:"fit-content",boxShadow:"none"}),Ut=styled(xe)(({theme:t})=>({background:t.palette.success.main,color:t.palette.success.contrastText,"&:hover":{background:t.palette.success.dark}}));var Ue=({cart:t})=>{let{slots:e}=d(),o=t?.partner?.phone?.replace(/\D/g,""),a=useCallback(()=>{let n=e.buildRecoveryMessage(t),m=o?`https://wa.me/${o}?text=${encodeURIComponent(n)}`:`https://wa.me/?text=${encodeURIComponent(n)}`;window.open(m,"_blank","noopener,noreferrer");},[t,o,e]);return jsxs(c,{display:"grid",gridTemplateColumns:{xs:"1fr",md:"2fr 1fr"},gap:3,children:[jsx(c,{position:{md:"relative"},sx:{order:{xs:2,md:1}},overflow:"hidden",children:jsx(c,{position:{md:"absolute"},minHeight:{md:0},sx:{inset:{md:0}},children:jsx(qt,{cart:t})})}),jsxs(c,{gap:3,sx:{order:{xs:1,md:2}},overflow:"hidden",children:[jsxs(ut,{variant:"outlined",children:[jsx(Yt,{title:jsx(p,{variant:"subtitle2",color:"text.primary",children:"Informa\xE7\xF5es"})}),jsx(Ht,{children:jsx(zt,{cart:t})})]}),jsxs(ut,{variant:"outlined",sx:{order:{xs:1,md:2}},children:[jsx(Yt,{title:jsx(p,{variant:"subtitle2",color:"text.primary",children:"Recuperar carrinho abandonado"})}),jsx(Ht,{children:jsxs(c,{gap:3,children:[jsx(p,{variant:"body2",color:"text.secondary",children:"Envie uma mensagem pelo WhatsApp para o cliente com o link deste carrinho abandonado e incentive a finaliza\xE7\xE3o da compra."}),jsxs(c,{gap:1.5,children:[jsx(Ut,{variant:"contained",startIcon:jsx(a$3,{icon:"WHATSAPP"}),size:"small",onClick:a,children:"Enviar carrinho por WhatsApp"}),e.renderRecoveryActions?.(t)]})]})})]})]})]})},He=Ue;var Ye=({status:t})=>{let e=c$1[t];return jsx(a$4,{color:e?.color,sx:{width:"fit-content"},children:e?.label})},it=Ye;styled(Xe)(({theme:t})=>({fontWeight:600,color:t.palette.primary.main,cursor:"pointer","&:hover":{textDecoration:"underline"}}));var Xt=styled(c)(({theme:t})=>({position:"sticky",padding:t.spacing(1.5),background:t.palette.background.neutral}));var Je=(t,e)=>jsx(c,{justifyContent:"center",height:1,children:t?.partner?.name?jsxs(Fragment,{children:[e.renderPartnerName(t),jsx(p,{variant:"body2",fontSize:13,color:"text.secondary",children:t?.partner?.tax_id?i(t?.partner?.tax_id):"-"})]}):"-"}),je=(t,e)=>jsx(c,{justifyContent:"center",height:1,children:t?.user?.name?jsxs(Fragment,{children:[e.renderUserName(t),jsx(p,{variant:"body2",fontSize:13,color:"text.secondary",children:t?.user?.profile==="PARTNER"?"Cliente":"Vendedor"})]}):"-"}),to=t=>jsx(c,{justifyContent:"center",height:1,children:t?.created_at?jsxs(Fragment,{children:[jsx(p,{variant:"body2",color:"text.primary",children:d$2(t?.created_at,"DD/MM/YYYY")}),jsx(p,{variant:"body2",color:"text.secondary",children:d$2(t?.created_at,"[\xE0s] HH:mm")})]}):"-"}),eo=t=>jsx(c,{justifyContent:"center",height:1,children:t?.updated_at?jsx(p,{variant:"body2",color:"text.primary",noWrap:!0,children:h$1(t?.updated_at,"instant")}):"-"}),oo=t=>jsx(c,{justifyContent:"center",height:1,children:jsx(it,{status:t?.status})}),Kt=t=>{let e=()=>{let a=t?.partner?.phone?.replace(/\D/g,"");window.open(`https://wa.me/${a}`,"_blank");},o=()=>{window.location.href=`mailto:${t?.partner?.email}`;};return jsx(a$5,{actions:jsxs(Fragment,{children:[jsx(a$6,{onClick:e,disabled:!t?.partner?.phone,children:"Enviar mensagem por WhatsApp"}),jsx(a$6,{onClick:o,disabled:!t?.partner?.email,children:"Enviar e-mail"})]})},t.id)},ro=(t,e$1)=>jsxs(a$7,{children:[e$1.renderCartLink(t,jsxs(c,{gap:1,children:[jsxs(c,{children:[jsx(p,{variant:"body2",color:"text.secondary",children:"Nome do cliente"}),jsx(p,{variant:"subtitle2",color:"text.primary",children:t?.partner?.name||"-"})]}),jsxs(c,{direction:"row",alignItems:"center",gap:1,children:[jsxs(c,{flex:1,overflow:"hidden",children:[jsx(p,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Usu\xE1rio"}),jsx(p,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:t?.user?.name||"-"})]}),jsx(yt,{orientation:"vertical",flexItem:!0,sx:{borderStyle:"dashed",mx:3}}),jsxs(c,{flex:1,overflow:"hidden",children:[jsx(p,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Tipo de usu\xE1rio"}),jsx(p,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:f(t.user?.profile)||"-"})]})]}),jsxs(c,{direction:"row",alignItems:"center",gap:1,children:[jsxs(c,{flex:1,overflow:"hidden",children:[jsx(p,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Valor"}),jsx(p,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:e(t?.amount_value)})]}),jsx(yt,{orientation:"vertical",flexItem:!0,sx:{borderStyle:"dashed",mx:3}}),jsxs(c,{flex:1,overflow:"hidden",children:[jsx(p,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Qtd. de itens"}),jsx(p,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:t?.item_quantity??0})]})]}),jsxs(c,{direction:"row",alignItems:"center",gap:1,children:[jsxs(c,{flex:1,overflow:"hidden",children:[jsx(p,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Criado em"}),jsx(p,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:t?.created_at?d$2(t?.created_at,"DD/MM/YYYY"):"-"})]}),jsx(yt,{orientation:"vertical",flexItem:!0,sx:{borderStyle:"dashed",mx:3}}),jsxs(c,{flex:1,overflow:"hidden",children:[jsx(p,{variant:"body2",color:"text.secondary",noWrap:!0,children:"\xDAltima atualiza\xE7\xE3o"}),jsx(p,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:h$1(t?.updated_at,"instant")??"-"})]})]}),jsxs(c,{gap:.5,children:[jsx(p,{variant:"body2",color:"text.secondary",children:"Status"}),t?.status?jsx(it,{status:t.status}):jsx(p,{variant:"subtitle2",color:"text.primary",children:"-"})]})]})),jsx(c,{position:"absolute",top:10,right:10,children:Kt(t)})]},t.id),ao=({apiRef:t,carts:e$1,isLoading:o,isFetching:a,isFetchingNextPage:n,onRowsScrollEnd:m})=>{let{slots:s,filters:l}=d(),{sortModel:f,handleSortModelChange:h}=l;return jsx(d$1,{apiRef:t,title:"Lista de carrinhos",header:jsx(p,{variant:"h6",color:"text.primary",children:"Lista de carrinhos"}),columns:[{field:"partner_name",headerName:"Nome do cliente",flex:1,renderCell:({row:i})=>Je(i,s)},{field:"user_name",headerName:"Usu\xE1rio",flex:1,renderCell:({row:i})=>je(i,s)},{field:"amount_value",headerName:"Valor",flex:1,renderCell:({row:i})=>e(i.amount_value)},{field:"item_quantity",headerName:"Qtd. de itens",flex:1,renderCell:({row:i})=>i.item_quantity},{field:"created_at",headerName:"Criado em",flex:1,renderCell:({row:i})=>to(i)},{field:"status",headerName:"Status",flex:1,renderCell:({row:i})=>oo(i)},{field:"updated_at",headerName:"\xDAltima atualiza\xE7\xE3o",flex:1,renderCell:({row:i})=>eo(i)},{field:"actions",type:"actions",headerName:"A\xE7\xF5es",maxWidth:80,getActions:i=>[Kt(i.row)]}],rows:e$1,mobileSlots:jsx(Xt,{children:jsx(p,{variant:"body2",fontWeight:600,color:"text.secondary",children:"Carrinhos"})}),mobileRender:i=>ro(i,s),loading:o,fetching:a&&!n,fetchingNextPage:n,onRowsScrollEnd:m,scrollEndThreshold:600,onRowDoubleClick:({row:i})=>{s.onOpenCart(i);},disableRowSelectionOnClick:!0,disableColumnMenu:!0,sortingMode:"server",sortModel:f,onSortModelChange:h,slots:{noRowsOverlay:()=>jsx(Fragment,{children:s.renderEmptyState()})}})},no=memo(ao);var R=3,Zt=(t,e)=>{let o=t===e.findIndex(n=>n.data[0]>0),a=t===e.map(n=>n.data[0]>0).lastIndexOf(!0);return o&&a?[R,R,R,R]:o?[R,0,0,R]:a?[0,R,R,0]:[0,0,0,0]};var io=["#22C55E","#FF5630"],so="#E5E7EB",lo=({series:t,isZero:e})=>e?jsx(Bar,{dataKey:"empty",stackId:"stack",fill:so,stroke:"none",radius:3,isAnimationActive:!1,"data-testid":"bar-empty"}):jsx(Fragment,{children:t.map((o,a)=>jsx(Bar,{dataKey:o.name,stackId:"stack",fill:io[a],stroke:"none",radius:Zt(a,t),isAnimationActive:!1,"data-testid":`bar-${a}`},a))}),jt=lo;var te=styled(qe)(({theme:t})=>({width:"100%",height:"auto",border:`1px solid ${t.palette.divider}`,boxShadow:"none",overflow:"visible"}));var xo=({title:t,subtitle:e,legend:o,series:a,isFetching:n})=>{let m=useMemo(()=>a.every(l=>l.data.every(f=>f===0)),[a]),s=useMemo(()=>{if(m)return [{empty:100}];let l=a.reduce((h,b)=>h+(b.data[0]??0),0),f={};return a.forEach(h=>{f[h.name]=l>0?h.data[0]/l*100:0;}),[f]},[a,m]);return jsxs(te,{variant:"outlined",children:[jsx(Yt,{title:t}),jsx(Ht,{children:jsxs(c,{gap:2,children:[jsxs(c,{gap:1,children:[e,jsx(a$2,{active:n,children:jsx(ResponsiveContainer,{width:"100%",height:24,style:{pointerEvents:"none"},children:jsxs(BarChart,{data:s,layout:"vertical",stackOffset:"none",margin:{top:0,right:0,bottom:0,left:0},barCategoryGap:0,children:[jsx(XAxis,{type:"number",hide:!0,domain:[0,100]}),jsx(YAxis,{type:"category",hide:!0}),jsx(jt,{series:a,isZero:m})]})})})]}),o]})})]})},lt=memo(xo);var P=t=>c$2(t,{maximumFractionDigits:2,...t>0&&t<100?{minimumFractionDigits:2}:{}});var vo=({active:t,abandoned:e,isFetching:o})=>{let[a,n]=useState(!0),[m,s]=useState(!0),l=a?t?.amount_value??0:0,f=m?e?.amount_value??0:0,h$1=l+f,b=[{name:"Ativos",data:[l]},{name:"Abandonados",data:[f]}];return jsx(lt,{title:"Valor em carrinhos",subtitle:jsx(p,{variant:"subtitle2",fontSize:20,fontWeight:700,children:h(h$1)}),legend:jsxs(c,{children:[jsxs(c,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,sx:{mt:-1},children:[jsx(ne,{label:"Ativos",control:jsx(ae,{name:"active",size:"small",checked:a,onChange:(i,T)=>n(T),sx:{"&.Mui-checked":{color:"#22C55E"}}})}),jsxs(p,{variant:"body2",color:"text.secondary",noWrap:!0,title:`${P(t?.amount_percentage??0)} | ${h(t?.amount_value??0)}`,children:[P(t?.amount_percentage??0),"\u2002",jsx(p,{component:"span",variant:"body2",color:"text.primary",children:h(t?.amount_value??0)})]})]}),jsxs(c,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,sx:{mt:-1},children:[jsx(ne,{label:"Abandonados",control:jsx(ae,{name:"abandoned",size:"small",checked:m,onChange:(i,T)=>s(T),sx:{"&.Mui-checked":{color:"#FF5630"}}})}),jsxs(p,{variant:"body2",color:"text.secondary",noWrap:!0,title:`${P(e?.amount_percentage??0)} | ${h(e?.amount_value??0)}`,children:[P(e?.amount_percentage??0),"\u2002",jsx(p,{component:"span",variant:"body2",color:"text.primary",children:h(e?.amount_value??0)})]})]})]}),series:b,isFetching:o})},ie=memo(vo);var Po=({active:t,abandoned:e,isFetching:o})=>{let[a,n]=useState(!0),[m,s]=useState(!0),l=a?t?.quantity_value??0:0,f=m?e?.quantity_value??0:0,h=l+f,b=[{name:"Ativos",data:[l]},{name:"Abandonados",data:[f]}];return jsx(lt,{title:"Quantidade de carrinhos",subtitle:jsxs(p,{variant:"subtitle2",fontSize:20,fontWeight:700,children:[h," ",jsxs(p,{component:"span",variant:"body2",fontSize:13,color:"text.secondary",children:["carrinho",h!==1&&"s"]})]}),legend:jsxs(c,{children:[jsxs(c,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,sx:{mt:-1},children:[jsx(ne,{label:"Ativos",control:jsx(ae,{name:"active",size:"small",checked:a,onChange:(i,T)=>n(T),sx:{"&.Mui-checked":{color:"#22C55E"}}})}),jsxs(p,{variant:"body2",color:"text.secondary",noWrap:!0,title:`${P(t?.quantity_percentage??0)} ${t?.quantity_value??0} | carrinho${t?.quantity_value!==1?"s":""}`,children:[P(t?.quantity_percentage??0),"\u2002",jsxs(p,{component:"span",variant:"body2",color:"text.primary",children:[t?.quantity_value??0," carrinho",t?.quantity_value!==1?"s":""]})]})]}),jsxs(c,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,sx:{mt:-1},children:[jsx(ne,{label:"Abandonados",control:jsx(ae,{name:"abandoned",size:"small",checked:m,onChange:(i,T)=>s(T),sx:{"&.Mui-checked":{color:"#FF5630"}}})}),jsxs(p,{variant:"body2",color:"text.secondary",noWrap:!0,title:`${P(e?.quantity_percentage??0)} ${e?.quantity_value} | carrinho${e?.quantity_value!==1?"s":""}`,children:[P(e?.quantity_percentage??0),"\u2002",jsxs(p,{component:"span",variant:"body2",color:"text.primary",children:[e?.quantity_value," carrinho",e?.quantity_value!==1?"s":""]})]})]})]}),series:b,isFetching:o})},me=memo(Po);var _o=({summary:t,isFetching:e})=>jsxs(c,{direction:{xs:"column",md:"row"},justifyContent:"space-between",gap:3,children:[jsx(me,{active:t?.active,abandoned:t?.abandoned,isFetching:e}),jsx(ie,{active:t?.active,abandoned:t?.abandoned,isFetching:e})]}),Io=memo(_o);var Ro=()=>{let{adapters:t}=d(),{selectedPartners:e,setSelectedPartners:o}=w();return jsx(a$b,{name:"partners",title:"Clientes",placeholder:"Digite para buscar um cliente...",emptyText:"Nenhum cliente selecionado",testIdPrefix:"filter-partner",defaultExpanded:!0,selected:e,onChange:o,useOptions:t.usePartnerOptions})},ce=Ro;var Oo=({profile:t,checked:e,onToggle:o})=>{let{label:a}=d$3[t];return jsx(ne,{control:jsx(Wo,{name:`profile-${t}`,checked:e,onClick:o}),label:a})},fe=Oo;var Bo=()=>{let{slots:t}=d(),{selectedProfile:e,setSelectedProfile:o}=w(),{profileOptions:a}=t,[n,m]=a$9(!!e),s=useCallback(l=>{o(e===l?null:l);},[o,e]);return jsxs(a$c,{expanded:n,onChange:m,children:[jsx(b$1,{children:jsx(p,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Perfis"})}),jsx(c$3,{children:jsx(c,{mt:-1,children:a.map(l=>jsx(fe,{profile:l,checked:e===l,onToggle:()=>s(l)},l))})})]})},ye=Bo;var Vo=({useOptions:t})=>{let{selectedSellers:e,setSelectedSellers:o}=w();return jsx(a$b,{name:"sellers",title:"Vendedores",placeholder:"Digite para buscar um vendedor...",emptyText:"Nenhum vendedor selecionado",testIdPrefix:"filter-seller",defaultExpanded:!!e.length,selected:e,onChange:o,useOptions:t})},he=Vo;var Go=({status:t,checked:e,onToggle:o})=>{let{label:a,color:n}=c$1[t];return jsx(ne,{control:jsx(ae,{name:`status-${t}`,checked:e,onChange:o}),label:jsx(a$4,{color:n,sx:{cursor:"pointer"},children:a})})},Ce=Go;var Xo=()=>{let{selectedStatuses:t,setSelectedStatuses:e}=w(),[o,a]=a$9(!!t.length),n=useMemo(()=>Object.values(a$d).filter(s=>s!=="EXPIRED"),[]),m=useCallback(s=>{e(t.includes(s)?t.filter(l=>l!==s):[...t,s]);},[e,t]);return jsxs(a$c,{expanded:o,onChange:a,children:[jsx(b$1,{children:jsx(p,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Status"})}),jsx(c$3,{children:jsx(c,{mt:-1,children:n.map(s=>jsx(Ce,{status:s,checked:t.includes(s),onToggle:()=>m(s)},s))})})]})},ge=Xo;var Zo=()=>{let{adapters:t}=d(),{useSellerOptions:e}=t;return jsxs(Fragment,{children:[jsx(ce,{}),!!e&&jsx(he,{useOptions:e}),jsx(ge,{}),jsx(ye,{})]})},be=Zo;var St=styled(xe)(({theme:t})=>({background:t.palette.common.white})),vt=styled(xe)(({theme:t})=>({color:t.palette.text.secondary,"&:hover":{background:t.palette.action.hover},[t.breakpoints.down("sm")]:{border:`1px solid ${t.palette.divider}`,textIndent:"-9999em",fontSize:0,minWidth:30,maxWidth:30,height:30,width:30,overflow:"hidden","& .MuiButton-icon":{margin:0}}})),kt=styled(a)(({theme:t})=>({"& .MuiPopover-paper":{width:540,padding:t.spacing(3),backgroundColor:t.palette.background.paper,borderRadius:t.spacing(1),backgroundImage:"none",[t.breakpoints.down("sm")]:{width:"calc(100% - 48px)"}}}));var rr=()=>{let t=b("down","sm"),{slots:e,adapters:o,filters:a}=d(),{dateFilter:n,handleDateFilterChange:m$1,selectedPartners:s,selectedSellers:l,selectedStatuses:f}=a,h=useMemo(()=>{let dt=o.useSellerOptions?l.length:0;return s.length+dt+f.length},[o.useSellerOptions,s.length,l.length,f.length]),b$1=a$8(),i=a$8(),[T,Pt]=a$9(),ve=useCallback(dt=>{m$1(dt),b$1.onClose();},[m$1,b$1]),ke=n.period!=="OTHER"?e$1[n.period]:m(n.start_date,n.end_date);return jsxs(Fragment,{children:[jsxs(c,{direction:{xs:"column",sm:"row"},alignItems:{xs:"flex-start",sm:"center"},justifyContent:"space-between",gap:1.5,children:[jsxs(c,{width:"100%",direction:"row",alignItems:"center",gap:1.5,children:[jsx(St,{variant:"outlined",endIcon:jsx(a$3,{icon:"ARROW_DOWN_SIMPLE"}),color:"inherit",size:"small",fullWidth:t,onClick:b$1.onOpen,children:t?"Per\xEDodo":ke}),jsx(or,{badgeContent:h,invisible:h===0,color:"primary",children:jsx(St,{variant:"outlined",startIcon:jsx(a$3,{icon:"FILTER_LIST"}),color:"inherit",size:"small",fullWidth:t,onClick:Pt,children:"Filtrar"})}),t&&jsx(vt,{variant:"text",startIcon:jsx(a$3,{icon:"DOWNLOAD_EXPORT_04"}),size:"small",onClick:i.onOpen,sx:{display:"none"},children:"Exportar"})]}),!t&&jsx(vt,{variant:"text",startIcon:jsx(a$3,{icon:"DOWNLOAD_EXPORT_04"}),size:"small",color:"inherit",onClick:i.onOpen,sx:{display:"none"},children:"Exportar"})]}),jsx(kt,{open:b$1.open,onClose:b$1.onClose,arrow:t?"top-center":"top-left",TransitionProps:{timeout:0},disabledArrow:!0,children:e.renderDateFilter({value:n,onSave:ve,onClose:b$1.onClose})}),jsxs(kt,{open:i.open,onClose:i.onClose,arrow:"top-right",disabledArrow:!0,children:[jsx(a$6,{children:"Exportar XLSX"}),jsx(a$6,{children:"Exportar CSV"}),jsx(a$6,{children:"Exportar PDF"})]}),jsx(a$a,{open:T,onClose:Pt,headerTitle:"Filtros",headerProps:{direction:"row-reverse"},contentProps:{p:0},maxWidth:400,children:jsx(be,{})})]})},ar=rr;
|
|
59
|
+
var Et=createContext(null),_e=({adapters:t,slots:e,children:o})=>{let a=a$1(),n=useMemo(()=>({adapters:t,slots:e,filters:a}),[t,e,a]);return jsx(Et.Provider,{value:n,children:o})},d=()=>{let t=useContext(Et);if(!t)throw new Error("useCartsContext must be used within a CartsProvider");return t},w=()=>d().filters;var Me=({label:t,value:e})=>jsxs(c,{direction:"row",justifyContent:"space-between",gap:1.5,overflow:"hidden",children:[jsxs(p,{variant:"body2",color:"text.secondary",flexShrink:0,children:[t,":"]}),jsx(p,{component:"div",variant:"body2",fontWeight:500,color:"text.primary",noWrap:!0,children:e})]}),k=memo(Me);var Oe=({cart:t})=>{let{slots:e}=d();return jsxs(c,{gap:3,children:[jsxs(c,{gap:.5,children:[jsx(k,{label:"Criado em",value:t.created_at?d$1(t.created_at,"DD/MM/YYYY [\xE0s] HH:mm"):"-"}),jsx(k,{label:"Usu\xE1rio",value:e.renderDetailUserName(t)}),jsx(k,{label:"Tipo de usu\xE1rio",value:f$1(t.user?.profile)||"-"}),jsx(k,{label:"\xDAltima atualiza\xE7\xE3o",value:h$1(t.updated_at,"instant")??"-"})]}),jsx(yt,{sx:{borderStyle:"dashed"}}),jsxs(c,{gap:.5,children:[jsx(k,{label:"Cliente",value:jsxs(c,{alignItems:"flex-end",minWidth:0,children:[e.renderDetailPartnerName(t),t.partner?.tax_id&&jsx(p,{variant:"body2",fontSize:13,color:"text.secondary",maxWidth:"100%",noWrap:!0,children:i(t.partner.tax_id)})]})}),jsx(k,{label:"E-mail",value:t.partner?.email||"-"}),jsx(k,{label:"Contato",value:t.partner?.phone?h$2(t.partner.phone):"-"})]}),jsx(yt,{sx:{borderStyle:"dashed"}}),jsxs(c,{gap:.5,children:[jsx(k,{label:"Forma de pagamento",value:t.payment_method?.name||"-"}),jsx(k,{label:"Subtotal",value:t.total!=null?h(t.total):"-"})]})]})},zt=Oe;var $t=styled(c)(({theme:t})=>({position:"sticky",borderBottom:`1px solid ${t.palette.divider}`}));var Be=t=>!t.product_name&&!t.product_sku&&!t.unit_name?jsx(p,{variant:"body2",color:"text.primary",noWrap:!0,children:"-"}):jsxs(c,{justifyContent:"center",height:1,children:[t.product_name&&jsx(p,{variant:"body2",color:"text.primary",noWrap:!0,children:t.product_name}),jsxs(c,{direction:"row",alignItems:"center",gap:1,children:[jsxs(p,{variant:"caption",color:"text.secondary",noWrap:!0,children:["C\xF3d.: ",t.product_sku||"-"]}),jsx(yt,{orientation:"vertical",flexItem:!0,sx:{borderStyle:"dashed"}}),jsxs(p,{variant:"caption",color:"text.secondary",noWrap:!0,children:["Unidade: ",t.unit_name||"-"]})]})]}),Ne=(t,e$1)=>jsx(a$7,{children:jsxs(c,{gap:1,children:[e$1.renderProductImage(t),t.product_name&&jsx(p,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:t.product_name||"-"}),jsxs(c,{children:[jsxs(p,{variant:"body2",color:"text.secondary",noWrap:!0,children:["C\xF3d.: ",t.product_sku||"-"]}),jsxs(p,{variant:"body2",color:"text.secondary",noWrap:!0,children:["Unidade: ",t.unit_name||"-"]}),jsxs(p,{variant:"body2",color:"text.secondary",noWrap:!0,children:["Valor:"," ",jsx(p,{component:"span",variant:"subtitle2",color:"text.primary",noWrap:!0,children:e(t.price)})]}),jsxs(p,{variant:"body2",color:"text.secondary",noWrap:!0,children:["Qtd. de itens:"," ",jsx(p,{component:"span",variant:"subtitle2",color:"text.primary",noWrap:!0,children:t.quantity})]})]}),jsx(c,{children:jsxs(p,{variant:"body2",color:"text.secondary",children:["Subtotal:"," ",jsx(p,{component:"span",variant:"subtitle2",color:"text.primary",children:e(t.total)})]})})]})},t.id),Ve=({cart:t})=>{let{slots:e$1}=d();return jsx(f,{title:"Itens",header:jsxs(c,{direction:"row",alignItems:"center",gap:1,children:[jsx(p,{variant:"subtitle2",color:"text.primary",children:"Itens"}),jsx(a$4,{variant:"soft",color:"primary",children:t.items.length||0})]}),headerProps:{p:{xs:3,md:0},pb:{md:1.5}},columns:[{field:"image",headerName:"Imagem",flex:1,sortable:!1,align:"center",headerAlign:"center",renderCell:({row:o})=>jsx(Fragment,{children:e$1.renderProductImage(o)})},{field:"product_name",headerName:"Produtos",flex:3,sortable:!1,renderCell:({row:o})=>Be(o)},{field:"price",headerName:"Valor",flex:1,sortable:!1,renderCell:({row:o})=>e(o.price)},{field:"quantity",headerName:"Qtd. de itens",flex:1,sortable:!1},{field:"total",headerName:"Subtotal",flex:1,sortable:!1,renderCell:({row:o})=>e(o.total)}],rows:t.items,mobileSlots:jsx($t,{}),mobileRender:o=>Ne(o,e$1),hideFooter:!0,disableRowSelectionOnClick:!0,disableColumnFilter:!0,disableColumnMenu:!0,disableColumnSorting:!0,disableColumnResize:!0,disableColumnPinning:!0,containerProps:{height:"100%",sx:{p:{xs:0,md:3}}}})},qt=Ve;var ut=styled(qe)({width:"100%",height:"fit-content",boxShadow:"none"}),Ut=styled(xe)(({theme:t})=>({background:t.palette.success.main,color:t.palette.success.contrastText,"&:hover":{background:t.palette.success.dark}}));var Ue=({cart:t})=>{let{slots:e}=d(),o=t?.partner?.phone?.replace(/\D/g,""),a=useCallback(()=>{let n=e.buildRecoveryMessage(t),m=o?`https://wa.me/${o}?text=${encodeURIComponent(n)}`:`https://wa.me/?text=${encodeURIComponent(n)}`;window.open(m,"_blank","noopener,noreferrer");},[t,o,e]);return jsxs(c,{display:"grid",gridTemplateColumns:{xs:"1fr",md:"2fr 1fr"},gap:3,children:[jsx(c,{position:{md:"relative"},sx:{order:{xs:2,md:1}},overflow:"hidden",children:jsx(c,{position:{md:"absolute"},minHeight:{md:0},sx:{inset:{md:0}},children:jsx(qt,{cart:t})})}),jsxs(c,{gap:3,sx:{order:{xs:1,md:2}},overflow:"hidden",children:[jsxs(ut,{variant:"outlined",children:[jsx(Yt,{title:jsx(p,{variant:"subtitle2",color:"text.primary",children:"Informa\xE7\xF5es"})}),jsx(Ht,{children:jsx(zt,{cart:t})})]}),jsxs(ut,{variant:"outlined",sx:{order:{xs:1,md:2}},children:[jsx(Yt,{title:jsx(p,{variant:"subtitle2",color:"text.primary",children:"Recuperar carrinho abandonado"})}),jsx(Ht,{children:jsxs(c,{gap:3,children:[jsx(p,{variant:"body2",color:"text.secondary",children:"Envie uma mensagem pelo WhatsApp para o cliente com o link deste carrinho abandonado e incentive a finaliza\xE7\xE3o da compra."}),jsxs(c,{gap:1.5,children:[jsx(Ut,{variant:"contained",startIcon:jsx(a$3,{icon:"WHATSAPP"}),size:"small",onClick:a,children:"Enviar carrinho por WhatsApp"}),e.renderRecoveryActions?.(t)]})]})})]})]})]})},He=Ue;var Ye=({status:t})=>{let e=c$1[t];return jsx(a$4,{color:e?.color,sx:{width:"fit-content"},children:e?.label})},it=Ye;styled(Xe)(({theme:t})=>({fontWeight:600,color:t.palette.primary.main,cursor:"pointer","&:hover":{textDecoration:"underline"}}));var Xt=styled(c)(({theme:t})=>({position:"sticky",padding:t.spacing(1.5),background:t.palette.background.neutral}));var Je=(t,e)=>jsx(c,{justifyContent:"center",height:1,children:t?.partner?.name?jsxs(Fragment,{children:[e.renderPartnerName(t),jsx(p,{variant:"body2",fontSize:13,color:"text.secondary",children:t?.partner?.tax_id?i(t?.partner?.tax_id):"-"})]}):"-"}),je=(t,e)=>jsx(c,{justifyContent:"center",height:1,children:t?.user?.name?jsxs(Fragment,{children:[e.renderUserName(t),jsx(p,{variant:"body2",fontSize:13,color:"text.secondary",children:t?.user?.profile==="PARTNER"?"Cliente":"Vendedor"})]}):"-"}),to=t=>jsx(c,{justifyContent:"center",height:1,children:t?.created_at?jsxs(Fragment,{children:[jsx(p,{variant:"body2",color:"text.primary",children:d$1(t?.created_at,"DD/MM/YYYY")}),jsx(p,{variant:"body2",color:"text.secondary",children:d$1(t?.created_at,"[\xE0s] HH:mm")})]}):"-"}),eo=t=>jsx(c,{justifyContent:"center",height:1,children:t?.updated_at?jsx(p,{variant:"body2",color:"text.primary",noWrap:!0,children:h$1(t?.updated_at,"instant")}):"-"}),oo=t=>jsx(c,{justifyContent:"center",height:1,children:jsx(it,{status:t?.status})}),Kt=t=>{let e=()=>{let a=t?.partner?.phone?.replace(/\D/g,"");window.open(`https://wa.me/${a}`,"_blank");},o=()=>{window.location.href=`mailto:${t?.partner?.email}`;};return jsx(a$5,{actions:jsxs(Fragment,{children:[jsx(a$6,{onClick:e,disabled:!t?.partner?.phone,children:"Enviar mensagem por WhatsApp"}),jsx(a$6,{onClick:o,disabled:!t?.partner?.email,children:"Enviar e-mail"})]})},t.id)},ro=(t,e$1)=>jsxs(a$7,{children:[e$1.renderCartLink(t,jsxs(c,{gap:1,children:[jsxs(c,{children:[jsx(p,{variant:"body2",color:"text.secondary",children:"Nome do cliente"}),jsx(p,{variant:"subtitle2",color:"text.primary",children:t?.partner?.name||"-"})]}),jsxs(c,{direction:"row",alignItems:"center",gap:1,children:[jsxs(c,{flex:1,overflow:"hidden",children:[jsx(p,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Usu\xE1rio"}),jsx(p,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:t?.user?.name||"-"})]}),jsx(yt,{orientation:"vertical",flexItem:!0,sx:{borderStyle:"dashed",mx:3}}),jsxs(c,{flex:1,overflow:"hidden",children:[jsx(p,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Tipo de usu\xE1rio"}),jsx(p,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:f$1(t.user?.profile)||"-"})]})]}),jsxs(c,{direction:"row",alignItems:"center",gap:1,children:[jsxs(c,{flex:1,overflow:"hidden",children:[jsx(p,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Valor"}),jsx(p,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:e(t?.amount_value)})]}),jsx(yt,{orientation:"vertical",flexItem:!0,sx:{borderStyle:"dashed",mx:3}}),jsxs(c,{flex:1,overflow:"hidden",children:[jsx(p,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Qtd. de itens"}),jsx(p,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:t?.item_quantity??0})]})]}),jsxs(c,{direction:"row",alignItems:"center",gap:1,children:[jsxs(c,{flex:1,overflow:"hidden",children:[jsx(p,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Criado em"}),jsx(p,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:t?.created_at?d$1(t?.created_at,"DD/MM/YYYY"):"-"})]}),jsx(yt,{orientation:"vertical",flexItem:!0,sx:{borderStyle:"dashed",mx:3}}),jsxs(c,{flex:1,overflow:"hidden",children:[jsx(p,{variant:"body2",color:"text.secondary",noWrap:!0,children:"\xDAltima atualiza\xE7\xE3o"}),jsx(p,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:h$1(t?.updated_at,"instant")??"-"})]})]}),jsxs(c,{gap:.5,children:[jsx(p,{variant:"body2",color:"text.secondary",children:"Status"}),t?.status?jsx(it,{status:t.status}):jsx(p,{variant:"subtitle2",color:"text.primary",children:"-"})]})]})),jsx(c,{position:"absolute",top:10,right:10,children:Kt(t)})]},t.id),ao=({apiRef:t,carts:e$1,isLoading:o,isFetching:a,isFetchingNextPage:n,onRowsScrollEnd:m})=>{let{slots:s,filters:l}=d(),{sortModel:f$1,handleSortModelChange:h}=l;return jsx(f,{apiRef:t,title:"Lista de carrinhos",header:jsx(p,{variant:"h6",color:"text.primary",children:"Lista de carrinhos"}),columns:[{field:"partner_name",headerName:"Nome do cliente",flex:1,renderCell:({row:i})=>Je(i,s)},{field:"user_name",headerName:"Usu\xE1rio",flex:1,renderCell:({row:i})=>je(i,s)},{field:"amount_value",headerName:"Valor",flex:1,renderCell:({row:i})=>e(i.amount_value)},{field:"item_quantity",headerName:"Qtd. de itens",flex:1,renderCell:({row:i})=>i.item_quantity},{field:"created_at",headerName:"Criado em",flex:1,renderCell:({row:i})=>to(i)},{field:"status",headerName:"Status",flex:1,renderCell:({row:i})=>oo(i)},{field:"updated_at",headerName:"\xDAltima atualiza\xE7\xE3o",flex:1,renderCell:({row:i})=>eo(i)},{field:"actions",type:"actions",headerName:"A\xE7\xF5es",maxWidth:80,getActions:i=>[Kt(i.row)]}],rows:e$1,mobileSlots:jsx(Xt,{children:jsx(p,{variant:"body2",fontWeight:600,color:"text.secondary",children:"Carrinhos"})}),mobileRender:i=>ro(i,s),loading:o,fetching:a&&!n,fetchingNextPage:n,onRowsScrollEnd:m,scrollEndThreshold:600,onRowDoubleClick:({row:i})=>{s.onOpenCart(i);},disableRowSelectionOnClick:!0,disableColumnMenu:!0,sortingMode:"server",sortModel:f$1,onSortModelChange:h,slots:{noRowsOverlay:()=>jsx(Fragment,{children:s.renderEmptyState()})}})},no=memo(ao);var R=3,Zt=(t,e)=>{let o=t===e.findIndex(n=>n.data[0]>0),a=t===e.map(n=>n.data[0]>0).lastIndexOf(!0);return o&&a?[R,R,R,R]:o?[R,0,0,R]:a?[0,R,R,0]:[0,0,0,0]};var io=["#22C55E","#FF5630"],so="#E5E7EB",lo=({series:t,isZero:e})=>e?jsx(Bar,{dataKey:"empty",stackId:"stack",fill:so,stroke:"none",radius:3,isAnimationActive:!1,"data-testid":"bar-empty"}):jsx(Fragment,{children:t.map((o,a)=>jsx(Bar,{dataKey:o.name,stackId:"stack",fill:io[a],stroke:"none",radius:Zt(a,t),isAnimationActive:!1,"data-testid":`bar-${a}`},a))}),jt=lo;var te=styled(qe)(({theme:t})=>({width:"100%",height:"auto",border:`1px solid ${t.palette.divider}`,boxShadow:"none",overflow:"visible"}));var xo=({title:t,subtitle:e,legend:o,series:a,isFetching:n})=>{let m=useMemo(()=>a.every(l=>l.data.every(f=>f===0)),[a]),s=useMemo(()=>{if(m)return [{empty:100}];let l=a.reduce((h,b)=>h+(b.data[0]??0),0),f={};return a.forEach(h=>{f[h.name]=l>0?h.data[0]/l*100:0;}),[f]},[a,m]);return jsxs(te,{variant:"outlined",children:[jsx(Yt,{title:t}),jsx(Ht,{children:jsxs(c,{gap:2,children:[jsxs(c,{gap:1,children:[e,jsx(a$2,{active:n,children:jsx(ResponsiveContainer,{width:"100%",height:24,style:{pointerEvents:"none"},children:jsxs(BarChart,{data:s,layout:"vertical",stackOffset:"none",margin:{top:0,right:0,bottom:0,left:0},barCategoryGap:0,children:[jsx(XAxis,{type:"number",hide:!0,domain:[0,100]}),jsx(YAxis,{type:"category",hide:!0}),jsx(jt,{series:a,isZero:m})]})})})]}),o]})})]})},lt=memo(xo);var P=t=>c$2(t,{maximumFractionDigits:2,...t>0&&t<100?{minimumFractionDigits:2}:{}});var vo=({active:t,abandoned:e,isFetching:o})=>{let[a,n]=useState(!0),[m,s]=useState(!0),l=a?t?.amount_value??0:0,f=m?e?.amount_value??0:0,h$1=l+f,b=[{name:"Ativos",data:[l]},{name:"Abandonados",data:[f]}];return jsx(lt,{title:"Valor em carrinhos",subtitle:jsx(p,{variant:"subtitle2",fontSize:20,fontWeight:700,children:h(h$1)}),legend:jsxs(c,{children:[jsxs(c,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,sx:{mt:-1},children:[jsx(ne,{label:"Ativos",control:jsx(ae,{name:"active",size:"small",checked:a,onChange:(i,T)=>n(T),sx:{"&.Mui-checked":{color:"#22C55E"}}})}),jsxs(p,{variant:"body2",color:"text.secondary",noWrap:!0,title:`${P(t?.amount_percentage??0)} | ${h(t?.amount_value??0)}`,children:[P(t?.amount_percentage??0),"\u2002",jsx(p,{component:"span",variant:"body2",color:"text.primary",children:h(t?.amount_value??0)})]})]}),jsxs(c,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,sx:{mt:-1},children:[jsx(ne,{label:"Abandonados",control:jsx(ae,{name:"abandoned",size:"small",checked:m,onChange:(i,T)=>s(T),sx:{"&.Mui-checked":{color:"#FF5630"}}})}),jsxs(p,{variant:"body2",color:"text.secondary",noWrap:!0,title:`${P(e?.amount_percentage??0)} | ${h(e?.amount_value??0)}`,children:[P(e?.amount_percentage??0),"\u2002",jsx(p,{component:"span",variant:"body2",color:"text.primary",children:h(e?.amount_value??0)})]})]})]}),series:b,isFetching:o})},ie=memo(vo);var Po=({active:t,abandoned:e,isFetching:o})=>{let[a,n]=useState(!0),[m,s]=useState(!0),l=a?t?.quantity_value??0:0,f=m?e?.quantity_value??0:0,h=l+f,b=[{name:"Ativos",data:[l]},{name:"Abandonados",data:[f]}];return jsx(lt,{title:"Quantidade de carrinhos",subtitle:jsxs(p,{variant:"subtitle2",fontSize:20,fontWeight:700,children:[h," ",jsxs(p,{component:"span",variant:"body2",fontSize:13,color:"text.secondary",children:["carrinho",h!==1&&"s"]})]}),legend:jsxs(c,{children:[jsxs(c,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,sx:{mt:-1},children:[jsx(ne,{label:"Ativos",control:jsx(ae,{name:"active",size:"small",checked:a,onChange:(i,T)=>n(T),sx:{"&.Mui-checked":{color:"#22C55E"}}})}),jsxs(p,{variant:"body2",color:"text.secondary",noWrap:!0,title:`${P(t?.quantity_percentage??0)} ${t?.quantity_value??0} | carrinho${t?.quantity_value!==1?"s":""}`,children:[P(t?.quantity_percentage??0),"\u2002",jsxs(p,{component:"span",variant:"body2",color:"text.primary",children:[t?.quantity_value??0," carrinho",t?.quantity_value!==1?"s":""]})]})]}),jsxs(c,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,sx:{mt:-1},children:[jsx(ne,{label:"Abandonados",control:jsx(ae,{name:"abandoned",size:"small",checked:m,onChange:(i,T)=>s(T),sx:{"&.Mui-checked":{color:"#FF5630"}}})}),jsxs(p,{variant:"body2",color:"text.secondary",noWrap:!0,title:`${P(e?.quantity_percentage??0)} ${e?.quantity_value} | carrinho${e?.quantity_value!==1?"s":""}`,children:[P(e?.quantity_percentage??0),"\u2002",jsxs(p,{component:"span",variant:"body2",color:"text.primary",children:[e?.quantity_value," carrinho",e?.quantity_value!==1?"s":""]})]})]})]}),series:b,isFetching:o})},me=memo(Po);var _o=({summary:t,isFetching:e})=>jsxs(c,{direction:{xs:"column",md:"row"},justifyContent:"space-between",gap:3,children:[jsx(me,{active:t?.active,abandoned:t?.abandoned,isFetching:e}),jsx(ie,{active:t?.active,abandoned:t?.abandoned,isFetching:e})]}),Io=memo(_o);var Ro=()=>{let{adapters:t}=d(),{selectedPartners:e,setSelectedPartners:o}=w();return jsx(a$b,{name:"partners",title:"Clientes",placeholder:"Digite para buscar um cliente...",emptyText:"Nenhum cliente selecionado",testIdPrefix:"filter-partner",defaultExpanded:!0,selected:e,onChange:o,useOptions:t.usePartnerOptions})},ce=Ro;var Oo=({profile:t,checked:e,onToggle:o})=>{let{label:a}=d$2[t];return jsx(ne,{control:jsx(Wo,{name:`profile-${t}`,checked:e,onClick:o}),label:a})},fe=Oo;var Bo=()=>{let{slots:t}=d(),{selectedProfile:e,setSelectedProfile:o}=w(),{profileOptions:a}=t,[n,m]=a$9(!!e),s=useCallback(l=>{o(e===l?null:l);},[o,e]);return jsxs(a$c,{expanded:n,onChange:m,children:[jsx(b$1,{children:jsx(p,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Perfis"})}),jsx(c$3,{children:jsx(c,{mt:-1,children:a.map(l=>jsx(fe,{profile:l,checked:e===l,onToggle:()=>s(l)},l))})})]})},ye=Bo;var Vo=({useOptions:t})=>{let{selectedSellers:e,setSelectedSellers:o}=w();return jsx(a$b,{name:"sellers",title:"Vendedores",placeholder:"Digite para buscar um vendedor...",emptyText:"Nenhum vendedor selecionado",testIdPrefix:"filter-seller",defaultExpanded:!!e.length,selected:e,onChange:o,useOptions:t})},he=Vo;var Go=({status:t,checked:e,onToggle:o})=>{let{label:a,color:n}=c$1[t];return jsx(ne,{control:jsx(ae,{name:`status-${t}`,checked:e,onChange:o}),label:jsx(a$4,{color:n,sx:{cursor:"pointer"},children:a})})},Ce=Go;var Xo=()=>{let{selectedStatuses:t,setSelectedStatuses:e}=w(),[o,a]=a$9(!!t.length),n=useMemo(()=>Object.values(a$d).filter(s=>s!=="EXPIRED"),[]),m=useCallback(s=>{e(t.includes(s)?t.filter(l=>l!==s):[...t,s]);},[e,t]);return jsxs(a$c,{expanded:o,onChange:a,children:[jsx(b$1,{children:jsx(p,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Status"})}),jsx(c$3,{children:jsx(c,{mt:-1,children:n.map(s=>jsx(Ce,{status:s,checked:t.includes(s),onToggle:()=>m(s)},s))})})]})},ge=Xo;var Zo=()=>{let{adapters:t}=d(),{useSellerOptions:e}=t;return jsxs(Fragment,{children:[jsx(ce,{}),!!e&&jsx(he,{useOptions:e}),jsx(ge,{}),jsx(ye,{})]})},be=Zo;var St=styled(xe)(({theme:t})=>({background:t.palette.common.white})),vt=styled(xe)(({theme:t})=>({color:t.palette.text.secondary,"&:hover":{background:t.palette.action.hover},[t.breakpoints.down("sm")]:{border:`1px solid ${t.palette.divider}`,textIndent:"-9999em",fontSize:0,minWidth:30,maxWidth:30,height:30,width:30,overflow:"hidden","& .MuiButton-icon":{margin:0}}})),kt=styled(a)(({theme:t})=>({"& .MuiPopover-paper":{width:540,padding:t.spacing(3),backgroundColor:t.palette.background.paper,borderRadius:t.spacing(1),backgroundImage:"none",[t.breakpoints.down("sm")]:{width:"calc(100% - 48px)"}}}));var rr=()=>{let t=b("down","sm"),{slots:e,adapters:o,filters:a}=d(),{dateFilter:n,handleDateFilterChange:m$1,selectedPartners:s,selectedSellers:l,selectedStatuses:f}=a,h=useMemo(()=>{let dt=o.useSellerOptions?l.length:0;return s.length+dt+f.length},[o.useSellerOptions,s.length,l.length,f.length]),b$1=a$8(),i=a$8(),[T,Pt]=a$9(),ve=useCallback(dt=>{m$1(dt),b$1.onClose();},[m$1,b$1]),ke=n.period!=="OTHER"?e$1[n.period]:m(n.start_date,n.end_date);return jsxs(Fragment,{children:[jsxs(c,{direction:{xs:"column",sm:"row"},alignItems:{xs:"flex-start",sm:"center"},justifyContent:"space-between",gap:1.5,children:[jsxs(c,{width:"100%",direction:"row",alignItems:"center",gap:1.5,children:[jsx(St,{variant:"outlined",endIcon:jsx(a$3,{icon:"ARROW_DOWN_SIMPLE"}),color:"inherit",size:"small",fullWidth:t,onClick:b$1.onOpen,children:t?"Per\xEDodo":ke}),jsx(or,{badgeContent:h,invisible:h===0,color:"primary",children:jsx(St,{variant:"outlined",startIcon:jsx(a$3,{icon:"FILTER_LIST"}),color:"inherit",size:"small",fullWidth:t,onClick:Pt,children:"Filtrar"})}),t&&jsx(vt,{variant:"text",startIcon:jsx(a$3,{icon:"DOWNLOAD_EXPORT_04"}),size:"small",onClick:i.onOpen,sx:{display:"none"},children:"Exportar"})]}),!t&&jsx(vt,{variant:"text",startIcon:jsx(a$3,{icon:"DOWNLOAD_EXPORT_04"}),size:"small",color:"inherit",onClick:i.onOpen,sx:{display:"none"},children:"Exportar"})]}),jsx(kt,{open:b$1.open,onClose:b$1.onClose,arrow:t?"top-center":"top-left",TransitionProps:{timeout:0},disabledArrow:!0,children:e.renderDateFilter({value:n,onSave:ve,onClose:b$1.onClose})}),jsxs(kt,{open:i.open,onClose:i.onClose,arrow:"top-right",disabledArrow:!0,children:[jsx(a$6,{children:"Exportar XLSX"}),jsx(a$6,{children:"Exportar CSV"}),jsx(a$6,{children:"Exportar PDF"})]}),jsx(a$a,{open:T,onClose:Pt,headerTitle:"Filtros",headerProps:{direction:"row-reverse"},contentProps:{p:0},maxWidth:400,children:jsx(be,{})})]})},ar=rr;
|
|
60
60
|
|
|
61
61
|
export { He as CartDetail, it as CartStatusLabel, no as CartsList, _e as CartsProvider, Io as CartsSummary, ar as CartsToolbar, d as useCartsContext, w as useCartsFilterContext };
|
|
62
62
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { b, c, d as d$
|
|
1
|
+
import { b, c, d as d$2 } from '../../../chunk-FYG3YWFZ.js';
|
|
2
2
|
import { a, m, c as c$1, n } from '../../../chunk-OZTGZSNN.js';
|
|
3
3
|
import { a as a$2 } from '../../../chunk-Q2R3X4EB.js';
|
|
4
4
|
import { a as a$8 } from '../../../chunk-DRGARBKB.js';
|
|
5
5
|
import { a as a$7 } from '../../../chunk-NDX5YJV7.js';
|
|
6
6
|
import { a as a$5 } from '../../../chunk-LTXQ3A3C.js';
|
|
7
7
|
import { a as a$4 } from '../../../chunk-4XN57SLB.js';
|
|
8
|
-
import { d as d$
|
|
9
|
-
import { h, d
|
|
10
|
-
import {
|
|
8
|
+
import { d as d$1 } from '../../../chunk-2W5FGLTC.js';
|
|
9
|
+
import { h, d, c as c$2 } from '../../../chunk-OF6623HG.js';
|
|
10
|
+
import { f } from '../../../chunk-U7DEJBXJ.js';
|
|
11
11
|
import { a as a$3 } from '../../../chunk-33LSXTPO.js';
|
|
12
12
|
import { a as a$1 } from '../../../chunk-4F2NKGF6.js';
|
|
13
13
|
import '../../../chunk-PRWQQJDL.js';
|
|
@@ -17,7 +17,7 @@ import '../../../chunk-5NLFXSCK.js';
|
|
|
17
17
|
import '../../../chunk-6U5LS7MP.js';
|
|
18
18
|
import '../../../chunk-JUAHRU5E.js';
|
|
19
19
|
import '../../../chunk-NIQW2J3M.js';
|
|
20
|
-
import '../../../chunk-
|
|
20
|
+
import '../../../chunk-43EX76EH.js';
|
|
21
21
|
import '../../../chunk-UVPQR2Q2.js';
|
|
22
22
|
import '../../../chunk-RBTYTONM.js';
|
|
23
23
|
import '../../../chunk-I4PPSW36.js';
|
|
@@ -43,7 +43,7 @@ import Ze from '@mui/material/FormControlLabel';
|
|
|
43
43
|
import Lt from '@mui/material/Link';
|
|
44
44
|
import { styled, alpha } from '@mui/material/styles';
|
|
45
45
|
|
|
46
|
-
var te={orders:"#22C55E",quotations:"#0EA5E9"};var Qo=({x:e=0,y:o=0,width:t=0,height:a=0,index:r,activeBarIndex:i})=>i!==r?null:jsx("rect",{x:e-6,y:o,width:t+12,height:a+6,fill:"#919EAB",opacity:.16,rx:6}),Ve=Qo;var Xo=({x:e=0,y:o=0,width:t=0,index:a=0,data:r,visibleSeries:i,isMonthly:l,shouldRotateLabels:n})=>{if(!l||n)return null;let m=r[a];if(!m)return null;let s=0;return i.orders&&(s+=m.order_count??0),i.quotations&&(s+=m.quotation_count??0),s?jsx("text",{x:e+t/2,y:o-8,textAnchor:"middle",fontSize:11,fill:"#212B36",children:s}):null},We=Xo;var jo=({active:e,payload:o,label:t,viewMode:a})=>{if(!e||!o?.length)return null;let r=a==="DAILY",i=String(t),l=i.split("-");if(l.length>=2){let s=parseInt(l[1],10)-1,f=b[s];r&&l.length===3?i=`${parseInt(l[2],10)} de ${f} de ${l[0]}`:r||(i=`${f} de ${l[0]}`);}let n=o[0].payload,m=[{name:"Vendas",count:n.order_count??0,value:n.order_value??0,color:o.find(s=>s.dataKey==="order_count")?.color??"#22C55E"},{name:"Or\xE7amentos",count:n.quotation_count??0,value:n.quotation_value??0,color:o.find(s=>s.dataKey==="quotation_count")?.color??"#0EA5E9"}];return jsxs(a$8,{minWidth:{xs:"auto",sm:300},p:1,gap:1,children:[jsx(T,{variant:"body2",color:"text.secondary",children:i}),jsx(be,{}),jsx(L,{children:m.map((s,f)=>jsxs(L,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:2,"data-testid":`tooltip-item-${f}`,children:[jsxs(L,{direction:"row",alignItems:"center",gap:1,children:[jsx(L,{width:6,height:6,borderRadius:"50%",bgcolor:s.color}),jsx(T,{variant:"body2",noWrap:!0,children:s.name})]}),jsxs(T,{variant:"body2",color:"text.disabled",noWrap:!0,children:[s.count," ",s.count===1?"pedido":"pedidos","\u2002",jsx(T,{component:"span",variant:"body2",color:"text.primary",children:h(s.value)})]})]},s.name))})]})},vo=jo;var ct=({data:e,viewMode:o,visibleSeries:t,activeBarIndex:a,onMouseMove:r,onMouseLeave:i,onBarClick:l})=>{let n$1=o==="MONTHLY",[m,s]=useState(0),f=useRef(null),d=useCallback(h=>{f.current&&(f.current.disconnect(),f.current=null),h&&(s(h.clientWidth),f.current=new ResizeObserver(()=>s(h.clientWidth)),f.current.observe(h));},[]),c$2=useMemo(()=>!n$1||m===0||e.length===0?!1:(m-60)/e.length<80,[n$1,m,e.length]),y=useMemo(()=>e.some(h=>(h.order_count??0)>0),[e]),S=useMemo(()=>e.some(h=>(h.quotation_count??0)>0),[e]),g=useMemo(()=>{if(!e.length)return [0,1];let h=Math.max(...e.map(M=>(M.order_count??0)+(M.quotation_count??0)));return [0,h>0?h*1.15:1]},[e]),k=useMemo(()=>{let[,h]=g,M=h/6;return [...new Set(Array.from({length:7},(v,O)=>Math.round(M*O)))]},[g]),x=t.quotations&&S,p=t.orders&&y&&!x,D=useMemo(()=>n$1?c:d$3,[n$1]);return jsx(c$1,{ref:d,children:jsx(ResponsiveContainer,{width:"100%",height:250,children:jsxs(BarChart,{data:e,margin:{top:20,right:10,bottom:c$2?-90:0,left:20},barCategoryGap:"20%",style:{cursor:"pointer"},onMouseMove:r,onMouseLeave:i,onClick:h=>{h?.activeTooltipIndex!=null&&l?.(Number(h.activeTooltipIndex));},children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,...c$2&&{interval:0,height:120},tick:c$2?jsx(n,{}):{fontSize:12,fill:"#637381"},tickFormatter:D}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:h=>d$1(h),domain:g,ticks:k}),jsx(Tooltip,{content:jsx(vo,{viewMode:o}),cursor:!1}),jsx(Bar,{dataKey:"order_count",name:"Vendas",fill:te.orders,stackId:"orders",maxBarSize:48,isAnimationActive:!1,hide:!t.orders,background:jsx(Ve,{activeBarIndex:a}),radius:p?[4,4,0,0]:void 0,...p&&{label:{position:"top",fontSize:11,fill:"#212B36",content:jsx(We,{data:e,visibleSeries:t,isMonthly:n$1,shouldRotateLabels:c$2})}}}),jsx(Bar,{dataKey:"quotation_count",name:"Or\xE7amentos",fill:te.quotations,stackId:"orders",maxBarSize:48,isAnimationActive:!1,hide:!t.quotations,radius:x?[4,4,0,0]:void 0,...!t.orders&&{background:jsx(Ve,{activeBarIndex:a})},...x&&{label:{position:"top",fontSize:11,fill:"#212B36",content:jsx(We,{data:e,visibleSeries:t,isMonthly:n$1,shouldRotateLabels:c$2})}}})]})})})},So=ct;var dt=({visibleSeries:e,onToggleSerie:o})=>jsxs(L,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(Ze,{control:jsx(Je,{checked:e.orders,onChange:()=>o("orders"),sx:{"&.Mui-checked":{color:te.orders}}}),label:"Vendas"}),jsx(Ze,{control:jsx(Je,{checked:e.quotations,onChange:()=>o("quotations"),sx:{"&.Mui-checked":{color:te.quotations}}}),label:"Or\xE7amentos"})]}),ko=dt;var ut=({ordersTotal:e,quotationsTotal:o,isMonthly:t})=>{let a=b$1("down","md");return jsxs(L,{direction:{xs:"column",md:"row"},alignItems:{xs:"flex-start",md:"center"},flexWrap:"wrap",gap:3,children:[a&&jsx(be,{orientation:"horizontal",flexItem:!0,sx:{borderStyle:"dashed",mx:-3}}),jsxs(L,{children:[jsx(T,{variant:"body2",color:"text.secondary",children:t?"Vendas no ano":"Vendas no m\xEAs"}),jsxs(T,{variant:"subtitle2",children:[e," vendas"]})]}),jsx(be,{orientation:a?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:a?"solid":"dashed"}}),jsxs(L,{children:[jsx(T,{variant:"body2",color:"text.secondary",children:t?"Or\xE7amentos no ano":"Or\xE7amentos no m\xEAs"}),jsxs(T,{variant:"subtitle2",children:[o," or\xE7amentos"]})]})]})},_e=ut;var vt=({data:e,isFetching:o,viewMode:t,selectedYear:a$3,DetailComponent:r})=>{let i=t==="MONTHLY",[l,n]=useState({orders:!0,quotations:!0}),[m$1,s]=useState(null),[f,d]=useState(!1),[c,y]=useState(""),[S,g]=useState(0),k=useCallback(v=>{n(O=>({...O,[v]:!O[v]}));},[]),x=useCallback(v=>{v?.activeTooltipIndex!=null&&s(Number(v.activeTooltipIndex));},[]),p=useCallback(()=>s(null),[]),D=useCallback(v=>{let O=e[v];O&&(y(O.label),g(O.order_value),d(!0));},[e]),h=useCallback(()=>{d(!1);},[]),M=useMemo(()=>{let v=e.reduce((me,de)=>me+(de.order_count??0),0),O=e.reduce((me,de)=>me+(de.quotation_count??0),0);return {ordersTotal:v,quotationsTotal:O}},[e]);return jsxs(Fragment,{children:[jsxs(a,{children:[jsx(gt,{title:"Quantidade de pedidos por tipo"}),jsx(yt,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(L,{gap:3,children:[jsx(L,{display:{xs:"none",md:"block"},children:jsx(_e,{isMonthly:i,ordersTotal:M.ordersTotal,quotationsTotal:M.quotationsTotal})}),jsx(a$2,{active:o,children:jsx(So,{data:e,viewMode:t,visibleSeries:l,activeBarIndex:m$1,onMouseMove:x,onMouseLeave:p,onBarClick:D})}),jsx(ko,{visibleSeries:l,onToggleSerie:k}),jsx(L,{display:{xs:"block",md:"none"},children:jsx(_e,{isMonthly:i,ordersTotal:M.ordersTotal,quotationsTotal:M.quotationsTotal})})]})})})]}),c&&r&&jsx(r,{open:f,onClose:h,label:c,viewMode:t,selectedYear:a$3,totalValue:S})]})},bt=vt;var xt=({title:e,viewMode:o,selectedYear:t,periodLabel:a})=>jsxs(L,{width:"100%",minWidth:0,overflow:"hidden",children:[jsx(T,{variant:"subtitle1",noWrap:!0,children:"Detalhes do relat\xF3rio"}),jsxs(L,{direction:"row",alignItems:"center",columnGap:1.5,rowGap:0,flexWrap:"wrap",children:[jsx(T,{variant:"body2",color:"text.secondary",flexShrink:0,children:e}),"\u2022",jsx(T,{variant:"body2",flexShrink:0,children:b$2[o]}),"\u2022",jsx(T,{variant:"body2",flexShrink:0,children:t}),"\u2022",jsx(T,{variant:"body2",color:"text.secondary",noWrap:!0,children:a})]})]}),Do=xt;var Bo=styled(be)(()=>({height:30,alignSelf:"center",borderStyle:"dashed"})),Po=styled(L)(({theme:e})=>({position:"relative",display:"flex",flexDirection:"column",padding:e.spacing(2),gap:e.spacing(1),color:e.palette.text.primary,"& a":{textDecoration:"none"},"&+div":{borderTop:`1px dashed ${alpha(e.palette.grey[500],.2)}`}}));var Dt=e=>jsx(L,{justifyContent:"center",height:1,children:jsx(T,{variant:"body2",color:"text.primary",children:e.id})}),wt=(e,o)=>jsx(L,{justifyContent:"center",height:1,children:e?.partner?.id&&o?jsx(Lt,{component:"a",href:o(e.partner.id),target:"_blank",rel:"noopener noreferrer",variant:"subtitle2",sx:{textDecoration:"underline"},noWrap:!0,children:e.partner?.name||"-"}):jsx(T,{variant:"body2",color:"text.primary",noWrap:!0,children:e.partner?.name||"-"})}),Bt=e=>jsx(L,{justifyContent:"center",height:1,children:jsx(T,{variant:"body2",color:"text.primary",children:h(e.total_value)})}),Pt=e=>jsx(L,{justifyContent:"center",height:1,children:e.negotiation_date?jsx(T,{variant:"body2",color:"text.primary",children:d$2(e.negotiation_date,"DD/MM/YYYY")}):"-"}),Rt=e=>jsx(L,{justifyContent:"center",height:1,children:e.status||"-"}),Ot=(e,o)=>jsx(Po,{children:jsxs(L,{gap:1,children:[jsxs(L,{children:[jsx(T,{variant:"body2",color:"text.secondary",children:"Pedido"}),jsx(T,{variant:"subtitle2",color:"text.primary",children:e.id})]}),jsxs(L,{children:[jsx(T,{variant:"body2",color:"text.secondary",children:"Cliente"}),jsx(T,{variant:"subtitle2",color:"primary.main",children:e.partner?.name||"-"})]}),jsxs(L,{direction:"row",alignItems:"center",gap:1,children:[jsxs(L,{flex:1,overflow:"hidden",children:[jsx(T,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Valor do pedido"}),jsx(T,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:h(e.total_value)})]}),jsx(be,{orientation:"vertical",flexItem:!0,sx:{borderStyle:"dashed",mx:3}}),jsxs(L,{flex:1,overflow:"hidden",children:[jsx(T,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Data"}),jsx(T,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:e.negotiation_date?d$2(e.negotiation_date,"DD/MM/YYYY"):"-"})]})]}),!o&&jsxs(L,{gap:.5,children:[jsx(T,{variant:"body2",color:"text.secondary",children:"Status"}),jsx(T,{variant:"subtitle2",color:"text.primary",children:e.status||"-"})]})]})},e.id),It=({open:e,onClose:o,title:t,viewMode:a,selectedYear:r,totalValue:i,periodLabel:l,suffix:n,rows:m,total:s,isLoading:f,isFetching:d$1,page:c,perPage:y,onSearch:S,onPaginationChange:g,buildPartnerLink:k,mobileItemSlot:x,hideStatus:p})=>{let D=b$1("down","sm"),h$1=jsxs(L,{gap:3,children:[jsxs(L,{direction:{xs:"column",sm:"row"},justifyContent:"space-between",gap:2,children:[jsxs(L,{minWidth:0,direction:"row",alignItems:"center",gap:3,flexWrap:"wrap",children:[jsxs(L,{children:[jsxs(T,{variant:"body2",color:"text.secondary",children:["Vendas ",n]}),jsx(T,{variant:"subtitle2",color:"text.primary",children:h(i)})]}),jsx(Bo,{orientation:"vertical",flexItem:!0}),jsxs(L,{children:[jsxs(T,{variant:"body2",color:"text.secondary",children:["Qtd. de pedidos ",n]}),jsx(T,{variant:"subtitle2",color:"text.primary",children:s})]})]}),jsx(a$3,{size:"small",placeholder:"Buscar",onSearch:S,trigger:"change",iconPosition:"start",sx:{minWidth:200}})]}),jsx(d,{title:"Pedidos",header:jsx(Fragment,{}),headerProps:{p:0},columns:[{field:"external_id",headerName:"Pedido",flex:1,renderCell:({row:v})=>Dt(v)},{field:"partner_name",headerName:"Cliente",flex:1,renderCell:({row:v})=>wt(v,k)},{field:"total_value",headerName:"Valor do pedido",flex:1,renderCell:({row:v})=>Bt(v)},{field:"created_at",headerName:"Data",flex:1,renderCell:({row:v})=>Pt(v)},...p?[]:[{field:"last_status",headerName:"Status",flex:1,renderCell:({row:v})=>Rt(v)}]],rows:m,rowCount:s,mobileRender:v=>x?x(v):Ot(v,p),loading:f,fetching:d$1,paginationModel:{page:c,pageSize:y},onPaginationChange:g,paginationMode:"server",disableRowSelectionOnClick:!0,disableColumnMenu:!0,containerProps:{height:400}})]}),M=jsx(Do,{title:t,viewMode:a,selectedYear:r,periodLabel:l});return D?jsx(a$4,{open:e,onClose:o,headerTitle:M,headerProps:{direction:"row-reverse",sx:{"& > :last-child":{minWidth:0,overflow:"hidden"}}},children:h$1}):jsx(a$5,{open:e,onClose:o,maxWidth:"lg",dialogTitle:M,dialogTitleProps:{sx:{flex:1,overflow:"hidden"}},fullWidth:!0,children:h$1})},zt=It;var Ye=(e,o)=>{let t=e.split("-");if(o==="DAILY"&&t.length===3){let l=`${t[0]}-${t[1]}-${t[2]}`;return {startDate:l,endDate:l}}let a=parseInt(t[0],10),r=parseInt(t[1],10),i=new Date(a,r,0).getDate();return {startDate:`${t[0]}-${t[1]}-01`,endDate:`${t[0]}-${t[1]}-${String(i).padStart(2,"0")}`}},Ge=(e,o)=>{let t=e.split("-"),a=parseInt(t[1],10)-1,r=b[a]??"";if(o==="DAILY"&&t.length===3){let i=parseInt(t[2],10);return `${r} - Dia ${i}`}return r},qe=e=>e==="MONTHLY"?"no m\xEAs":"no dia";var Vt=(e,o)=>{let{page:t,perPage:a,search:r,handlePaginationModelChange:i,handleSearch:l}=a$6(),{startDate:n,endDate:m}=useMemo(()=>Ye(e,o),[e,o]),s=useMemo(()=>Ge(e,o),[e,o]),f=qe(o),d=useMemo(()=>({page:t,perPage:a,...r?{search:r}:{},filter:{operator:"AND",groups:[{operator:"AND",conditionals:[{fieldName:"negotiationDate",conditional:"GREATER_THAN_OR_EQUAL",value:[`${n}T00:00:00`]},{fieldName:"negotiationDate",conditional:"LESS_THAN_OR_EQUAL",value:[`${m}T23:59:59`]}]}]}}),[m,t,a,r,n]),c=useCallback((y,S)=>{i({page:y,pageSize:S});},[i]);return {page:t,perPage:a,periodLabel:s,suffix:f,queryParams:d,handleSearch:l,handlePaginationChange:c}},Wt=Vt;var C={sales:"#22C55E",forecast:"#F59E0B",goal:"#212B36"};var Et=({x:e=0,y:o=0,width:t=0,height:a=0,index:r,activeBarIndex:i})=>i!==r?null:jsx("rect",{x:e-6,y:o,width:t+6*2,height:a+6,fill:C.sales,opacity:.16,rx:6}),we=Et;var $t=({active:e,payload:o,label:t,viewMode:a,hideGoal:r})=>{if(!e||!o?.length)return null;let i=a==="DAILY",l=o[0].payload,n=Number(l.realized)||0,m=Number(l.forecast)||0,s=Number(l.goal)||0,f=s>0?n/s*100:0,d=s>n?s-n:0,c=i?"no dia":"no m\xEAs",y=i?"di\xE1ria":"mensal",S=String(t),g=S.split("-");if(g.length>=2){let x=parseInt(g[1],10)-1,p=b[x];i&&g.length===3?S=`${parseInt(g[2],10)} de ${p} de ${g[0]}`:i||(S=`${p} de ${g[0]}`);}let k=[{name:`Realizado ${c}`,value:h(n),color:C.sales},{name:`Previsto ${c}`,value:h(m),color:C.forecast},...r?[]:[{name:`Meta ${y}`,value:h(s),color:C.goal},{name:"Atingimento",value:`${f.toFixed(0)}%`,color:"#00B8D9"},{name:`GAP ${c}`,value:h(d),color:"#FF5630"}]];return jsxs(a$8,{minWidth:{xs:"auto",sm:400},p:1,gap:1,children:[jsx(T,{variant:"body2",color:"text.secondary",children:S}),jsx(be,{}),jsx(L,{children:k.map((x,p)=>jsxs(L,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,"data-testid":`tooltip-item-${p}`,children:[jsxs(L,{direction:"row",alignItems:"center",gap:1,children:[jsx(L,{width:6,height:6,borderRadius:"50%",bgcolor:x.color}),jsx(T,{variant:"body2",noWrap:!0,children:x.name})]}),jsx(T,{variant:"body2",children:x.value})]},p))})]})},Pe=$t;var Jt=({data:e,visibleSeries:o,yDomain:t,yTicks:a,viewMode:r,activeBarIndex:i,onMouseMove:l,onMouseLeave:n,onBarClick:m,hideGoal:s})=>{let f=useCallback(d=>d$1(d),[]);return jsx(ResponsiveContainer,{width:"100%",height:350,children:jsxs(ComposedChart,{data:e,margin:{top:20,right:10,bottom:0,left:20},style:{cursor:"pointer"},onMouseMove:l,onMouseLeave:n,onClick:d=>{d?.activeTooltipIndex!=null&&m?.(Number(d.activeTooltipIndex));},children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:d$3}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:f,domain:t,ticks:a}),jsx(Tooltip,{content:jsx(Pe,{viewMode:r,hideGoal:s})}),jsx(Bar,{dataKey:"realized",fill:"transparent",isAnimationActive:!1,background:jsx(we,{activeBarIndex:i})}),o.goal&&jsx(Line,{dataKey:"goal",name:"Meta",stroke:C.goal,strokeWidth:2,strokeDasharray:"8 4",dot:!1,isAnimationActive:!1}),o.realized&&jsx(Line,{dataKey:"realized",name:"Vendas",stroke:C.sales,strokeWidth:2,dot:{fill:C.sales,r:4,strokeWidth:0},isAnimationActive:!1}),o.forecast&&jsx(Line,{dataKey:"forecast",name:"Previsto",stroke:C.forecast,strokeWidth:2,strokeDasharray:"6 3",dot:{fill:C.forecast,r:4,strokeWidth:0},isAnimationActive:!1})]})})},Ro=Jt;var sr=({data:e,visibleSeries:o,yDomain:t,yTicks:a,shouldRotateLabels:r,activeBarIndex:i,onMouseMove:l,onMouseLeave:n$1,onBarClick:m,viewMode:s,hideGoal:f})=>{let d=useMemo(()=>r?!1:{position:"top",fontSize:12,fill:"#212B36",formatter:c=>h(Number(c))},[r]);return jsx(ResponsiveContainer,{width:"100%",height:300,children:jsxs(ComposedChart,{data:e,margin:{top:20,right:10,bottom:r?-90:0,left:20},barCategoryGap:"20%",style:{cursor:"pointer"},onMouseMove:l,onMouseLeave:n$1,onClick:c=>{c?.activeTooltipIndex!=null&&m?.(Number(c.activeTooltipIndex));},children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,...r&&{interval:0,height:120},tick:r?jsx(n,{}):{fontSize:12,fill:"#637381"},tickFormatter:c}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:c=>d$1(c),domain:t,ticks:a}),jsx(Tooltip,{content:jsx(Pe,{viewMode:s,hideGoal:f})}),o.goal&&jsx(Line,{dataKey:"goal",name:"Meta",stroke:C.goal,strokeWidth:2,strokeDasharray:"8 4",dot:!1,isAnimationActive:!1}),o.realized&&jsx(Bar,{dataKey:"realized",name:"Vendas",fill:C.sales,maxBarSize:48,isAnimationActive:!1,radius:[4,4,0,0],background:jsx(we,{activeBarIndex:i}),label:d}),o.forecast&&jsx(Line,{dataKey:"forecast",name:"Previsto",stroke:C.forecast,strokeWidth:2,strokeDasharray:"6 3",dot:{fill:C.forecast,r:4,strokeWidth:0},isAnimationActive:!1})]})})},Io=sr;var mr=({data:e,viewMode:o,visibleSeries:t,yDomain:a,yTicks:r,formatYAxis:i,onBarClick:l,hideGoal:n})=>{let[m,s]=useState(null),[f,d]=useState(0),c=useRef(null),y=o==="MONTHLY",S=useMemo(()=>!y||f===0||e.length===0?!1:(f-60)/e.length<60,[f,e.length,y]),g=useCallback(()=>s(null),[]),k=useCallback(p=>{p?.activeTooltipIndex!=null&&s(Number(p.activeTooltipIndex));},[]),x=useCallback(p=>{c.current&&(c.current.disconnect(),c.current=null),p&&(d(p.clientWidth),c.current=new ResizeObserver(()=>d(p.clientWidth)),c.current.observe(p));},[]);return y?jsx(c$1,{ref:x,children:jsx(Io,{data:e,visibleSeries:t,yDomain:a,yTicks:r,formatYAxis:i,shouldRotateLabels:S,activeBarIndex:m,onMouseMove:k,onMouseLeave:g,onBarClick:l,viewMode:o,hideGoal:n})}):jsx(c$1,{ref:x,children:jsx(Ro,{data:e,visibleSeries:t,yDomain:a,yTicks:r,formatYAxis:i,viewMode:o,activeBarIndex:m,onMouseMove:k,onMouseLeave:g,onBarClick:l,hideGoal:n})})},Fo=mr;var fr=({visibleSeries:e,onToggleSerie:o,hideGoal:t})=>jsxs(L,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(Ze,{control:jsx(Je,{checked:e.realized,onChange:()=>o("realized"),sx:{"&.Mui-checked":{color:C.sales}}}),label:"Vendas"}),jsx(Ze,{control:jsx(Je,{checked:e.forecast,onChange:()=>o("forecast"),sx:{"&.Mui-checked":{color:C.forecast}}}),label:"Previsto"}),!t&&jsx(Ze,{control:jsx(Je,{checked:e.goal,onChange:()=>o("goal"),sx:{"&.Mui-checked":{color:C.goal}}}),label:"Meta"})]}),Ao=fr;var hr=({kpis:e,isMonthly:o,editGoalAction:t,hideGoal:a})=>{let r=b$1("down","md");return jsxs(L,{direction:{xs:"column",md:"row"},alignItems:{xs:"flex-start",md:"center"},flexWrap:"wrap",gap:3,children:[r&&jsx(be,{orientation:"horizontal",flexItem:!0,sx:{borderStyle:"dashed",mx:-3}}),jsxs(L,{children:[jsxs(T,{variant:"body2",color:"text.secondary",children:["Previsto no ",o?"ano":"m\xEAs"]}),jsx(T,{variant:"subtitle2",children:h(e?.forecast)})]}),jsx(be,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(L,{children:[jsxs(T,{variant:"body2",color:"text.secondary",children:["Realizado no ",o?"ano":"m\xEAs"]}),jsx(T,{variant:"subtitle2",children:h(e?.realized)})]}),!a&&jsx(be,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),!a&&jsxs(L,{children:[jsxs(L,{direction:"row",alignItems:"center",gap:3,children:[jsxs(T,{variant:"body2",color:"text.secondary",children:["Meta ",o?"anual":"mensal"]}),t]}),jsx(T,{variant:"subtitle2",children:h(e?.goal)})]}),!a&&jsx(be,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),!a&&jsxs(L,{children:[jsx(T,{variant:"body2",color:"text.secondary",children:"Atingimento"}),jsx(T,{variant:"subtitle2",children:c$2(e?.achievement??0,{maximumFractionDigits:2,minimumFractionDigits:2})})]}),!a&&jsx(be,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),!a&&jsxs(L,{children:[jsxs(L,{direction:"row",gap:.5,children:[jsxs(T,{variant:"body2",color:"text.secondary",children:["GAP do ",o?"ano":"m\xEAs"]}),jsx(a$7,{text:"Diferen\xE7a entre o valor realizado e a meta. Um GAP significa que as vendas ainda est\xE3o abaixo do objetivo definido para o per\xEDodo.",width:18,arrow:!0,sx:{mt:-.1}})]}),jsx(T,{variant:"subtitle2",children:h(e?.gap)})]})]})},je=hr;var vr=({data:e,isFetching:o,kpis:t,viewMode:a$3,selectedYear:r,editGoalAction:i,DetailComponent:l,hideGoal:n,emptyMessage:m$1})=>{let[s,f]=useState({realized:!0,forecast:!0,goal:!0}),[d,c]=useState(!1),[y,S]=useState(""),[g,k]=useState(0),x=a$3==="MONTHLY",p=useMemo(()=>m$1!=null&&e.every(w=>!Number(w.realized)),[e,m$1]),D=useMemo(()=>{if(!e.length)return [0,1];let w=e.flatMap(fe=>[Number(fe.realized)||0,Number(fe.forecast)||0,Number(fe.goal)||0]),V=Math.max(...w);return [0,V>0?V*1.15:1]},[e]),h=useMemo(()=>{let[,w]=D,V=w/6,fe=Array.from({length:7},(Kr,Ko)=>Math.round(V*Ko));return [...new Set(fe)]},[D]),M=useCallback(w=>{f(V=>({...V,[w]:!V[w]}));},[]),v=useCallback(w=>M(w),[M]),O=useCallback(w=>{let V=e[w];V&&(S(V.label),k(V.realized),c(!0));},[e]),me=useCallback(()=>{c(!1);},[]),de=useCallback(w=>d$1(w),[]);return jsxs(Fragment,{children:[jsxs(a,{children:[jsx(gt,{title:"Evolu\xE7\xE3o de vendas"}),jsx(yt,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(L,{gap:3,children:[jsx(L,{display:{xs:"none",md:"block"},children:jsx(je,{kpis:t,isMonthly:x,editGoalAction:i,hideGoal:n})}),p?jsx(m,{title:m$1,description:"Troque a origem do pedido ou o per\xEDodo selecionado."}):jsx(a$2,{active:o,children:jsx(Fo,{data:e,viewMode:a$3,visibleSeries:n?{...s,goal:!1}:s,yDomain:D,yTicks:h,formatYAxis:de,onBarClick:O,hideGoal:n})}),!p&&jsx(Ao,{visibleSeries:s,onToggleSerie:v,hideGoal:n}),jsx(L,{display:{xs:"block",md:"none"},children:jsx(je,{kpis:t,isMonthly:x,editGoalAction:i,hideGoal:n})})]})})})]}),y&&l&&jsx(l,{open:d,onClose:me,label:y,viewMode:a$3,selectedYear:r,totalValue:g})]})},br=vr;var se={realized:"#22C55E",forecast:"#F59E0B"};var xr=({x:e=0,y:o=0,width:t=0,height:a=0,index:r,activeBarIndex:i})=>i!==r?null:jsx("rect",{x:e-6,y:o,width:t+12,height:a+6,fill:"#919EAB",opacity:.16,rx:6}),Vo=xr;var kr=({x:e=0,y:o=0,width:t=0,height:a=0,index:r,activeBarIndex:i,bothRendered:l})=>i!==r?null:jsx("rect",{x:e-6,y:o,width:l?t*2+4+12:t+12,height:a+6,fill:"#919EAB",opacity:.16,rx:6}),Wo=kr;var Lr=({active:e,payload:o,label:t,viewMode:a})=>{if(!e||!o?.length)return null;let r=a==="DAILY",i=String(t),l=i.split("-");if(l.length>=2){let n=parseInt(l[1],10)-1,m=b[n];r&&l.length===3?i=`${parseInt(l[2],10)} de ${m} de ${l[0]}`:r||(i=`${m} de ${l[0]}`);}return jsxs(a$8,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(T,{variant:"body2",color:"text.secondary",children:i}),jsx(be,{}),jsx(L,{children:o.map((n,m)=>jsxs(L,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,"data-testid":`tooltip-item-${m}`,children:[jsxs(L,{direction:"row",alignItems:"center",gap:1,children:[jsx(L,{width:6,height:6,borderRadius:"50%",bgcolor:n.color}),jsx(T,{variant:"body2",noWrap:!0,children:n.name})]}),jsx(T,{variant:"body2",children:h(n.value)})]},n.name))})]})},Eo=Lr;var Ar=({data:e,viewMode:o,visibleSeries:t,activeBarIndex:a,onMouseMove:r,onMouseLeave:i})=>{let l=o==="MONTHLY",[n$1,m]=useState(0),s=useRef(null),f=useCallback(p=>{s.current&&(s.current.disconnect(),s.current=null),p&&(m(p.clientWidth),s.current=new ResizeObserver(()=>m(p.clientWidth)),s.current.observe(p));},[]),d=useMemo(()=>!l||n$1===0||e.length===0?!1:(n$1-60)/e.length<80,[l,n$1,e.length]),c$2=useMemo(()=>e.some(p=>p.realized_value>0),[e]),y=useMemo(()=>e.some(p=>p.forecast_value>0),[e]),S=useMemo(()=>{if(!e.length)return [0,1];let p=e.flatMap(h=>[h.realized_value,h.forecast_value]),D=Math.max(...p);return [0,D>0?D*1.15:1]},[e]),g=useMemo(()=>{let[,p]=S,D=p/6;return [...new Set(Array.from({length:7},(h,M)=>Math.round(D*M)))]},[S]),k=useMemo(()=>l?c:d$3,[l]),x=t.realized&&c$2&&t.forecast&&y;return jsx(c$1,{ref:f,children:jsx(ResponsiveContainer,{width:"100%",height:250,children:jsxs(BarChart,{data:e,margin:{top:20,right:10,bottom:d?-90:0,left:20},barCategoryGap:"20%",barGap:4,onMouseMove:r,onMouseLeave:i,children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,...d&&{interval:0,height:120},tick:d?jsx(n,{}):{fontSize:12,fill:"#637381"},tickFormatter:k}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:p=>d$1(p),domain:S,ticks:g}),jsx(Tooltip,{content:jsx(Eo,{viewMode:o}),cursor:!1}),t.realized&&c$2&&jsx(Bar,{dataKey:"realized_value",name:"Realizado",fill:se.realized,maxBarSize:32,isAnimationActive:!1,radius:[4,4,0,0],background:jsx(Wo,{activeBarIndex:a,bothRendered:x})}),t.forecast&&y&&jsx(Bar,{dataKey:"forecast_value",name:"Previsto",fill:se.forecast,maxBarSize:32,isAnimationActive:!1,radius:[4,4,0,0],...!t.realized&&{background:jsx(Vo,{activeBarIndex:a})}})]})})})},No=Ar;var Er=({visibleSeries:e,onToggleSerie:o})=>jsxs(L,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(Ze,{control:jsx(Je,{checked:e.realized,onChange:()=>o("realized"),sx:{"&.Mui-checked":{color:se.realized}}}),label:"Realizado"}),jsx(Ze,{control:jsx(Je,{checked:e.forecast,onChange:()=>o("forecast"),sx:{"&.Mui-checked":{color:se.forecast}}}),label:"Previsto"})]}),Go=Er;var Nr=({totalForecast:e,totalRealized:o,percentage:t,isMonthly:a})=>{let r=b$1("down","md");return jsxs(L,{direction:{xs:"column",md:"row"},alignItems:{xs:"flex-start",md:"center"},flexWrap:"wrap",gap:3,children:[r&&jsx(be,{orientation:"horizontal",flexItem:!0,sx:{borderStyle:"dashed",mx:-3}}),jsxs(L,{children:[jsx(T,{variant:"body2",color:"text.secondary",children:a?"Total previsto no ano":"Total previsto no m\xEAs"}),jsx(T,{variant:"subtitle2",children:h(e)})]}),jsx(be,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(L,{children:[jsx(T,{variant:"body2",color:"text.secondary",children:a?"Total realizado no ano":"Total realizado no m\xEAs"}),jsx(T,{variant:"subtitle2",children:h(o)})]}),jsx(be,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(L,{children:[jsx(T,{variant:"body2",color:"text.secondary",children:"Atingimento"}),jsxs(T,{variant:"subtitle2",children:[t,"%"]})]})]})},no=Nr;var qr=({data:e,viewMode:o,isFetching:t})=>{let a$3=o==="MONTHLY",[r,i]=useState({realized:!0,forecast:!0}),[l,n]=useState(null),m$1=useCallback(c=>{i(y=>({...y,[c]:!y[c]}));},[]),s=useCallback(c=>{c?.activeTooltipIndex!=null&&n(Number(c.activeTooltipIndex));},[]),f=useCallback(()=>n(null),[]),d=useMemo(()=>{let c=e.reduce((g,k)=>g+(k.realized_value??0),0),y=e.reduce((g,k)=>g+(k.forecast_value??0),0),S=y>0?Math.round(c/y*100):0;return {totalRealized:c,totalForecast:y,percentage:S}},[e]);return jsxs(a,{children:[jsx(gt,{title:"Previsto vs. Realizado (Positiva\xE7\xE3o)"}),jsx(yt,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(L,{gap:3,children:[jsx(L,{display:{xs:"none",md:"block"},children:jsx(no,{totalForecast:d.totalForecast,totalRealized:d.totalRealized,percentage:d.percentage,isMonthly:a$3})}),jsx(a$2,{active:t,children:jsx(No,{data:e,viewMode:o,visibleSeries:r,activeBarIndex:l,onMouseMove:s,onMouseLeave:f})}),jsx(Go,{visibleSeries:r,onToggleSerie:m$1}),jsx(L,{display:{xs:"block",md:"none"},children:jsx(no,{totalForecast:d.totalForecast,totalRealized:d.totalRealized,percentage:d.percentage,isMonthly:a$3})})]})})})]})},Hr=qr;
|
|
46
|
+
var te={orders:"#22C55E",quotations:"#0EA5E9"};var Qo=({x:e=0,y:o=0,width:t=0,height:a=0,index:r,activeBarIndex:i})=>i!==r?null:jsx("rect",{x:e-6,y:o,width:t+12,height:a+6,fill:"#919EAB",opacity:.16,rx:6}),Ve=Qo;var Xo=({x:e=0,y:o=0,width:t=0,index:a=0,data:r,visibleSeries:i,isMonthly:l,shouldRotateLabels:n})=>{if(!l||n)return null;let m=r[a];if(!m)return null;let s=0;return i.orders&&(s+=m.order_count??0),i.quotations&&(s+=m.quotation_count??0),s?jsx("text",{x:e+t/2,y:o-8,textAnchor:"middle",fontSize:11,fill:"#212B36",children:s}):null},We=Xo;var jo=({active:e,payload:o,label:t,viewMode:a})=>{if(!e||!o?.length)return null;let r=a==="DAILY",i=String(t),l=i.split("-");if(l.length>=2){let s=parseInt(l[1],10)-1,f=b[s];r&&l.length===3?i=`${parseInt(l[2],10)} de ${f} de ${l[0]}`:r||(i=`${f} de ${l[0]}`);}let n=o[0].payload,m=[{name:"Vendas",count:n.order_count??0,value:n.order_value??0,color:o.find(s=>s.dataKey==="order_count")?.color??"#22C55E"},{name:"Or\xE7amentos",count:n.quotation_count??0,value:n.quotation_value??0,color:o.find(s=>s.dataKey==="quotation_count")?.color??"#0EA5E9"}];return jsxs(a$8,{minWidth:{xs:"auto",sm:300},p:1,gap:1,children:[jsx(T,{variant:"body2",color:"text.secondary",children:i}),jsx(be,{}),jsx(L,{children:m.map((s,f)=>jsxs(L,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:2,"data-testid":`tooltip-item-${f}`,children:[jsxs(L,{direction:"row",alignItems:"center",gap:1,children:[jsx(L,{width:6,height:6,borderRadius:"50%",bgcolor:s.color}),jsx(T,{variant:"body2",noWrap:!0,children:s.name})]}),jsxs(T,{variant:"body2",color:"text.disabled",noWrap:!0,children:[s.count," ",s.count===1?"pedido":"pedidos","\u2002",jsx(T,{component:"span",variant:"body2",color:"text.primary",children:h(s.value)})]})]},s.name))})]})},vo=jo;var ct=({data:e,viewMode:o,visibleSeries:t,activeBarIndex:a,onMouseMove:r,onMouseLeave:i,onBarClick:l})=>{let n$1=o==="MONTHLY",[m,s]=useState(0),f=useRef(null),d$1=useCallback(h=>{f.current&&(f.current.disconnect(),f.current=null),h&&(s(h.clientWidth),f.current=new ResizeObserver(()=>s(h.clientWidth)),f.current.observe(h));},[]),c$2=useMemo(()=>!n$1||m===0||e.length===0?!1:(m-60)/e.length<80,[n$1,m,e.length]),y=useMemo(()=>e.some(h=>(h.order_count??0)>0),[e]),S=useMemo(()=>e.some(h=>(h.quotation_count??0)>0),[e]),g=useMemo(()=>{if(!e.length)return [0,1];let h=Math.max(...e.map(M=>(M.order_count??0)+(M.quotation_count??0)));return [0,h>0?h*1.15:1]},[e]),k=useMemo(()=>{let[,h]=g,M=h/6;return [...new Set(Array.from({length:7},(v,O)=>Math.round(M*O)))]},[g]),x=t.quotations&&S,p=t.orders&&y&&!x,D=useMemo(()=>n$1?c:d$2,[n$1]);return jsx(c$1,{ref:d$1,children:jsx(ResponsiveContainer,{width:"100%",height:250,children:jsxs(BarChart,{data:e,margin:{top:20,right:10,bottom:c$2?-90:0,left:20},barCategoryGap:"20%",style:{cursor:"pointer"},onMouseMove:r,onMouseLeave:i,onClick:h=>{h?.activeTooltipIndex!=null&&l?.(Number(h.activeTooltipIndex));},children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,...c$2&&{interval:0,height:120},tick:c$2?jsx(n,{}):{fontSize:12,fill:"#637381"},tickFormatter:D}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:h=>d(h),domain:g,ticks:k}),jsx(Tooltip,{content:jsx(vo,{viewMode:o}),cursor:!1}),jsx(Bar,{dataKey:"order_count",name:"Vendas",fill:te.orders,stackId:"orders",maxBarSize:48,isAnimationActive:!1,hide:!t.orders,background:jsx(Ve,{activeBarIndex:a}),radius:p?[4,4,0,0]:void 0,...p&&{label:{position:"top",fontSize:11,fill:"#212B36",content:jsx(We,{data:e,visibleSeries:t,isMonthly:n$1,shouldRotateLabels:c$2})}}}),jsx(Bar,{dataKey:"quotation_count",name:"Or\xE7amentos",fill:te.quotations,stackId:"orders",maxBarSize:48,isAnimationActive:!1,hide:!t.quotations,radius:x?[4,4,0,0]:void 0,...!t.orders&&{background:jsx(Ve,{activeBarIndex:a})},...x&&{label:{position:"top",fontSize:11,fill:"#212B36",content:jsx(We,{data:e,visibleSeries:t,isMonthly:n$1,shouldRotateLabels:c$2})}}})]})})})},So=ct;var dt=({visibleSeries:e,onToggleSerie:o})=>jsxs(L,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(Ze,{control:jsx(Je,{checked:e.orders,onChange:()=>o("orders"),sx:{"&.Mui-checked":{color:te.orders}}}),label:"Vendas"}),jsx(Ze,{control:jsx(Je,{checked:e.quotations,onChange:()=>o("quotations"),sx:{"&.Mui-checked":{color:te.quotations}}}),label:"Or\xE7amentos"})]}),ko=dt;var ut=({ordersTotal:e,quotationsTotal:o,isMonthly:t})=>{let a=b$1("down","md");return jsxs(L,{direction:{xs:"column",md:"row"},alignItems:{xs:"flex-start",md:"center"},flexWrap:"wrap",gap:3,children:[a&&jsx(be,{orientation:"horizontal",flexItem:!0,sx:{borderStyle:"dashed",mx:-3}}),jsxs(L,{children:[jsx(T,{variant:"body2",color:"text.secondary",children:t?"Vendas no ano":"Vendas no m\xEAs"}),jsxs(T,{variant:"subtitle2",children:[e," vendas"]})]}),jsx(be,{orientation:a?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:a?"solid":"dashed"}}),jsxs(L,{children:[jsx(T,{variant:"body2",color:"text.secondary",children:t?"Or\xE7amentos no ano":"Or\xE7amentos no m\xEAs"}),jsxs(T,{variant:"subtitle2",children:[o," or\xE7amentos"]})]})]})},_e=ut;var vt=({data:e,isFetching:o,viewMode:t,selectedYear:a$3,DetailComponent:r})=>{let i=t==="MONTHLY",[l,n]=useState({orders:!0,quotations:!0}),[m$1,s]=useState(null),[f,d]=useState(!1),[c,y]=useState(""),[S,g]=useState(0),k=useCallback(v=>{n(O=>({...O,[v]:!O[v]}));},[]),x=useCallback(v=>{v?.activeTooltipIndex!=null&&s(Number(v.activeTooltipIndex));},[]),p=useCallback(()=>s(null),[]),D=useCallback(v=>{let O=e[v];O&&(y(O.label),g(O.order_value),d(!0));},[e]),h=useCallback(()=>{d(!1);},[]),M=useMemo(()=>{let v=e.reduce((me,de)=>me+(de.order_count??0),0),O=e.reduce((me,de)=>me+(de.quotation_count??0),0);return {ordersTotal:v,quotationsTotal:O}},[e]);return jsxs(Fragment,{children:[jsxs(a,{children:[jsx(gt,{title:"Quantidade de pedidos por tipo"}),jsx(yt,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(L,{gap:3,children:[jsx(L,{display:{xs:"none",md:"block"},children:jsx(_e,{isMonthly:i,ordersTotal:M.ordersTotal,quotationsTotal:M.quotationsTotal})}),jsx(a$2,{active:o,children:jsx(So,{data:e,viewMode:t,visibleSeries:l,activeBarIndex:m$1,onMouseMove:x,onMouseLeave:p,onBarClick:D})}),jsx(ko,{visibleSeries:l,onToggleSerie:k}),jsx(L,{display:{xs:"block",md:"none"},children:jsx(_e,{isMonthly:i,ordersTotal:M.ordersTotal,quotationsTotal:M.quotationsTotal})})]})})})]}),c&&r&&jsx(r,{open:f,onClose:h,label:c,viewMode:t,selectedYear:a$3,totalValue:S})]})},bt=vt;var xt=({title:e,viewMode:o,selectedYear:t,periodLabel:a})=>jsxs(L,{width:"100%",minWidth:0,overflow:"hidden",children:[jsx(T,{variant:"subtitle1",noWrap:!0,children:"Detalhes do relat\xF3rio"}),jsxs(L,{direction:"row",alignItems:"center",columnGap:1.5,rowGap:0,flexWrap:"wrap",children:[jsx(T,{variant:"body2",color:"text.secondary",flexShrink:0,children:e}),"\u2022",jsx(T,{variant:"body2",flexShrink:0,children:b$2[o]}),"\u2022",jsx(T,{variant:"body2",flexShrink:0,children:t}),"\u2022",jsx(T,{variant:"body2",color:"text.secondary",noWrap:!0,children:a})]})]}),Do=xt;var Bo=styled(be)(()=>({height:30,alignSelf:"center",borderStyle:"dashed"})),Po=styled(L)(({theme:e})=>({position:"relative",display:"flex",flexDirection:"column",padding:e.spacing(2),gap:e.spacing(1),color:e.palette.text.primary,"& a":{textDecoration:"none"},"&+div":{borderTop:`1px dashed ${alpha(e.palette.grey[500],.2)}`}}));var Dt=e=>jsx(L,{justifyContent:"center",height:1,children:jsx(T,{variant:"body2",color:"text.primary",children:e.id})}),wt=(e,o)=>jsx(L,{justifyContent:"center",height:1,children:e?.partner?.id&&o?jsx(Lt,{component:"a",href:o(e.partner.id),target:"_blank",rel:"noopener noreferrer",variant:"subtitle2",sx:{textDecoration:"underline"},noWrap:!0,children:e.partner?.name||"-"}):jsx(T,{variant:"body2",color:"text.primary",noWrap:!0,children:e.partner?.name||"-"})}),Bt=e=>jsx(L,{justifyContent:"center",height:1,children:jsx(T,{variant:"body2",color:"text.primary",children:h(e.total_value)})}),Pt=e=>jsx(L,{justifyContent:"center",height:1,children:e.negotiation_date?jsx(T,{variant:"body2",color:"text.primary",children:d$1(e.negotiation_date,"DD/MM/YYYY")}):"-"}),Rt=e=>jsx(L,{justifyContent:"center",height:1,children:e.status||"-"}),Ot=(e,o)=>jsx(Po,{children:jsxs(L,{gap:1,children:[jsxs(L,{children:[jsx(T,{variant:"body2",color:"text.secondary",children:"Pedido"}),jsx(T,{variant:"subtitle2",color:"text.primary",children:e.id})]}),jsxs(L,{children:[jsx(T,{variant:"body2",color:"text.secondary",children:"Cliente"}),jsx(T,{variant:"subtitle2",color:"primary.main",children:e.partner?.name||"-"})]}),jsxs(L,{direction:"row",alignItems:"center",gap:1,children:[jsxs(L,{flex:1,overflow:"hidden",children:[jsx(T,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Valor do pedido"}),jsx(T,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:h(e.total_value)})]}),jsx(be,{orientation:"vertical",flexItem:!0,sx:{borderStyle:"dashed",mx:3}}),jsxs(L,{flex:1,overflow:"hidden",children:[jsx(T,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Data"}),jsx(T,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:e.negotiation_date?d$1(e.negotiation_date,"DD/MM/YYYY"):"-"})]})]}),!o&&jsxs(L,{gap:.5,children:[jsx(T,{variant:"body2",color:"text.secondary",children:"Status"}),jsx(T,{variant:"subtitle2",color:"text.primary",children:e.status||"-"})]})]})},e.id),It=({open:e,onClose:o,title:t,viewMode:a,selectedYear:r,totalValue:i,periodLabel:l,suffix:n,rows:m,total:s,isLoading:f$1,isFetching:d,page:c,perPage:y,onSearch:S,onPaginationChange:g,buildPartnerLink:k,mobileItemSlot:x,hideStatus:p})=>{let D=b$1("down","sm"),h$1=jsxs(L,{gap:3,children:[jsxs(L,{direction:{xs:"column",sm:"row"},justifyContent:"space-between",gap:2,children:[jsxs(L,{minWidth:0,direction:"row",alignItems:"center",gap:3,flexWrap:"wrap",children:[jsxs(L,{children:[jsxs(T,{variant:"body2",color:"text.secondary",children:["Vendas ",n]}),jsx(T,{variant:"subtitle2",color:"text.primary",children:h(i)})]}),jsx(Bo,{orientation:"vertical",flexItem:!0}),jsxs(L,{children:[jsxs(T,{variant:"body2",color:"text.secondary",children:["Qtd. de pedidos ",n]}),jsx(T,{variant:"subtitle2",color:"text.primary",children:s})]})]}),jsx(a$3,{size:"small",placeholder:"Buscar",onSearch:S,trigger:"change",iconPosition:"start",sx:{minWidth:200}})]}),jsx(f,{title:"Pedidos",header:jsx(Fragment,{}),headerProps:{p:0},columns:[{field:"external_id",headerName:"Pedido",flex:1,renderCell:({row:v})=>Dt(v)},{field:"partner_name",headerName:"Cliente",flex:1,renderCell:({row:v})=>wt(v,k)},{field:"total_value",headerName:"Valor do pedido",flex:1,renderCell:({row:v})=>Bt(v)},{field:"created_at",headerName:"Data",flex:1,renderCell:({row:v})=>Pt(v)},...p?[]:[{field:"last_status",headerName:"Status",flex:1,renderCell:({row:v})=>Rt(v)}]],rows:m,rowCount:s,mobileRender:v=>x?x(v):Ot(v,p),loading:f$1,fetching:d,paginationModel:{page:c,pageSize:y},onPaginationChange:g,paginationMode:"server",disableRowSelectionOnClick:!0,disableColumnMenu:!0,containerProps:{height:400}})]}),M=jsx(Do,{title:t,viewMode:a,selectedYear:r,periodLabel:l});return D?jsx(a$4,{open:e,onClose:o,headerTitle:M,headerProps:{direction:"row-reverse",sx:{"& > :last-child":{minWidth:0,overflow:"hidden"}}},children:h$1}):jsx(a$5,{open:e,onClose:o,maxWidth:"lg",dialogTitle:M,dialogTitleProps:{sx:{flex:1,overflow:"hidden"}},fullWidth:!0,children:h$1})},zt=It;var Ye=(e,o)=>{let t=e.split("-");if(o==="DAILY"&&t.length===3){let l=`${t[0]}-${t[1]}-${t[2]}`;return {startDate:l,endDate:l}}let a=parseInt(t[0],10),r=parseInt(t[1],10),i=new Date(a,r,0).getDate();return {startDate:`${t[0]}-${t[1]}-01`,endDate:`${t[0]}-${t[1]}-${String(i).padStart(2,"0")}`}},Ge=(e,o)=>{let t=e.split("-"),a=parseInt(t[1],10)-1,r=b[a]??"";if(o==="DAILY"&&t.length===3){let i=parseInt(t[2],10);return `${r} - Dia ${i}`}return r},qe=e=>e==="MONTHLY"?"no m\xEAs":"no dia";var Vt=(e,o)=>{let{page:t,perPage:a,search:r,handlePaginationModelChange:i,handleSearch:l}=a$6(),{startDate:n,endDate:m}=useMemo(()=>Ye(e,o),[e,o]),s=useMemo(()=>Ge(e,o),[e,o]),f=qe(o),d=useMemo(()=>({page:t,perPage:a,...r?{search:r}:{},filter:{operator:"AND",groups:[{operator:"AND",conditionals:[{fieldName:"negotiationDate",conditional:"GREATER_THAN_OR_EQUAL",value:[`${n}T00:00:00`]},{fieldName:"negotiationDate",conditional:"LESS_THAN_OR_EQUAL",value:[`${m}T23:59:59`]}]}]}}),[m,t,a,r,n]),c=useCallback((y,S)=>{i({page:y,pageSize:S});},[i]);return {page:t,perPage:a,periodLabel:s,suffix:f,queryParams:d,handleSearch:l,handlePaginationChange:c}},Wt=Vt;var C={sales:"#22C55E",forecast:"#F59E0B",goal:"#212B36"};var Et=({x:e=0,y:o=0,width:t=0,height:a=0,index:r,activeBarIndex:i})=>i!==r?null:jsx("rect",{x:e-6,y:o,width:t+6*2,height:a+6,fill:C.sales,opacity:.16,rx:6}),we=Et;var $t=({active:e,payload:o,label:t,viewMode:a,hideGoal:r})=>{if(!e||!o?.length)return null;let i=a==="DAILY",l=o[0].payload,n=Number(l.realized)||0,m=Number(l.forecast)||0,s=Number(l.goal)||0,f=s>0?n/s*100:0,d=s>n?s-n:0,c=i?"no dia":"no m\xEAs",y=i?"di\xE1ria":"mensal",S=String(t),g=S.split("-");if(g.length>=2){let x=parseInt(g[1],10)-1,p=b[x];i&&g.length===3?S=`${parseInt(g[2],10)} de ${p} de ${g[0]}`:i||(S=`${p} de ${g[0]}`);}let k=[{name:`Realizado ${c}`,value:h(n),color:C.sales},{name:`Previsto ${c}`,value:h(m),color:C.forecast},...r?[]:[{name:`Meta ${y}`,value:h(s),color:C.goal},{name:"Atingimento",value:`${f.toFixed(0)}%`,color:"#00B8D9"},{name:`GAP ${c}`,value:h(d),color:"#FF5630"}]];return jsxs(a$8,{minWidth:{xs:"auto",sm:400},p:1,gap:1,children:[jsx(T,{variant:"body2",color:"text.secondary",children:S}),jsx(be,{}),jsx(L,{children:k.map((x,p)=>jsxs(L,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,"data-testid":`tooltip-item-${p}`,children:[jsxs(L,{direction:"row",alignItems:"center",gap:1,children:[jsx(L,{width:6,height:6,borderRadius:"50%",bgcolor:x.color}),jsx(T,{variant:"body2",noWrap:!0,children:x.name})]}),jsx(T,{variant:"body2",children:x.value})]},p))})]})},Pe=$t;var Jt=({data:e,visibleSeries:o,yDomain:t,yTicks:a,viewMode:r,activeBarIndex:i,onMouseMove:l,onMouseLeave:n,onBarClick:m,hideGoal:s})=>{let f=useCallback(d$1=>d(d$1),[]);return jsx(ResponsiveContainer,{width:"100%",height:350,children:jsxs(ComposedChart,{data:e,margin:{top:20,right:10,bottom:0,left:20},style:{cursor:"pointer"},onMouseMove:l,onMouseLeave:n,onClick:d=>{d?.activeTooltipIndex!=null&&m?.(Number(d.activeTooltipIndex));},children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:d$2}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:f,domain:t,ticks:a}),jsx(Tooltip,{content:jsx(Pe,{viewMode:r,hideGoal:s})}),jsx(Bar,{dataKey:"realized",fill:"transparent",isAnimationActive:!1,background:jsx(we,{activeBarIndex:i})}),o.goal&&jsx(Line,{dataKey:"goal",name:"Meta",stroke:C.goal,strokeWidth:2,strokeDasharray:"8 4",dot:!1,isAnimationActive:!1}),o.realized&&jsx(Line,{dataKey:"realized",name:"Vendas",stroke:C.sales,strokeWidth:2,dot:{fill:C.sales,r:4,strokeWidth:0},isAnimationActive:!1}),o.forecast&&jsx(Line,{dataKey:"forecast",name:"Previsto",stroke:C.forecast,strokeWidth:2,strokeDasharray:"6 3",dot:{fill:C.forecast,r:4,strokeWidth:0},isAnimationActive:!1})]})})},Ro=Jt;var sr=({data:e,visibleSeries:o,yDomain:t,yTicks:a,shouldRotateLabels:r,activeBarIndex:i,onMouseMove:l,onMouseLeave:n$1,onBarClick:m,viewMode:s,hideGoal:f})=>{let d$1=useMemo(()=>r?!1:{position:"top",fontSize:12,fill:"#212B36",formatter:c=>h(Number(c))},[r]);return jsx(ResponsiveContainer,{width:"100%",height:300,children:jsxs(ComposedChart,{data:e,margin:{top:20,right:10,bottom:r?-90:0,left:20},barCategoryGap:"20%",style:{cursor:"pointer"},onMouseMove:l,onMouseLeave:n$1,onClick:c=>{c?.activeTooltipIndex!=null&&m?.(Number(c.activeTooltipIndex));},children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,...r&&{interval:0,height:120},tick:r?jsx(n,{}):{fontSize:12,fill:"#637381"},tickFormatter:c}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:c=>d(c),domain:t,ticks:a}),jsx(Tooltip,{content:jsx(Pe,{viewMode:s,hideGoal:f})}),o.goal&&jsx(Line,{dataKey:"goal",name:"Meta",stroke:C.goal,strokeWidth:2,strokeDasharray:"8 4",dot:!1,isAnimationActive:!1}),o.realized&&jsx(Bar,{dataKey:"realized",name:"Vendas",fill:C.sales,maxBarSize:48,isAnimationActive:!1,radius:[4,4,0,0],background:jsx(we,{activeBarIndex:i}),label:d$1}),o.forecast&&jsx(Line,{dataKey:"forecast",name:"Previsto",stroke:C.forecast,strokeWidth:2,strokeDasharray:"6 3",dot:{fill:C.forecast,r:4,strokeWidth:0},isAnimationActive:!1})]})})},Io=sr;var mr=({data:e,viewMode:o,visibleSeries:t,yDomain:a,yTicks:r,formatYAxis:i,onBarClick:l,hideGoal:n})=>{let[m,s]=useState(null),[f,d]=useState(0),c=useRef(null),y=o==="MONTHLY",S=useMemo(()=>!y||f===0||e.length===0?!1:(f-60)/e.length<60,[f,e.length,y]),g=useCallback(()=>s(null),[]),k=useCallback(p=>{p?.activeTooltipIndex!=null&&s(Number(p.activeTooltipIndex));},[]),x=useCallback(p=>{c.current&&(c.current.disconnect(),c.current=null),p&&(d(p.clientWidth),c.current=new ResizeObserver(()=>d(p.clientWidth)),c.current.observe(p));},[]);return y?jsx(c$1,{ref:x,children:jsx(Io,{data:e,visibleSeries:t,yDomain:a,yTicks:r,formatYAxis:i,shouldRotateLabels:S,activeBarIndex:m,onMouseMove:k,onMouseLeave:g,onBarClick:l,viewMode:o,hideGoal:n})}):jsx(c$1,{ref:x,children:jsx(Ro,{data:e,visibleSeries:t,yDomain:a,yTicks:r,formatYAxis:i,viewMode:o,activeBarIndex:m,onMouseMove:k,onMouseLeave:g,onBarClick:l,hideGoal:n})})},Fo=mr;var fr=({visibleSeries:e,onToggleSerie:o,hideGoal:t})=>jsxs(L,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(Ze,{control:jsx(Je,{checked:e.realized,onChange:()=>o("realized"),sx:{"&.Mui-checked":{color:C.sales}}}),label:"Vendas"}),jsx(Ze,{control:jsx(Je,{checked:e.forecast,onChange:()=>o("forecast"),sx:{"&.Mui-checked":{color:C.forecast}}}),label:"Previsto"}),!t&&jsx(Ze,{control:jsx(Je,{checked:e.goal,onChange:()=>o("goal"),sx:{"&.Mui-checked":{color:C.goal}}}),label:"Meta"})]}),Ao=fr;var hr=({kpis:e,isMonthly:o,editGoalAction:t,hideGoal:a})=>{let r=b$1("down","md");return jsxs(L,{direction:{xs:"column",md:"row"},alignItems:{xs:"flex-start",md:"center"},flexWrap:"wrap",gap:3,children:[r&&jsx(be,{orientation:"horizontal",flexItem:!0,sx:{borderStyle:"dashed",mx:-3}}),jsxs(L,{children:[jsxs(T,{variant:"body2",color:"text.secondary",children:["Previsto no ",o?"ano":"m\xEAs"]}),jsx(T,{variant:"subtitle2",children:h(e?.forecast)})]}),jsx(be,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(L,{children:[jsxs(T,{variant:"body2",color:"text.secondary",children:["Realizado no ",o?"ano":"m\xEAs"]}),jsx(T,{variant:"subtitle2",children:h(e?.realized)})]}),!a&&jsx(be,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),!a&&jsxs(L,{children:[jsxs(L,{direction:"row",alignItems:"center",gap:3,children:[jsxs(T,{variant:"body2",color:"text.secondary",children:["Meta ",o?"anual":"mensal"]}),t]}),jsx(T,{variant:"subtitle2",children:h(e?.goal)})]}),!a&&jsx(be,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),!a&&jsxs(L,{children:[jsx(T,{variant:"body2",color:"text.secondary",children:"Atingimento"}),jsx(T,{variant:"subtitle2",children:c$2(e?.achievement??0,{maximumFractionDigits:2,minimumFractionDigits:2})})]}),!a&&jsx(be,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),!a&&jsxs(L,{children:[jsxs(L,{direction:"row",gap:.5,children:[jsxs(T,{variant:"body2",color:"text.secondary",children:["GAP do ",o?"ano":"m\xEAs"]}),jsx(a$7,{text:"Diferen\xE7a entre o valor realizado e a meta. Um GAP significa que as vendas ainda est\xE3o abaixo do objetivo definido para o per\xEDodo.",width:18,arrow:!0,sx:{mt:-.1}})]}),jsx(T,{variant:"subtitle2",children:h(e?.gap)})]})]})},je=hr;var vr=({data:e,isFetching:o,kpis:t,viewMode:a$3,selectedYear:r,editGoalAction:i,DetailComponent:l,hideGoal:n,emptyMessage:m$1})=>{let[s,f]=useState({realized:!0,forecast:!0,goal:!0}),[d$1,c]=useState(!1),[y,S]=useState(""),[g,k]=useState(0),x=a$3==="MONTHLY",p=useMemo(()=>m$1!=null&&e.every(w=>!Number(w.realized)),[e,m$1]),D=useMemo(()=>{if(!e.length)return [0,1];let w=e.flatMap(fe=>[Number(fe.realized)||0,Number(fe.forecast)||0,Number(fe.goal)||0]),V=Math.max(...w);return [0,V>0?V*1.15:1]},[e]),h=useMemo(()=>{let[,w]=D,V=w/6,fe=Array.from({length:7},(Kr,Ko)=>Math.round(V*Ko));return [...new Set(fe)]},[D]),M=useCallback(w=>{f(V=>({...V,[w]:!V[w]}));},[]),v=useCallback(w=>M(w),[M]),O=useCallback(w=>{let V=e[w];V&&(S(V.label),k(V.realized),c(!0));},[e]),me=useCallback(()=>{c(!1);},[]),de=useCallback(w=>d(w),[]);return jsxs(Fragment,{children:[jsxs(a,{children:[jsx(gt,{title:"Evolu\xE7\xE3o de vendas"}),jsx(yt,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(L,{gap:3,children:[jsx(L,{display:{xs:"none",md:"block"},children:jsx(je,{kpis:t,isMonthly:x,editGoalAction:i,hideGoal:n})}),p?jsx(m,{title:m$1,description:"Troque a origem do pedido ou o per\xEDodo selecionado."}):jsx(a$2,{active:o,children:jsx(Fo,{data:e,viewMode:a$3,visibleSeries:n?{...s,goal:!1}:s,yDomain:D,yTicks:h,formatYAxis:de,onBarClick:O,hideGoal:n})}),!p&&jsx(Ao,{visibleSeries:s,onToggleSerie:v,hideGoal:n}),jsx(L,{display:{xs:"block",md:"none"},children:jsx(je,{kpis:t,isMonthly:x,editGoalAction:i,hideGoal:n})})]})})})]}),y&&l&&jsx(l,{open:d$1,onClose:me,label:y,viewMode:a$3,selectedYear:r,totalValue:g})]})},br=vr;var se={realized:"#22C55E",forecast:"#F59E0B"};var xr=({x:e=0,y:o=0,width:t=0,height:a=0,index:r,activeBarIndex:i})=>i!==r?null:jsx("rect",{x:e-6,y:o,width:t+12,height:a+6,fill:"#919EAB",opacity:.16,rx:6}),Vo=xr;var kr=({x:e=0,y:o=0,width:t=0,height:a=0,index:r,activeBarIndex:i,bothRendered:l})=>i!==r?null:jsx("rect",{x:e-6,y:o,width:l?t*2+4+12:t+12,height:a+6,fill:"#919EAB",opacity:.16,rx:6}),Wo=kr;var Lr=({active:e,payload:o,label:t,viewMode:a})=>{if(!e||!o?.length)return null;let r=a==="DAILY",i=String(t),l=i.split("-");if(l.length>=2){let n=parseInt(l[1],10)-1,m=b[n];r&&l.length===3?i=`${parseInt(l[2],10)} de ${m} de ${l[0]}`:r||(i=`${m} de ${l[0]}`);}return jsxs(a$8,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(T,{variant:"body2",color:"text.secondary",children:i}),jsx(be,{}),jsx(L,{children:o.map((n,m)=>jsxs(L,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,"data-testid":`tooltip-item-${m}`,children:[jsxs(L,{direction:"row",alignItems:"center",gap:1,children:[jsx(L,{width:6,height:6,borderRadius:"50%",bgcolor:n.color}),jsx(T,{variant:"body2",noWrap:!0,children:n.name})]}),jsx(T,{variant:"body2",children:h(n.value)})]},n.name))})]})},Eo=Lr;var Ar=({data:e,viewMode:o,visibleSeries:t,activeBarIndex:a,onMouseMove:r,onMouseLeave:i})=>{let l=o==="MONTHLY",[n$1,m]=useState(0),s=useRef(null),f=useCallback(p=>{s.current&&(s.current.disconnect(),s.current=null),p&&(m(p.clientWidth),s.current=new ResizeObserver(()=>m(p.clientWidth)),s.current.observe(p));},[]),d$1=useMemo(()=>!l||n$1===0||e.length===0?!1:(n$1-60)/e.length<80,[l,n$1,e.length]),c$2=useMemo(()=>e.some(p=>p.realized_value>0),[e]),y=useMemo(()=>e.some(p=>p.forecast_value>0),[e]),S=useMemo(()=>{if(!e.length)return [0,1];let p=e.flatMap(h=>[h.realized_value,h.forecast_value]),D=Math.max(...p);return [0,D>0?D*1.15:1]},[e]),g=useMemo(()=>{let[,p]=S,D=p/6;return [...new Set(Array.from({length:7},(h,M)=>Math.round(D*M)))]},[S]),k=useMemo(()=>l?c:d$2,[l]),x=t.realized&&c$2&&t.forecast&&y;return jsx(c$1,{ref:f,children:jsx(ResponsiveContainer,{width:"100%",height:250,children:jsxs(BarChart,{data:e,margin:{top:20,right:10,bottom:d$1?-90:0,left:20},barCategoryGap:"20%",barGap:4,onMouseMove:r,onMouseLeave:i,children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,...d$1&&{interval:0,height:120},tick:d$1?jsx(n,{}):{fontSize:12,fill:"#637381"},tickFormatter:k}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:p=>d(p),domain:S,ticks:g}),jsx(Tooltip,{content:jsx(Eo,{viewMode:o}),cursor:!1}),t.realized&&c$2&&jsx(Bar,{dataKey:"realized_value",name:"Realizado",fill:se.realized,maxBarSize:32,isAnimationActive:!1,radius:[4,4,0,0],background:jsx(Wo,{activeBarIndex:a,bothRendered:x})}),t.forecast&&y&&jsx(Bar,{dataKey:"forecast_value",name:"Previsto",fill:se.forecast,maxBarSize:32,isAnimationActive:!1,radius:[4,4,0,0],...!t.realized&&{background:jsx(Vo,{activeBarIndex:a})}})]})})})},No=Ar;var Er=({visibleSeries:e,onToggleSerie:o})=>jsxs(L,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(Ze,{control:jsx(Je,{checked:e.realized,onChange:()=>o("realized"),sx:{"&.Mui-checked":{color:se.realized}}}),label:"Realizado"}),jsx(Ze,{control:jsx(Je,{checked:e.forecast,onChange:()=>o("forecast"),sx:{"&.Mui-checked":{color:se.forecast}}}),label:"Previsto"})]}),Go=Er;var Nr=({totalForecast:e,totalRealized:o,percentage:t,isMonthly:a})=>{let r=b$1("down","md");return jsxs(L,{direction:{xs:"column",md:"row"},alignItems:{xs:"flex-start",md:"center"},flexWrap:"wrap",gap:3,children:[r&&jsx(be,{orientation:"horizontal",flexItem:!0,sx:{borderStyle:"dashed",mx:-3}}),jsxs(L,{children:[jsx(T,{variant:"body2",color:"text.secondary",children:a?"Total previsto no ano":"Total previsto no m\xEAs"}),jsx(T,{variant:"subtitle2",children:h(e)})]}),jsx(be,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(L,{children:[jsx(T,{variant:"body2",color:"text.secondary",children:a?"Total realizado no ano":"Total realizado no m\xEAs"}),jsx(T,{variant:"subtitle2",children:h(o)})]}),jsx(be,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(L,{children:[jsx(T,{variant:"body2",color:"text.secondary",children:"Atingimento"}),jsxs(T,{variant:"subtitle2",children:[t,"%"]})]})]})},no=Nr;var qr=({data:e,viewMode:o,isFetching:t})=>{let a$3=o==="MONTHLY",[r,i]=useState({realized:!0,forecast:!0}),[l,n]=useState(null),m$1=useCallback(c=>{i(y=>({...y,[c]:!y[c]}));},[]),s=useCallback(c=>{c?.activeTooltipIndex!=null&&n(Number(c.activeTooltipIndex));},[]),f=useCallback(()=>n(null),[]),d=useMemo(()=>{let c=e.reduce((g,k)=>g+(k.realized_value??0),0),y=e.reduce((g,k)=>g+(k.forecast_value??0),0),S=y>0?Math.round(c/y*100):0;return {totalRealized:c,totalForecast:y,percentage:S}},[e]);return jsxs(a,{children:[jsx(gt,{title:"Previsto vs. Realizado (Positiva\xE7\xE3o)"}),jsx(yt,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(L,{gap:3,children:[jsx(L,{display:{xs:"none",md:"block"},children:jsx(no,{totalForecast:d.totalForecast,totalRealized:d.totalRealized,percentage:d.percentage,isMonthly:a$3})}),jsx(a$2,{active:t,children:jsx(No,{data:e,viewMode:o,visibleSeries:r,activeBarIndex:l,onMouseMove:s,onMouseLeave:f})}),jsx(Go,{visibleSeries:r,onToggleSerie:m$1}),jsx(L,{display:{xs:"block",md:"none"},children:jsx(no,{totalForecast:d.totalForecast,totalRealized:d.totalRealized,percentage:d.percentage,isMonthly:a$3})})]})})})]})},Hr=qr;
|
|
47
47
|
|
|
48
48
|
export { bt as OrdersByType, zt as OverviewDetail, br as SalesEvolution, Hr as SalesForecast, Ye as getDateRange, Ge as getPeriodLabel, qe as getPeriodSuffix, Wt as useOverviewDetailState };
|
|
49
49
|
//# sourceMappingURL=index.js.map
|
|
@@ -5,9 +5,9 @@ import { a as a$2 } from '../../../chunk-Q2R3X4EB.js';
|
|
|
5
5
|
import { a as a$9 } from '../../../chunk-DRGARBKB.js';
|
|
6
6
|
import { a as a$5 } from '../../../chunk-LTXQ3A3C.js';
|
|
7
7
|
import { a as a$4 } from '../../../chunk-4XN57SLB.js';
|
|
8
|
-
import { d as d$
|
|
8
|
+
import { d as d$1 } from '../../../chunk-2W5FGLTC.js';
|
|
9
9
|
import { h, d, a as a$7, c as c$1 } from '../../../chunk-OF6623HG.js';
|
|
10
|
-
import {
|
|
10
|
+
import { f } from '../../../chunk-U7DEJBXJ.js';
|
|
11
11
|
import { a as a$3 } from '../../../chunk-33LSXTPO.js';
|
|
12
12
|
import { a as a$1 } from '../../../chunk-4F2NKGF6.js';
|
|
13
13
|
import '../../../chunk-PRWQQJDL.js';
|
|
@@ -16,7 +16,7 @@ import '../../../chunk-5NLFXSCK.js';
|
|
|
16
16
|
import '../../../chunk-6U5LS7MP.js';
|
|
17
17
|
import '../../../chunk-JUAHRU5E.js';
|
|
18
18
|
import '../../../chunk-NIQW2J3M.js';
|
|
19
|
-
import '../../../chunk-
|
|
19
|
+
import '../../../chunk-43EX76EH.js';
|
|
20
20
|
import '../../../chunk-UVPQR2Q2.js';
|
|
21
21
|
import '../../../chunk-RBTYTONM.js';
|
|
22
22
|
import '../../../chunk-I4PPSW36.js';
|
|
@@ -42,7 +42,7 @@ import { memo, useState, useRef, useCallback, useMemo } from 'react';
|
|
|
42
42
|
import Po from '@mui/material/Slider';
|
|
43
43
|
import Ro from '@mui/material/Button';
|
|
44
44
|
|
|
45
|
-
var tr=styled(S)(({theme:e})=>({position:"relative",alignSelf:"flex-start",flexShrink:0,"& .recharts-wrapper, & .recharts-wrapper *":{outline:"none !important",boxShadow:"none !important"},"& .recharts-pie-sector":{cursor:"pointer"},[e.breakpoints.down("md")]:{alignSelf:"center"}}));var or=e=>c$1(e,{maximumFractionDigits:2,...e>0&&e<100?{minimumFractionDigits:2}:{}}),jr=({active:e,payload:r,total:o})=>{if(!e||!r?.length)return null;let t=r[0];return jsxs(a$9,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:t.name}),jsx(Jr,{}),jsxs(S,{children:[jsxs(S,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(S,{direction:"row",alignItems:"center",gap:1,children:[jsx(S,{width:6,height:6,borderRadius:"50%",bgcolor:t.payload.fill}),jsx(b$2,{variant:"body2",noWrap:!0,children:t.name})]}),jsxs(b$2,{variant:"body2",noWrap:!0,children:[or(t.payload.percentage)," (",t.value,")"]})]}),jsxs(S,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(S,{direction:"row",alignItems:"center",gap:1,children:[jsx(S,{width:6,height:6,borderRadius:"50%",bgcolor:"#919EAB"}),jsx(b$2,{variant:"body2",noWrap:!0,children:"Total"})]}),jsxs(b$2,{variant:"body2",noWrap:!0,children:[or(100)," (",o,")"]})]})]})]})},ar=jr;var at=({chartData:e,total:r,isEmptyData:o,onPieClick:t,clickable:a})=>jsx(tr,{children:jsx(ResponsiveContainer,{width:200,height:200,children:jsxs(PieChart,{children:[jsx(Pie,{data:e,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:60,outerRadius:90,paddingAngle:2,strokeWidth:0,isAnimationActive:!1,onClick:t,cursor:a?"pointer":void 0}),jsx("text",{x:"50%",y:"46%",textAnchor:"middle",dominantBaseline:"middle",style:{fontSize:24,fontWeight:700},children:a$7(r)}),jsx("text",{x:"50%",y:"58%",textAnchor:"middle",dominantBaseline:"middle",style:{fontSize:12,fill:"#919EAB"},children:"clientes"}),!o&&jsx(Tooltip,{content:jsx(ar,{total:r})})]})})}),nr=at;var st=({items:e,hiddenKeys:r,onToggle:o,onItemClick:t})=>jsx(S,{width:"100%",justifyContent:"center",children:e.map(a=>jsxs(S,{display:"grid",gridTemplateColumns:"1fr auto auto",alignItems:"center",gap:1.5,onClick:()=>t?.(a.key,a.label),sx:{...t?{cursor:"pointer"}:{}},children:[jsx(Wr,{label:a.label,onClick:i=>i.stopPropagation(),control:jsx(_r,{size:"small",checked:!r.has(a.key),onChange:(i,n)=>o(a.key,n),sx:{"&.Mui-checked":{color:a.color}}}),sx:{"& .MuiFormControlLabel-label":{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}}}),jsx(b$2,{variant:"body2",color:"text.secondary",textAlign:"right",noWrap:!0,children:c$1(a.percentage,{maximumFractionDigits:2,...a.percentage>0&&a.percentage<100?{minimumFractionDigits:2}:{}})}),jsx(b$2,{variant:"subtitle2",color:"text.primary",textAlign:"right",noWrap:!0,children:d(a.count)})]},a.key))}),sr=st;var ft=({title:e,isFetching:r,chartData:o,total:t,isEmptyData:a$1,legendItems:i,hiddenKeys:n,onToggle:d,onPieClick:m,onItemClick:h})=>jsxs(a,{children:[jsx(dt,{title:e}),jsx(mt,{children:jsxs(S,{direction:{xs:"column",sm:"row"},alignItems:"center",gap:1.5,minWidth:0,children:[jsx(a$2,{active:r,children:jsx(nr,{chartData:o,total:t,isEmptyData:a$1,onPieClick:m,clickable:!!m})}),jsx(sr,{items:i,hiddenKeys:n,onToggle:d,onItemClick:h})]})})]}),gt=ft;var mr=Math.PI/180,dr=22,ht=2,ut=e=>{let{cx:r,cy:o,midAngle:t,outerRadius:a,percentage:i}=e;if(i<ht)return null;let n=Number(r),d=Number(o),m=Number(a),h=Number(t);if(isNaN(n)||isNaN(d)||isNaN(m))return null;let x=Math.sin(-h*mr),P=Math.cos(-h*mr),v=n+m*P,C=d+m*x,k=n+(m+dr*.5)*P,l=d+(m+dr*.5)*x,s=P>=0?1:-1,u=k+s*10,c=l,g=c$1(i,{maximumFractionDigits:1,...i>0&&i<100?{minimumFractionDigits:1}:{}}),T=g.length*7+10,_=s===1?u+2:u-T-2;return jsxs("g",{children:[jsx("path",{d:`M${v},${C} L${k},${l} L${u},${c}`,stroke:"#637381",fill:"none",strokeWidth:1}),jsx("rect",{x:_,y:c-10,width:T,height:20,rx:4,fill:"#212B36"}),jsx("text",{x:_+T/2,y:c,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fontWeight:600,fill:"#FFFFFF",children:g})]})},cr=ut;var fr=styled(S)({position:"relative",alignItems:"center",justifyContent:"center","& .recharts-wrapper, & .recharts-wrapper *":{outline:"none !important",boxShadow:"none !important"},"& .recharts-wrapper":{overflow:"visible !important"},"& .recharts-wrapper svg":{overflow:"visible"},"& .recharts-pie-sector":{cursor:"pointer"}});var gr=e=>c$1(e,{maximumFractionDigits:2,...e>0&&e<100?{minimumFractionDigits:2}:{}}),xt=({active:e,payload:r,total:o})=>{if(!e||!r?.length)return null;let t=r[0];return jsxs(a$9,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:t.name}),jsx(Jr,{}),jsxs(S,{children:[jsxs(S,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(S,{direction:"row",alignItems:"center",gap:1,children:[jsx(S,{width:6,height:6,borderRadius:"50%",bgcolor:t.payload.fill}),jsx(b$2,{variant:"body2",noWrap:!0,children:t.name})]}),jsxs(b$2,{variant:"body2",noWrap:!0,children:[gr(t.payload.percentage)," (",t.value,")"]})]}),jsxs(S,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(S,{direction:"row",alignItems:"center",gap:1,children:[jsx(S,{width:6,height:6,borderRadius:"50%",bgcolor:"#919EAB"}),jsx(b$2,{variant:"body2",noWrap:!0,children:"Total"})]}),jsxs(b$2,{variant:"body2",noWrap:!0,children:[gr(100)," (",o,")"]})]})]})]})},hr=xt;var Rt=e=>jsx(cr,{...e}),wt=({chartData:e,total:r,isEmptyData:o,onPieClick:t})=>jsx(fr,{children:jsx(ResponsiveContainer,{width:280,height:280,children:jsxs(PieChart,{children:[jsx(Pie,{data:e,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:90,paddingAngle:1,strokeWidth:0,isAnimationActive:!1,label:o?!1:Rt,labelLine:!1,onClick:t,cursor:t?"pointer":void 0}),!o&&jsx(Tooltip,{content:jsx(hr,{total:r})})]})})}),ur=wt;var At=e=>c$1(e,{maximumFractionDigits:2,...e>0&&e<100?{minimumFractionDigits:2}:{}}),_t=({items:e,hiddenKeys:r,onToggle:o,onItemClick:t})=>jsx(a$8,{sx:{maxHeight:280,width:"100%",pl:.5},children:e.map(a=>jsxs(S,{display:"grid",gridTemplateColumns:"1fr auto auto",alignItems:"center",gap:1.5,onClick:()=>t?.(a.key),sx:t?{cursor:"pointer"}:void 0,children:[jsx(Wr,{label:a.label,onClick:i=>i.stopPropagation(),control:jsx(_r,{size:"small",checked:!r.has(a.key),onChange:(i,n)=>o(a.key,n),sx:{"&.Mui-checked":{color:a.color}}}),sx:{"& .MuiFormControlLabel-label":{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}}}),jsx(b$2,{variant:"body2",color:"text.secondary",textAlign:"right",noWrap:!0,children:At(a.percentage)}),jsx(b$2,{variant:"subtitle2",color:"text.primary",textAlign:"right",noWrap:!0,children:d(a.count)})]},a.key))}),br=_t;var Nt=({data:e,isFetching:r,chartData:o,total:t,isEmptyData:a$3,onPieClick:i,onLegendClick:n,hiddenKeys:d,onToggle:m$1})=>jsxs(a,{children:[jsx(dt,{title:"Clientes por segmentos"}),jsx(mt,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(S,{alignItems:"center",gap:2,children:[jsx(a$2,{active:r,children:jsx(ur,{chartData:o,total:t,isEmptyData:a$3,onPieClick:i})}),jsx(br,{items:e,hiddenKeys:d,onToggle:m$1,onItemClick:n})]})})})]}),Kt=Nt;var Ot=["#FF5630","#FFAB00","#22C55E","#C4CDD5","#8E33FF","#00B8D9","#3366FF","#FF6C40","#36B37E","#B76E00"],Vt=12;var Ht=({title:e,label:r})=>jsxs(S,{width:"100%",minWidth:0,overflow:"hidden",children:[jsx(b$2,{variant:"subtitle1",noWrap:!0,children:e}),jsx(b$2,{variant:"body2",color:"text.secondary",noWrap:!0,children:r})]}),vr=Ht;var $t=({open:e,onClose:r,title:o,label:t,columns:a,rows:i,totalPartners:n,isLoading:d,isFetching:m,isFetchingNextPage:h,onSearch:x,onRowsScrollEnd:P,sellerName:v,buildSellerLink:C,sellerExternalId:k,mobileRender:l})=>{let s=b("down","sm"),u=jsxs(S,{gap:3,children:[jsxs(S,{direction:{xs:"column",sm:"row"},justifyContent:"space-between",alignItems:{sm:"center"},gap:3,children:[jsxs(S,{direction:"row",alignItems:"center",gap:3,flexWrap:"wrap",children:[v&&k&&jsxs(Fragment,{children:[C?jsx(Xt,{component:"a",href:C(k),target:"_blank",rel:"noopener noreferrer",variant:"subtitle2",sx:{textDecoration:"underline"},noWrap:!0,children:v}):jsx(b$2,{variant:"subtitle2",noWrap:!0,children:v}),jsx(Jr,{orientation:"vertical",flexItem:!0})]}),jsxs(S,{children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:"Total de clientes:"}),jsx(b$2,{variant:"subtitle2",color:"text.primary",children:n})]})]}),jsx(a$3,{size:"small",placeholder:"Buscar",onSearch:x,trigger:"change",iconPosition:"start",sx:{minWidth:200}})]}),jsx(d$1,{title:"Clientes",header:jsx(Fragment,{}),headerProps:{p:0},columns:a,rows:i,getRowId:g=>g.external_id,mobileRender:l,loading:d,fetching:m&&!h,fetchingNextPage:h,onRowsScrollEnd:P,scrollEndThreshold:600,disableRowSelectionOnClick:!0,disableColumnMenu:!0,containerProps:{height:400}})]}),c=jsx(vr,{title:o,label:t});return s?jsx(a$4,{open:e,onClose:r,headerTitle:c,headerProps:{direction:"row-reverse",sx:{"& > :last-child":{minWidth:0,overflow:"hidden"}}},children:u}):jsx(a$5,{open:e,onClose:r,maxWidth:"lg",dialogTitle:c,dialogTitleProps:{sx:{flex:1,overflow:"hidden"}},fullWidth:!0,children:u})},Qt=$t;var qt=({profileName:e})=>jsxs(S,{width:"100%",minWidth:0,overflow:"hidden",children:[jsx(b$2,{variant:"subtitle1",noWrap:!0,children:"Clientes por perfil"}),jsx(b$2,{variant:"body2",color:"text.secondary",noWrap:!0,children:e})]}),Rr=qt;var Jt=({open:e,onClose:r,profileName:o,columns:t,rows:a,totalPartners:i,isLoading:n,isFetching:d,isFetchingNextPage:m,onSearch:h,onRowsScrollEnd:x,mobileRender:P})=>{let v=b("down","sm"),C=jsxs(S,{gap:3,children:[jsxs(S,{direction:{xs:"column",sm:"row"},justifyContent:"space-between",alignItems:{sm:"center"},gap:2,children:[jsx(S,{direction:"row",alignItems:"center",gap:3,flexWrap:"wrap",children:jsxs(S,{children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:"Total de clientes:"}),jsx(b$2,{variant:"subtitle2",color:"text.primary",children:i})]})}),jsx(a$3,{size:"small",placeholder:"Buscar",onSearch:h,trigger:"change",iconPosition:"start",sx:{minWidth:200}})]}),jsx(d$1,{title:"Clientes",header:jsx(Fragment,{}),headerProps:{p:0},columns:t,rows:a,getRowId:l=>l.external_id,mobileRender:P,loading:n,fetching:d&&!m,fetchingNextPage:m,onRowsScrollEnd:x,scrollEndThreshold:600,disableRowSelectionOnClick:!0,disableColumnMenu:!0,containerProps:{height:400}})]}),k=jsx(Rr,{profileName:o});return v?jsx(a$4,{open:e,onClose:r,headerTitle:k,headerProps:{direction:"row-reverse",sx:{"& > :last-child":{minWidth:0,overflow:"hidden"}}},children:C}):jsx(a$5,{open:e,onClose:r,maxWidth:"lg",dialogTitle:k,dialogTitleProps:{sx:{flex:1,overflow:"hidden"}},fullWidth:!0,children:C})},jt=Jt;var J="#212B36",ro={["SALE_TOTAL_VALUE"]:{label:"Por valor total",color:"#22C55E",dataKey:"total_sale_value",barName:"Valor total por cliente",averageName:"M\xE9dia total de valor por cliente",averageDataKey:"average_total_value",formatLabel:h,formatYAxis:d},["SALE_COUNT"]:{label:"Por pedidos",color:"#C684FF",dataKey:"total_value_by_customer",barName:"Quantidade de pedidos",averageName:"Quantidade total de pedidos",averageDataKey:"average_sale_count",formatLabel:String,formatYAxis:d,floorAverage:!0},["SALE_AVERAGE_VALUE"]:{label:"Por ticket m\xE9dio",color:"#00B8D9",dataKey:"total_sale_value",barName:"Ticket m\xE9dio por cliente",averageName:"M\xE9dia do ticket m\xE9dio",averageDataKey:"average_ticket",formatLabel:h,formatYAxis:d}};var to=({x:e=0,y:r=0,width:o=0,height:t=0,index:a=0,activeBarIndex:i,color:n,data:d,onBarClick:m})=>i!==a?null:jsx("rect",{x:e-6,y:r,width:o+12,height:t+6,fill:n,opacity:.16,rx:6,style:{cursor:"pointer"},onClick:()=>m(d[a])}),Dr=to;var no=({active:e,payload:r,label:o,config:t,average:a})=>!e||!r?.length?null:jsxs(a$9,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:o}),jsx(Jr,{}),jsxs(S,{children:[r.map((i,n)=>jsxs(S,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,"data-testid":`tooltip-item-${n}`,children:[jsxs(S,{direction:"row",alignItems:"center",gap:1,children:[jsx(S,{width:6,height:6,borderRadius:"50%",bgcolor:i.color}),jsx(b$2,{variant:"body2",noWrap:!0,children:t.barName})]}),jsx(b$2,{variant:"body2",children:t.formatLabel(i.value)})]},i.dataKey)),jsxs(S,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(S,{direction:"row",alignItems:"center",gap:1,children:[jsx(S,{width:6,height:6,borderRadius:"50%",bgcolor:J}),jsx(b$2,{variant:"body2",noWrap:!0,children:t.averageName})]}),jsx(b$2,{variant:"body2",children:t.formatLabel(a)})]})]})]}),Ir=no;var go=48,ho=go/.8,uo=({data:e,config:r,visibleSeries:o,average:t,activeBarIndex:a,activeCoordX:i,shouldRotateLabels:n$1,onMouseMove:d$1,onMouseLeave:m,onBarClick:h})=>{let x=useMemo(()=>{if(!e.length)return [0,1];let s=e.map(c=>c[r.dataKey]||0);o.average&&t>0&&s.push(t);let u=Math.max(...s);return [0,u>0?u*1.15:1]},[e,r.dataKey,t,o.average]),P=useMemo(()=>{let[,s]=x,u=s/6;return [...new Set(Array.from({length:7},(c,g)=>Math.round(u*g)))]},[x]),v=useMemo(()=>n$1?!1:{position:"top",fontSize:11,fill:"#212B36",formatter:s=>r.formatLabel(Number(s))},[n$1,r]),C=useMemo(()=>jsx(Ir,{config:r,average:t}),[r,t]),k=useCallback(s=>n$1?jsx(n,{...s}):jsx(b$3,{x:s.x,y:s.y,payload:s.payload,slotWidth:ho}),[n$1]),l=useCallback(s=>{s&&h(s);},[h]);return jsx(c,{children:jsx(ResponsiveContainer,{width:"100%",height:350,children:jsxs(ComposedChart,{data:e,margin:{top:20,right:10,bottom:0,left:20},barCategoryGap:"20%",onMouseMove:d$1,onMouseLeave:m,children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"partner_name",axisLine:!1,tickLine:!1,interval:0,height:n$1?70:50,tick:k}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:s=>d(s),domain:x,ticks:P}),jsx(Tooltip,{content:C}),o.average&&t>0&&jsx(ReferenceLine,{y:t,stroke:J,strokeDasharray:"8 4",strokeWidth:2,ifOverflow:"extendDomain"}),o.average&&t>0&&jsx(ReferenceLine,{y:t,stroke:"none",ifOverflow:"extendDomain",label:jsx(a$6,{activeCoordX:i,referenceCircleColor:J,activeIndex:a})}),o.bar&&jsx(Bar,{dataKey:r.dataKey,name:r.barName,fill:r.color,maxBarSize:48,isAnimationActive:!1,radius:[4,4,0,0],cursor:"pointer",onClick:l,background:jsx(Dr,{activeBarIndex:a,color:r.color,data:e,onBarClick:h}),label:v})]})})})},Ar=uo;var Co=({visibleSeries:e,config:r,onToggleSerie:o})=>jsxs(S,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(Wr,{control:jsx(_r,{checked:e.bar,onChange:()=>o("bar"),sx:{"&.Mui-checked":{color:r.color}}}),label:r.barName}),jsx(Wr,{control:jsx(_r,{checked:e.average,onChange:()=>o("average"),sx:{"&.Mui-checked":{color:J}}}),label:r.averageName})]}),Mr=Co;var Nr=memo(({data:e,config:r,average:o,isFetching:t,onBarClick:a$3,children:i})=>{let n=b("down","sm"),d=b("down","lg"),[m$1,h]=useState({bar:!0,average:!0}),[x,P]=useState(12),[v,C]=useState(null),[k,l]=useState(null),[s,u]=useState(0),c=useRef(null),g=useCallback(f=>{c.current&&(c.current.disconnect(),c.current=null),f&&(u(f.clientWidth),c.current=new ResizeObserver(()=>u(f.clientWidth)),c.current.observe(f));},[]),T=useMemo(()=>[...e].sort((f,D)=>D[r.dataKey]-f[r.dataKey]),[e,r.dataKey]),_=T.length,M=useMemo(()=>n?10:d?25:30,[n,d]),Ne=!n&&_>10,he=Math.min(_,M),ue=Math.min(n?_:x,_,M),$=useMemo(()=>T.slice(0,ue),[T,ue]),Ke=useMemo(()=>s===0||$.length===0?!1:(s-60)/$.length<80,[s,$.length]),Oe=useCallback(f=>{h(D=>({...D,[f]:!D[f]}));},[]),Ve=useCallback(f=>{f?.activeTooltipIndex!=null&&C(Number(f.activeTooltipIndex)),f?.activeCoordinate?.x!=null&&l(f.activeCoordinate.x);},[]),Ge=useCallback(()=>{C(null),l(null);},[]),He=useCallback(f=>{f&&a$3?.(f);},[a$3]),y=useCallback((f,D)=>{P(D);},[]);return jsxs(a,{children:[jsx(b$1,{title:"Ranking de clientes",action:i}),jsx(mt,{children:jsx(a$1,{isEmpty:$.length===0,empty:jsx(m,{}),children:jsxs(S,{alignItems:"center",gap:1.5,children:[jsx(S,{width:"100%",ref:g,children:jsx(a$2,{active:t,children:jsx(Ar,{data:$,config:r,visibleSeries:m$1,average:o,activeBarIndex:v,activeCoordX:k,shouldRotateLabels:Ke,onMouseMove:Ve,onMouseLeave:Ge,onBarClick:He})})}),jsx(Mr,{visibleSeries:m$1,config:r,onToggleSerie:Oe}),Ne&&jsx(Po,{size:"small",min:10,max:he,value:ue,valueLabelDisplay:"auto",onChange:y})]})})})]})});Nr.displayName="Ranking";var To=Nr;var Do=styled(Ro,{shouldForwardProp:e=>e!=="active"})(({theme:e,active:r})=>({justifyContent:"flex-start",color:r?e.palette.primary.main:e.palette.text.secondary,fontWeight:r?800:400,"&:hover":{background:e.palette.action.hover}}));var Io=({rankingLabel:e,partnerName:r})=>jsxs(S,{width:"100%",minWidth:0,overflow:"hidden",children:[jsx(b$2,{variant:"subtitle1",noWrap:!0,children:"Detalhes do relat\xF3rio"}),jsxs(S,{direction:"row",alignItems:"center",columnGap:1.5,rowGap:0,flexWrap:"wrap",children:[jsx(b$2,{variant:"body2",color:"text.secondary",flexShrink:0,children:"Top clientes"}),"\u2022",jsxs(b$2,{variant:"body2",flexShrink:0,children:['Por "',e,'"']}),"\u2022",jsx(b$2,{variant:"body2",color:"text.secondary",noWrap:!0,children:r})]})]}),Or=Io;var Ee=styled(Jr)(()=>({height:30,alignSelf:"center",borderStyle:"dashed"})),Gr=styled(S)(({theme:e})=>({position:"relative",display:"flex",flexDirection:"column",padding:e.spacing(2),gap:e.spacing(1),color:e.palette.text.primary,"& a":{textDecoration:"none"},"&+div":{borderTop:`1px dashed ${alpha(e.palette.grey[500],.2)}`}}));var Mo=e=>jsx(S,{justifyContent:"center",height:1,children:jsx(b$2,{variant:"body2",color:"text.primary",children:e.id})}),Eo=(e,r)=>jsx(S,{justifyContent:"center",height:1,children:e?.partner?.id&&r?jsx(Xt,{component:"a",href:r(e.partner.id),target:"_blank",rel:"noopener noreferrer",variant:"subtitle2",sx:{textDecoration:"underline"},noWrap:!0,children:e.partner?.name||"-"}):jsx(b$2,{variant:"body2",color:"text.primary",noWrap:!0,children:e.partner?.name||"-"})}),Fo=e=>jsx(S,{justifyContent:"center",height:1,children:jsx(b$2,{variant:"body2",color:"text.primary",children:h(e.total_value)})}),No=e=>jsx(S,{justifyContent:"center",height:1,children:e.negotiation_date?jsx(b$2,{variant:"body2",color:"text.primary",children:d$2(e.negotiation_date,"DD/MM/YYYY")}):"-"}),Ko=e=>jsx(S,{justifyContent:"center",height:1,children:e.status||"-"}),Oo=e=>jsx(Gr,{children:jsxs(S,{gap:1,children:[jsxs(S,{children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:"Pedido"}),jsx(b$2,{variant:"subtitle2",color:"text.primary",children:e.id})]}),jsxs(S,{children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:"Cliente"}),jsx(b$2,{variant:"subtitle2",color:"primary.main",children:e.partner?.name||"-"})]}),jsxs(S,{direction:"row",alignItems:"center",gap:1,children:[jsxs(S,{flex:1,overflow:"hidden",children:[jsx(b$2,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Valor do pedido"}),jsx(b$2,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:h(e.total_value)})]}),jsx(Jr,{orientation:"vertical",flexItem:!0,sx:{borderStyle:"dashed",mx:3}}),jsxs(S,{flex:1,overflow:"hidden",children:[jsx(b$2,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Data"}),jsx(b$2,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:e.negotiation_date?d$2(e.negotiation_date,"DD/MM/YYYY"):"-"})]})]}),jsxs(S,{gap:.5,children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:"Status"}),jsx(b$2,{variant:"subtitle2",color:"text.primary",children:e.status||"-"})]})]})},e.id),Vo=({open:e,onClose:r,partnerName:o,rankingLabel:t,rows:a,total:i,totalValue:n,averageTicket:d,isLoading:m,isFetching:h$1,page:x,perPage:P,onSearch:v,onPaginationChange:C,buildPartnerLink:k,mobileItemSlot:l})=>{let s=b("down","sm"),u=jsxs(S,{gap:3,children:[jsxs(S,{direction:{xs:"column",sm:"row"},justifyContent:"space-between",gap:2,children:[jsxs(S,{minWidth:0,direction:"row",alignItems:"center",gap:3,flexWrap:"wrap",children:[jsx(b$2,{variant:"subtitle2",noWrap:!0,children:o}),jsx(Ee,{orientation:"vertical",flexItem:!0}),jsxs(S,{children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:"Qtd. de pedidos"}),jsx(b$2,{variant:"subtitle2",color:"text.primary",children:i})]}),jsx(Ee,{orientation:"vertical",flexItem:!0}),jsxs(S,{children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:"Valor em pedidos"}),jsx(b$2,{variant:"subtitle2",color:"text.primary",children:h(n)})]}),jsx(Ee,{orientation:"vertical",flexItem:!0}),jsxs(S,{children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:"Ticket m\xE9dio"}),jsx(b$2,{variant:"subtitle2",color:"text.primary",children:h(d)})]})]}),jsx(a$3,{size:"small",placeholder:"Buscar",onSearch:v,trigger:"change",iconPosition:"start",sx:{minWidth:200}})]}),jsx(d$1,{title:"Pedidos",header:jsx(Fragment,{}),headerProps:{p:0},columns:[{field:"external_id",headerName:"Pedido",flex:1,renderCell:({row:g})=>Mo(g)},{field:"partner_name",headerName:"Cliente",flex:1,renderCell:({row:g})=>Eo(g,k)},{field:"total_value",headerName:"Valor do pedido",flex:1,renderCell:({row:g})=>Fo(g)},{field:"created_at",headerName:"Data",flex:1,renderCell:({row:g})=>No(g)},{field:"last_status",headerName:"Status",flex:1,renderCell:({row:g})=>Ko(g)}],rows:a,rowCount:i,mobileRender:g=>l?l(g):Oo(g),loading:m,fetching:h$1,paginationModel:{page:x,pageSize:P},onPaginationChange:C,paginationMode:"server",disableRowSelectionOnClick:!0,disableColumnMenu:!0,containerProps:{height:400}})]}),c=jsx(Or,{rankingLabel:t,partnerName:o});return s?jsx(a$4,{open:e,onClose:r,headerTitle:c,headerProps:{direction:"row-reverse",sx:{"& > :last-child":{minWidth:0,overflow:"hidden"}}},children:u}):jsx(a$5,{open:e,onClose:r,maxWidth:"lg",dialogTitle:c,dialogTitleProps:{sx:{flex:1,overflow:"hidden"}},fullWidth:!0,children:u})},Go=Vo;var zo=({x:e=0,y:r=0,width:o=0,height:t=0,index:a=0,activeBarIndex:i,data:n,onBarClick:d})=>{if(i!==a)return null;let m=n[a];return jsx("rect",{x:e-6,y:r,width:o+12,height:t+6,fill:"#919EAB",opacity:.16,rx:6,style:{cursor:"pointer"},onClick:()=>{m&&d(String(m.seller_external_id),String(m.seller_name));}})},Hr=zo;var zr=e=>c$1(e,{maximumFractionDigits:2,...e>0&&e<100?{minimumFractionDigits:2}:{}}),$o=({active:e,payload:r,label:o,config:t})=>{if(!e||!r?.length)return null;let a=r.filter(n=>n.value!=null&&n.value>0),i=a.reduce((n,d)=>n+d.value,0);return jsxs(a$9,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:o}),jsx(Jr,{}),jsxs(S,{children:[a.map(n=>{let d=t.series.find(h=>h.dataKey===n.dataKey),m=i>0?zr(n.value/i*100):"0%";return jsxs(S,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(S,{direction:"row",alignItems:"center",gap:1,children:[jsx(S,{width:6,height:6,borderRadius:"50%",bgcolor:n.color}),jsx(b$2,{variant:"body2",noWrap:!0,children:d?.name??n.dataKey})]}),jsxs(b$2,{variant:"body2",noWrap:!0,children:[m," (",n.value,")"]})]},n.dataKey)}),jsxs(S,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(S,{direction:"row",alignItems:"center",gap:1,children:[jsx(S,{width:6,height:6,borderRadius:"50%",bgcolor:"#919EAB"}),jsx(b$2,{variant:"body2",noWrap:!0,children:"Total"})]}),jsxs(b$2,{variant:"body2",noWrap:!0,children:[zr(100)," (",i,")"]})]})]})]})},Yr=$o;var ra=48,ta=ra/.8,oa=({data:e,config:r,visibleSeries:o,hiddenKeys:t,activeBarIndex:a,shouldRotateLabels:i,onMouseMove:n$1,onMouseLeave:d$1,onBarClick:m})=>{let h=useMemo(()=>{if(!e.length)return [0,1];let l=Math.max(...e.map(s=>s._visibleTotal));return [0,l>0?l*1.15:1]},[e]),x=useMemo(()=>{let[,l]=h,s=l/6;return [...new Set(Array.from({length:7},(u,c)=>Math.round(s*c)))]},[h]),P=useMemo(()=>jsx(Yr,{config:r}),[r]),v=useCallback(l=>i?jsx(n,{...l}):jsx(b$3,{x:l.x,y:l.y,payload:l.payload,slotWidth:ta}),[i]),C=useCallback(l=>{if(!l)return;let s=l.payload;s&&m(String(s.seller_external_id),String(s.seller_name));},[m]),k=useCallback(l=>{let{x:s,y:u,width:c,index:g}=l,T=e[g]?._visibleTotal;return T?jsx("text",{x:s+c/2,y:u-6,textAnchor:"middle",fontSize:11,fill:"#212B36",children:T}):jsx(Fragment,{})},[e]);return jsx(c,{children:jsx(ResponsiveContainer,{width:"100%",height:350,children:jsxs(BarChart,{data:e,margin:{top:20,right:10,bottom:0,left:20},barCategoryGap:"20%",onMouseMove:n$1,onMouseLeave:d$1,children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"seller_name",axisLine:!1,tickLine:!1,interval:0,height:i?70:50,tick:v}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:l=>d(l),domain:h,ticks:x}),jsx(Tooltip,{content:P,cursor:!1}),r.series.map(l=>{let s=!t.has(l.dataKey),u=o[0],c=o[o.length-1],g=s&&l.dataKey===u?.dataKey,T=s&&l.dataKey===c?.dataKey;return jsx(Bar,{dataKey:s?l.dataKey:`_hidden_${l.dataKey}`,name:l.name,fill:l.color,stackId:"stack",maxBarSize:48,isAnimationActive:!1,cursor:"pointer",hide:!s,onClick:C,...g&&{background:jsx(Hr,{activeBarIndex:a,data:e,onBarClick:m})},...T&&{radius:[4,4,0,0]},...T&&!i&&{label:{position:"top",fontSize:11,fill:"#212B36",content:k}}},l.dataKey)})]})})})},Xr=oa;var pa=({series:e,hiddenKeys:r,onToggleSerie:o})=>jsx(S,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:e.map(t=>jsx(Wr,{control:jsx(_r,{checked:!r.has(t.dataKey),onChange:()=>o(t.dataKey),sx:{"&.Mui-checked":{color:t.color}}}),label:t.name},t.dataKey))}),$r=pa;var fa=({data:e,isFetching:r,config:o,onBarClick:t,children:a$3})=>{let i=b("down","sm"),n=b("down","lg"),[d,m$1]=useState(new Set),[h,x]=useState(12),[P,v]=useState(null),[C,k]=useState(0),l=useRef(null),s=useMemo(()=>[...e].sort((y,f)=>f._total-y._total),[e]),u=useMemo(()=>i?10:n?25:30,[n,i]),c=s.length,g=!i&&c>10,T=Math.min(c,u),_=Math.min(i?c:h,c,u),M=useMemo(()=>s.slice(0,_),[s,_]),Ne=useMemo(()=>C===0||M.length===0?!1:(C-60)/M.length<80,[C,M.length]),he=useMemo(()=>o.series.filter(y=>!d.has(y.dataKey)),[o.series,d]),ue=useMemo(()=>M.map(y=>({...y,_visibleTotal:he.reduce((f,D)=>f+(Number(y[D.dataKey])||0),0)})),[M,he]),$=useCallback(y=>{l.current&&(l.current.disconnect(),l.current=null),y&&(k(y.clientWidth),l.current=new ResizeObserver(()=>k(y.clientWidth)),l.current.observe(y));},[]),Ke=useCallback(y=>{m$1(f=>{let D=new Set(f);return D.has(y)?D.delete(y):D.add(y),D});},[]),Oe=useCallback(y=>{y?.activeTooltipIndex!=null&&v(Number(y.activeTooltipIndex));},[]),Ve=useCallback(()=>{v(null);},[]),Ge=useCallback((y,f)=>{t?.(y,f);},[t]),He=useCallback((y,f)=>{x(f);},[]);return jsxs(a,{children:[jsx(b$1,{title:"Carteira de clientes do vendedor",action:a$3}),jsx(mt,{children:jsx(a$1,{isEmpty:M.length===0,empty:jsx(m,{}),children:jsxs(S,{alignItems:"center",gap:1.5,children:[jsx(S,{width:"100%",ref:$,children:jsx(a$2,{active:r,children:jsx(Xr,{data:ue,config:o,visibleSeries:he,hiddenKeys:d,activeBarIndex:P,shouldRotateLabels:Ne,onMouseMove:Oe,onMouseLeave:Ve,onBarClick:Ge})})}),jsx($r,{series:o.series,hiddenKeys:d,onToggleSerie:Ke}),g&&jsx(Po,{size:"small",min:10,max:T,value:_,valueLabelDisplay:"auto",onChange:He})]})})})]})},ga=fa;var ha=[{dataKey:"ACTIVE",name:"Ativos",color:"#22C55E"},{dataKey:"AT_RISK",name:"Em risco",color:"#FFAB00"},{dataKey:"INACTIVE",name:"Inativos",color:"#FF5630"},{dataKey:"NEW_CLIENT",name:"Novos clientes",color:"#8E33FF"},{dataKey:"PROSPECT",name:"Prospects",color:"#00B8D9"},{dataKey:"LOST",name:"Perdidos",color:"#C4CDD5"}],ua=[{dataKey:"A",name:"Curva A",color:"#22C55E"},{dataKey:"B",name:"Curva B",color:"#FFAB00"},{dataKey:"C",name:"Curva C",color:"#FF5630"}],ya={["CLASSIFICATION"]:{label:"Por classifica\xE7\xE3o",series:ha,formatYAxis:d},["ABC_CURVE"]:{label:"Por curva ABC",series:ua,formatYAxis:d}};
|
|
45
|
+
var tr=styled(S)(({theme:e})=>({position:"relative",alignSelf:"flex-start",flexShrink:0,"& .recharts-wrapper, & .recharts-wrapper *":{outline:"none !important",boxShadow:"none !important"},"& .recharts-pie-sector":{cursor:"pointer"},[e.breakpoints.down("md")]:{alignSelf:"center"}}));var or=e=>c$1(e,{maximumFractionDigits:2,...e>0&&e<100?{minimumFractionDigits:2}:{}}),jr=({active:e,payload:r,total:o})=>{if(!e||!r?.length)return null;let t=r[0];return jsxs(a$9,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:t.name}),jsx(Jr,{}),jsxs(S,{children:[jsxs(S,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(S,{direction:"row",alignItems:"center",gap:1,children:[jsx(S,{width:6,height:6,borderRadius:"50%",bgcolor:t.payload.fill}),jsx(b$2,{variant:"body2",noWrap:!0,children:t.name})]}),jsxs(b$2,{variant:"body2",noWrap:!0,children:[or(t.payload.percentage)," (",t.value,")"]})]}),jsxs(S,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(S,{direction:"row",alignItems:"center",gap:1,children:[jsx(S,{width:6,height:6,borderRadius:"50%",bgcolor:"#919EAB"}),jsx(b$2,{variant:"body2",noWrap:!0,children:"Total"})]}),jsxs(b$2,{variant:"body2",noWrap:!0,children:[or(100)," (",o,")"]})]})]})]})},ar=jr;var at=({chartData:e,total:r,isEmptyData:o,onPieClick:t,clickable:a})=>jsx(tr,{children:jsx(ResponsiveContainer,{width:200,height:200,children:jsxs(PieChart,{children:[jsx(Pie,{data:e,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:60,outerRadius:90,paddingAngle:2,strokeWidth:0,isAnimationActive:!1,onClick:t,cursor:a?"pointer":void 0}),jsx("text",{x:"50%",y:"46%",textAnchor:"middle",dominantBaseline:"middle",style:{fontSize:24,fontWeight:700},children:a$7(r)}),jsx("text",{x:"50%",y:"58%",textAnchor:"middle",dominantBaseline:"middle",style:{fontSize:12,fill:"#919EAB"},children:"clientes"}),!o&&jsx(Tooltip,{content:jsx(ar,{total:r})})]})})}),nr=at;var st=({items:e,hiddenKeys:r,onToggle:o,onItemClick:t})=>jsx(S,{width:"100%",justifyContent:"center",children:e.map(a=>jsxs(S,{display:"grid",gridTemplateColumns:"1fr auto auto",alignItems:"center",gap:1.5,onClick:()=>t?.(a.key,a.label),sx:{...t?{cursor:"pointer"}:{}},children:[jsx(Wr,{label:a.label,onClick:i=>i.stopPropagation(),control:jsx(_r,{size:"small",checked:!r.has(a.key),onChange:(i,n)=>o(a.key,n),sx:{"&.Mui-checked":{color:a.color}}}),sx:{"& .MuiFormControlLabel-label":{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}}}),jsx(b$2,{variant:"body2",color:"text.secondary",textAlign:"right",noWrap:!0,children:c$1(a.percentage,{maximumFractionDigits:2,...a.percentage>0&&a.percentage<100?{minimumFractionDigits:2}:{}})}),jsx(b$2,{variant:"subtitle2",color:"text.primary",textAlign:"right",noWrap:!0,children:d(a.count)})]},a.key))}),sr=st;var ft=({title:e,isFetching:r,chartData:o,total:t,isEmptyData:a$1,legendItems:i,hiddenKeys:n,onToggle:d,onPieClick:m,onItemClick:h})=>jsxs(a,{children:[jsx(dt,{title:e}),jsx(mt,{children:jsxs(S,{direction:{xs:"column",sm:"row"},alignItems:"center",gap:1.5,minWidth:0,children:[jsx(a$2,{active:r,children:jsx(nr,{chartData:o,total:t,isEmptyData:a$1,onPieClick:m,clickable:!!m})}),jsx(sr,{items:i,hiddenKeys:n,onToggle:d,onItemClick:h})]})})]}),gt=ft;var mr=Math.PI/180,dr=22,ht=2,ut=e=>{let{cx:r,cy:o,midAngle:t,outerRadius:a,percentage:i}=e;if(i<ht)return null;let n=Number(r),d=Number(o),m=Number(a),h=Number(t);if(isNaN(n)||isNaN(d)||isNaN(m))return null;let x=Math.sin(-h*mr),P=Math.cos(-h*mr),v=n+m*P,C=d+m*x,k=n+(m+dr*.5)*P,l=d+(m+dr*.5)*x,s=P>=0?1:-1,u=k+s*10,c=l,g=c$1(i,{maximumFractionDigits:1,...i>0&&i<100?{minimumFractionDigits:1}:{}}),T=g.length*7+10,_=s===1?u+2:u-T-2;return jsxs("g",{children:[jsx("path",{d:`M${v},${C} L${k},${l} L${u},${c}`,stroke:"#637381",fill:"none",strokeWidth:1}),jsx("rect",{x:_,y:c-10,width:T,height:20,rx:4,fill:"#212B36"}),jsx("text",{x:_+T/2,y:c,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fontWeight:600,fill:"#FFFFFF",children:g})]})},cr=ut;var fr=styled(S)({position:"relative",alignItems:"center",justifyContent:"center","& .recharts-wrapper, & .recharts-wrapper *":{outline:"none !important",boxShadow:"none !important"},"& .recharts-wrapper":{overflow:"visible !important"},"& .recharts-wrapper svg":{overflow:"visible"},"& .recharts-pie-sector":{cursor:"pointer"}});var gr=e=>c$1(e,{maximumFractionDigits:2,...e>0&&e<100?{minimumFractionDigits:2}:{}}),xt=({active:e,payload:r,total:o})=>{if(!e||!r?.length)return null;let t=r[0];return jsxs(a$9,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:t.name}),jsx(Jr,{}),jsxs(S,{children:[jsxs(S,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(S,{direction:"row",alignItems:"center",gap:1,children:[jsx(S,{width:6,height:6,borderRadius:"50%",bgcolor:t.payload.fill}),jsx(b$2,{variant:"body2",noWrap:!0,children:t.name})]}),jsxs(b$2,{variant:"body2",noWrap:!0,children:[gr(t.payload.percentage)," (",t.value,")"]})]}),jsxs(S,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(S,{direction:"row",alignItems:"center",gap:1,children:[jsx(S,{width:6,height:6,borderRadius:"50%",bgcolor:"#919EAB"}),jsx(b$2,{variant:"body2",noWrap:!0,children:"Total"})]}),jsxs(b$2,{variant:"body2",noWrap:!0,children:[gr(100)," (",o,")"]})]})]})]})},hr=xt;var Rt=e=>jsx(cr,{...e}),wt=({chartData:e,total:r,isEmptyData:o,onPieClick:t})=>jsx(fr,{children:jsx(ResponsiveContainer,{width:280,height:280,children:jsxs(PieChart,{children:[jsx(Pie,{data:e,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:90,paddingAngle:1,strokeWidth:0,isAnimationActive:!1,label:o?!1:Rt,labelLine:!1,onClick:t,cursor:t?"pointer":void 0}),!o&&jsx(Tooltip,{content:jsx(hr,{total:r})})]})})}),ur=wt;var At=e=>c$1(e,{maximumFractionDigits:2,...e>0&&e<100?{minimumFractionDigits:2}:{}}),_t=({items:e,hiddenKeys:r,onToggle:o,onItemClick:t})=>jsx(a$8,{sx:{maxHeight:280,width:"100%",pl:.5},children:e.map(a=>jsxs(S,{display:"grid",gridTemplateColumns:"1fr auto auto",alignItems:"center",gap:1.5,onClick:()=>t?.(a.key),sx:t?{cursor:"pointer"}:void 0,children:[jsx(Wr,{label:a.label,onClick:i=>i.stopPropagation(),control:jsx(_r,{size:"small",checked:!r.has(a.key),onChange:(i,n)=>o(a.key,n),sx:{"&.Mui-checked":{color:a.color}}}),sx:{"& .MuiFormControlLabel-label":{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}}}),jsx(b$2,{variant:"body2",color:"text.secondary",textAlign:"right",noWrap:!0,children:At(a.percentage)}),jsx(b$2,{variant:"subtitle2",color:"text.primary",textAlign:"right",noWrap:!0,children:d(a.count)})]},a.key))}),br=_t;var Nt=({data:e,isFetching:r,chartData:o,total:t,isEmptyData:a$3,onPieClick:i,onLegendClick:n,hiddenKeys:d,onToggle:m$1})=>jsxs(a,{children:[jsx(dt,{title:"Clientes por segmentos"}),jsx(mt,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(S,{alignItems:"center",gap:2,children:[jsx(a$2,{active:r,children:jsx(ur,{chartData:o,total:t,isEmptyData:a$3,onPieClick:i})}),jsx(br,{items:e,hiddenKeys:d,onToggle:m$1,onItemClick:n})]})})})]}),Kt=Nt;var Ot=["#FF5630","#FFAB00","#22C55E","#C4CDD5","#8E33FF","#00B8D9","#3366FF","#FF6C40","#36B37E","#B76E00"],Vt=12;var Ht=({title:e,label:r})=>jsxs(S,{width:"100%",minWidth:0,overflow:"hidden",children:[jsx(b$2,{variant:"subtitle1",noWrap:!0,children:e}),jsx(b$2,{variant:"body2",color:"text.secondary",noWrap:!0,children:r})]}),vr=Ht;var $t=({open:e,onClose:r,title:o,label:t,columns:a,rows:i,totalPartners:n,isLoading:d,isFetching:m,isFetchingNextPage:h,onSearch:x,onRowsScrollEnd:P,sellerName:v,buildSellerLink:C,sellerExternalId:k,mobileRender:l})=>{let s=b("down","sm"),u=jsxs(S,{gap:3,children:[jsxs(S,{direction:{xs:"column",sm:"row"},justifyContent:"space-between",alignItems:{sm:"center"},gap:3,children:[jsxs(S,{direction:"row",alignItems:"center",gap:3,flexWrap:"wrap",children:[v&&k&&jsxs(Fragment,{children:[C?jsx(Xt,{component:"a",href:C(k),target:"_blank",rel:"noopener noreferrer",variant:"subtitle2",sx:{textDecoration:"underline"},noWrap:!0,children:v}):jsx(b$2,{variant:"subtitle2",noWrap:!0,children:v}),jsx(Jr,{orientation:"vertical",flexItem:!0})]}),jsxs(S,{children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:"Total de clientes:"}),jsx(b$2,{variant:"subtitle2",color:"text.primary",children:n})]})]}),jsx(a$3,{size:"small",placeholder:"Buscar",onSearch:x,trigger:"change",iconPosition:"start",sx:{minWidth:200}})]}),jsx(f,{title:"Clientes",header:jsx(Fragment,{}),headerProps:{p:0},columns:a,rows:i,getRowId:g=>g.external_id,mobileRender:l,loading:d,fetching:m&&!h,fetchingNextPage:h,onRowsScrollEnd:P,scrollEndThreshold:600,disableRowSelectionOnClick:!0,disableColumnMenu:!0,containerProps:{height:400}})]}),c=jsx(vr,{title:o,label:t});return s?jsx(a$4,{open:e,onClose:r,headerTitle:c,headerProps:{direction:"row-reverse",sx:{"& > :last-child":{minWidth:0,overflow:"hidden"}}},children:u}):jsx(a$5,{open:e,onClose:r,maxWidth:"lg",dialogTitle:c,dialogTitleProps:{sx:{flex:1,overflow:"hidden"}},fullWidth:!0,children:u})},Qt=$t;var qt=({profileName:e})=>jsxs(S,{width:"100%",minWidth:0,overflow:"hidden",children:[jsx(b$2,{variant:"subtitle1",noWrap:!0,children:"Clientes por perfil"}),jsx(b$2,{variant:"body2",color:"text.secondary",noWrap:!0,children:e})]}),Rr=qt;var Jt=({open:e,onClose:r,profileName:o,columns:t,rows:a,totalPartners:i,isLoading:n,isFetching:d,isFetchingNextPage:m,onSearch:h,onRowsScrollEnd:x,mobileRender:P})=>{let v=b("down","sm"),C=jsxs(S,{gap:3,children:[jsxs(S,{direction:{xs:"column",sm:"row"},justifyContent:"space-between",alignItems:{sm:"center"},gap:2,children:[jsx(S,{direction:"row",alignItems:"center",gap:3,flexWrap:"wrap",children:jsxs(S,{children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:"Total de clientes:"}),jsx(b$2,{variant:"subtitle2",color:"text.primary",children:i})]})}),jsx(a$3,{size:"small",placeholder:"Buscar",onSearch:h,trigger:"change",iconPosition:"start",sx:{minWidth:200}})]}),jsx(f,{title:"Clientes",header:jsx(Fragment,{}),headerProps:{p:0},columns:t,rows:a,getRowId:l=>l.external_id,mobileRender:P,loading:n,fetching:d&&!m,fetchingNextPage:m,onRowsScrollEnd:x,scrollEndThreshold:600,disableRowSelectionOnClick:!0,disableColumnMenu:!0,containerProps:{height:400}})]}),k=jsx(Rr,{profileName:o});return v?jsx(a$4,{open:e,onClose:r,headerTitle:k,headerProps:{direction:"row-reverse",sx:{"& > :last-child":{minWidth:0,overflow:"hidden"}}},children:C}):jsx(a$5,{open:e,onClose:r,maxWidth:"lg",dialogTitle:k,dialogTitleProps:{sx:{flex:1,overflow:"hidden"}},fullWidth:!0,children:C})},jt=Jt;var J="#212B36",ro={["SALE_TOTAL_VALUE"]:{label:"Por valor total",color:"#22C55E",dataKey:"total_sale_value",barName:"Valor total por cliente",averageName:"M\xE9dia total de valor por cliente",averageDataKey:"average_total_value",formatLabel:h,formatYAxis:d},["SALE_COUNT"]:{label:"Por pedidos",color:"#C684FF",dataKey:"total_value_by_customer",barName:"Quantidade de pedidos",averageName:"Quantidade total de pedidos",averageDataKey:"average_sale_count",formatLabel:String,formatYAxis:d,floorAverage:!0},["SALE_AVERAGE_VALUE"]:{label:"Por ticket m\xE9dio",color:"#00B8D9",dataKey:"total_sale_value",barName:"Ticket m\xE9dio por cliente",averageName:"M\xE9dia do ticket m\xE9dio",averageDataKey:"average_ticket",formatLabel:h,formatYAxis:d}};var to=({x:e=0,y:r=0,width:o=0,height:t=0,index:a=0,activeBarIndex:i,color:n,data:d,onBarClick:m})=>i!==a?null:jsx("rect",{x:e-6,y:r,width:o+12,height:t+6,fill:n,opacity:.16,rx:6,style:{cursor:"pointer"},onClick:()=>m(d[a])}),Dr=to;var no=({active:e,payload:r,label:o,config:t,average:a})=>!e||!r?.length?null:jsxs(a$9,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:o}),jsx(Jr,{}),jsxs(S,{children:[r.map((i,n)=>jsxs(S,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,"data-testid":`tooltip-item-${n}`,children:[jsxs(S,{direction:"row",alignItems:"center",gap:1,children:[jsx(S,{width:6,height:6,borderRadius:"50%",bgcolor:i.color}),jsx(b$2,{variant:"body2",noWrap:!0,children:t.barName})]}),jsx(b$2,{variant:"body2",children:t.formatLabel(i.value)})]},i.dataKey)),jsxs(S,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(S,{direction:"row",alignItems:"center",gap:1,children:[jsx(S,{width:6,height:6,borderRadius:"50%",bgcolor:J}),jsx(b$2,{variant:"body2",noWrap:!0,children:t.averageName})]}),jsx(b$2,{variant:"body2",children:t.formatLabel(a)})]})]})]}),Ir=no;var go=48,ho=go/.8,uo=({data:e,config:r,visibleSeries:o,average:t,activeBarIndex:a,activeCoordX:i,shouldRotateLabels:n$1,onMouseMove:d$1,onMouseLeave:m,onBarClick:h})=>{let x=useMemo(()=>{if(!e.length)return [0,1];let s=e.map(c=>c[r.dataKey]||0);o.average&&t>0&&s.push(t);let u=Math.max(...s);return [0,u>0?u*1.15:1]},[e,r.dataKey,t,o.average]),P=useMemo(()=>{let[,s]=x,u=s/6;return [...new Set(Array.from({length:7},(c,g)=>Math.round(u*g)))]},[x]),v=useMemo(()=>n$1?!1:{position:"top",fontSize:11,fill:"#212B36",formatter:s=>r.formatLabel(Number(s))},[n$1,r]),C=useMemo(()=>jsx(Ir,{config:r,average:t}),[r,t]),k=useCallback(s=>n$1?jsx(n,{...s}):jsx(b$3,{x:s.x,y:s.y,payload:s.payload,slotWidth:ho}),[n$1]),l=useCallback(s=>{s&&h(s);},[h]);return jsx(c,{children:jsx(ResponsiveContainer,{width:"100%",height:350,children:jsxs(ComposedChart,{data:e,margin:{top:20,right:10,bottom:0,left:20},barCategoryGap:"20%",onMouseMove:d$1,onMouseLeave:m,children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"partner_name",axisLine:!1,tickLine:!1,interval:0,height:n$1?70:50,tick:k}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:s=>d(s),domain:x,ticks:P}),jsx(Tooltip,{content:C}),o.average&&t>0&&jsx(ReferenceLine,{y:t,stroke:J,strokeDasharray:"8 4",strokeWidth:2,ifOverflow:"extendDomain"}),o.average&&t>0&&jsx(ReferenceLine,{y:t,stroke:"none",ifOverflow:"extendDomain",label:jsx(a$6,{activeCoordX:i,referenceCircleColor:J,activeIndex:a})}),o.bar&&jsx(Bar,{dataKey:r.dataKey,name:r.barName,fill:r.color,maxBarSize:48,isAnimationActive:!1,radius:[4,4,0,0],cursor:"pointer",onClick:l,background:jsx(Dr,{activeBarIndex:a,color:r.color,data:e,onBarClick:h}),label:v})]})})})},Ar=uo;var Co=({visibleSeries:e,config:r,onToggleSerie:o})=>jsxs(S,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(Wr,{control:jsx(_r,{checked:e.bar,onChange:()=>o("bar"),sx:{"&.Mui-checked":{color:r.color}}}),label:r.barName}),jsx(Wr,{control:jsx(_r,{checked:e.average,onChange:()=>o("average"),sx:{"&.Mui-checked":{color:J}}}),label:r.averageName})]}),Mr=Co;var Nr=memo(({data:e,config:r,average:o,isFetching:t,onBarClick:a$3,children:i})=>{let n=b("down","sm"),d=b("down","lg"),[m$1,h]=useState({bar:!0,average:!0}),[x,P]=useState(12),[v,C]=useState(null),[k,l]=useState(null),[s,u]=useState(0),c=useRef(null),g=useCallback(f=>{c.current&&(c.current.disconnect(),c.current=null),f&&(u(f.clientWidth),c.current=new ResizeObserver(()=>u(f.clientWidth)),c.current.observe(f));},[]),T=useMemo(()=>[...e].sort((f,D)=>D[r.dataKey]-f[r.dataKey]),[e,r.dataKey]),_=T.length,M=useMemo(()=>n?10:d?25:30,[n,d]),Ne=!n&&_>10,he=Math.min(_,M),ue=Math.min(n?_:x,_,M),$=useMemo(()=>T.slice(0,ue),[T,ue]),Ke=useMemo(()=>s===0||$.length===0?!1:(s-60)/$.length<80,[s,$.length]),Oe=useCallback(f=>{h(D=>({...D,[f]:!D[f]}));},[]),Ve=useCallback(f=>{f?.activeTooltipIndex!=null&&C(Number(f.activeTooltipIndex)),f?.activeCoordinate?.x!=null&&l(f.activeCoordinate.x);},[]),Ge=useCallback(()=>{C(null),l(null);},[]),He=useCallback(f=>{f&&a$3?.(f);},[a$3]),y=useCallback((f,D)=>{P(D);},[]);return jsxs(a,{children:[jsx(b$1,{title:"Ranking de clientes",action:i}),jsx(mt,{children:jsx(a$1,{isEmpty:$.length===0,empty:jsx(m,{}),children:jsxs(S,{alignItems:"center",gap:1.5,children:[jsx(S,{width:"100%",ref:g,children:jsx(a$2,{active:t,children:jsx(Ar,{data:$,config:r,visibleSeries:m$1,average:o,activeBarIndex:v,activeCoordX:k,shouldRotateLabels:Ke,onMouseMove:Ve,onMouseLeave:Ge,onBarClick:He})})}),jsx(Mr,{visibleSeries:m$1,config:r,onToggleSerie:Oe}),Ne&&jsx(Po,{size:"small",min:10,max:he,value:ue,valueLabelDisplay:"auto",onChange:y})]})})})]})});Nr.displayName="Ranking";var To=Nr;var Do=styled(Ro,{shouldForwardProp:e=>e!=="active"})(({theme:e,active:r})=>({justifyContent:"flex-start",color:r?e.palette.primary.main:e.palette.text.secondary,fontWeight:r?800:400,"&:hover":{background:e.palette.action.hover}}));var Io=({rankingLabel:e,partnerName:r})=>jsxs(S,{width:"100%",minWidth:0,overflow:"hidden",children:[jsx(b$2,{variant:"subtitle1",noWrap:!0,children:"Detalhes do relat\xF3rio"}),jsxs(S,{direction:"row",alignItems:"center",columnGap:1.5,rowGap:0,flexWrap:"wrap",children:[jsx(b$2,{variant:"body2",color:"text.secondary",flexShrink:0,children:"Top clientes"}),"\u2022",jsxs(b$2,{variant:"body2",flexShrink:0,children:['Por "',e,'"']}),"\u2022",jsx(b$2,{variant:"body2",color:"text.secondary",noWrap:!0,children:r})]})]}),Or=Io;var Ee=styled(Jr)(()=>({height:30,alignSelf:"center",borderStyle:"dashed"})),Gr=styled(S)(({theme:e})=>({position:"relative",display:"flex",flexDirection:"column",padding:e.spacing(2),gap:e.spacing(1),color:e.palette.text.primary,"& a":{textDecoration:"none"},"&+div":{borderTop:`1px dashed ${alpha(e.palette.grey[500],.2)}`}}));var Mo=e=>jsx(S,{justifyContent:"center",height:1,children:jsx(b$2,{variant:"body2",color:"text.primary",children:e.id})}),Eo=(e,r)=>jsx(S,{justifyContent:"center",height:1,children:e?.partner?.id&&r?jsx(Xt,{component:"a",href:r(e.partner.id),target:"_blank",rel:"noopener noreferrer",variant:"subtitle2",sx:{textDecoration:"underline"},noWrap:!0,children:e.partner?.name||"-"}):jsx(b$2,{variant:"body2",color:"text.primary",noWrap:!0,children:e.partner?.name||"-"})}),Fo=e=>jsx(S,{justifyContent:"center",height:1,children:jsx(b$2,{variant:"body2",color:"text.primary",children:h(e.total_value)})}),No=e=>jsx(S,{justifyContent:"center",height:1,children:e.negotiation_date?jsx(b$2,{variant:"body2",color:"text.primary",children:d$1(e.negotiation_date,"DD/MM/YYYY")}):"-"}),Ko=e=>jsx(S,{justifyContent:"center",height:1,children:e.status||"-"}),Oo=e=>jsx(Gr,{children:jsxs(S,{gap:1,children:[jsxs(S,{children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:"Pedido"}),jsx(b$2,{variant:"subtitle2",color:"text.primary",children:e.id})]}),jsxs(S,{children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:"Cliente"}),jsx(b$2,{variant:"subtitle2",color:"primary.main",children:e.partner?.name||"-"})]}),jsxs(S,{direction:"row",alignItems:"center",gap:1,children:[jsxs(S,{flex:1,overflow:"hidden",children:[jsx(b$2,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Valor do pedido"}),jsx(b$2,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:h(e.total_value)})]}),jsx(Jr,{orientation:"vertical",flexItem:!0,sx:{borderStyle:"dashed",mx:3}}),jsxs(S,{flex:1,overflow:"hidden",children:[jsx(b$2,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Data"}),jsx(b$2,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:e.negotiation_date?d$1(e.negotiation_date,"DD/MM/YYYY"):"-"})]})]}),jsxs(S,{gap:.5,children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:"Status"}),jsx(b$2,{variant:"subtitle2",color:"text.primary",children:e.status||"-"})]})]})},e.id),Vo=({open:e,onClose:r,partnerName:o,rankingLabel:t,rows:a,total:i,totalValue:n,averageTicket:d,isLoading:m,isFetching:h$1,page:x,perPage:P,onSearch:v,onPaginationChange:C,buildPartnerLink:k,mobileItemSlot:l})=>{let s=b("down","sm"),u=jsxs(S,{gap:3,children:[jsxs(S,{direction:{xs:"column",sm:"row"},justifyContent:"space-between",gap:2,children:[jsxs(S,{minWidth:0,direction:"row",alignItems:"center",gap:3,flexWrap:"wrap",children:[jsx(b$2,{variant:"subtitle2",noWrap:!0,children:o}),jsx(Ee,{orientation:"vertical",flexItem:!0}),jsxs(S,{children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:"Qtd. de pedidos"}),jsx(b$2,{variant:"subtitle2",color:"text.primary",children:i})]}),jsx(Ee,{orientation:"vertical",flexItem:!0}),jsxs(S,{children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:"Valor em pedidos"}),jsx(b$2,{variant:"subtitle2",color:"text.primary",children:h(n)})]}),jsx(Ee,{orientation:"vertical",flexItem:!0}),jsxs(S,{children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:"Ticket m\xE9dio"}),jsx(b$2,{variant:"subtitle2",color:"text.primary",children:h(d)})]})]}),jsx(a$3,{size:"small",placeholder:"Buscar",onSearch:v,trigger:"change",iconPosition:"start",sx:{minWidth:200}})]}),jsx(f,{title:"Pedidos",header:jsx(Fragment,{}),headerProps:{p:0},columns:[{field:"external_id",headerName:"Pedido",flex:1,renderCell:({row:g})=>Mo(g)},{field:"partner_name",headerName:"Cliente",flex:1,renderCell:({row:g})=>Eo(g,k)},{field:"total_value",headerName:"Valor do pedido",flex:1,renderCell:({row:g})=>Fo(g)},{field:"created_at",headerName:"Data",flex:1,renderCell:({row:g})=>No(g)},{field:"last_status",headerName:"Status",flex:1,renderCell:({row:g})=>Ko(g)}],rows:a,rowCount:i,mobileRender:g=>l?l(g):Oo(g),loading:m,fetching:h$1,paginationModel:{page:x,pageSize:P},onPaginationChange:C,paginationMode:"server",disableRowSelectionOnClick:!0,disableColumnMenu:!0,containerProps:{height:400}})]}),c=jsx(Or,{rankingLabel:t,partnerName:o});return s?jsx(a$4,{open:e,onClose:r,headerTitle:c,headerProps:{direction:"row-reverse",sx:{"& > :last-child":{minWidth:0,overflow:"hidden"}}},children:u}):jsx(a$5,{open:e,onClose:r,maxWidth:"lg",dialogTitle:c,dialogTitleProps:{sx:{flex:1,overflow:"hidden"}},fullWidth:!0,children:u})},Go=Vo;var zo=({x:e=0,y:r=0,width:o=0,height:t=0,index:a=0,activeBarIndex:i,data:n,onBarClick:d})=>{if(i!==a)return null;let m=n[a];return jsx("rect",{x:e-6,y:r,width:o+12,height:t+6,fill:"#919EAB",opacity:.16,rx:6,style:{cursor:"pointer"},onClick:()=>{m&&d(String(m.seller_external_id),String(m.seller_name));}})},Hr=zo;var zr=e=>c$1(e,{maximumFractionDigits:2,...e>0&&e<100?{minimumFractionDigits:2}:{}}),$o=({active:e,payload:r,label:o,config:t})=>{if(!e||!r?.length)return null;let a=r.filter(n=>n.value!=null&&n.value>0),i=a.reduce((n,d)=>n+d.value,0);return jsxs(a$9,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(b$2,{variant:"body2",color:"text.secondary",children:o}),jsx(Jr,{}),jsxs(S,{children:[a.map(n=>{let d=t.series.find(h=>h.dataKey===n.dataKey),m=i>0?zr(n.value/i*100):"0%";return jsxs(S,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(S,{direction:"row",alignItems:"center",gap:1,children:[jsx(S,{width:6,height:6,borderRadius:"50%",bgcolor:n.color}),jsx(b$2,{variant:"body2",noWrap:!0,children:d?.name??n.dataKey})]}),jsxs(b$2,{variant:"body2",noWrap:!0,children:[m," (",n.value,")"]})]},n.dataKey)}),jsxs(S,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(S,{direction:"row",alignItems:"center",gap:1,children:[jsx(S,{width:6,height:6,borderRadius:"50%",bgcolor:"#919EAB"}),jsx(b$2,{variant:"body2",noWrap:!0,children:"Total"})]}),jsxs(b$2,{variant:"body2",noWrap:!0,children:[zr(100)," (",i,")"]})]})]})]})},Yr=$o;var ra=48,ta=ra/.8,oa=({data:e,config:r,visibleSeries:o,hiddenKeys:t,activeBarIndex:a,shouldRotateLabels:i,onMouseMove:n$1,onMouseLeave:d$1,onBarClick:m})=>{let h=useMemo(()=>{if(!e.length)return [0,1];let l=Math.max(...e.map(s=>s._visibleTotal));return [0,l>0?l*1.15:1]},[e]),x=useMemo(()=>{let[,l]=h,s=l/6;return [...new Set(Array.from({length:7},(u,c)=>Math.round(s*c)))]},[h]),P=useMemo(()=>jsx(Yr,{config:r}),[r]),v=useCallback(l=>i?jsx(n,{...l}):jsx(b$3,{x:l.x,y:l.y,payload:l.payload,slotWidth:ta}),[i]),C=useCallback(l=>{if(!l)return;let s=l.payload;s&&m(String(s.seller_external_id),String(s.seller_name));},[m]),k=useCallback(l=>{let{x:s,y:u,width:c,index:g}=l,T=e[g]?._visibleTotal;return T?jsx("text",{x:s+c/2,y:u-6,textAnchor:"middle",fontSize:11,fill:"#212B36",children:T}):jsx(Fragment,{})},[e]);return jsx(c,{children:jsx(ResponsiveContainer,{width:"100%",height:350,children:jsxs(BarChart,{data:e,margin:{top:20,right:10,bottom:0,left:20},barCategoryGap:"20%",onMouseMove:n$1,onMouseLeave:d$1,children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"seller_name",axisLine:!1,tickLine:!1,interval:0,height:i?70:50,tick:v}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:l=>d(l),domain:h,ticks:x}),jsx(Tooltip,{content:P,cursor:!1}),r.series.map(l=>{let s=!t.has(l.dataKey),u=o[0],c=o[o.length-1],g=s&&l.dataKey===u?.dataKey,T=s&&l.dataKey===c?.dataKey;return jsx(Bar,{dataKey:s?l.dataKey:`_hidden_${l.dataKey}`,name:l.name,fill:l.color,stackId:"stack",maxBarSize:48,isAnimationActive:!1,cursor:"pointer",hide:!s,onClick:C,...g&&{background:jsx(Hr,{activeBarIndex:a,data:e,onBarClick:m})},...T&&{radius:[4,4,0,0]},...T&&!i&&{label:{position:"top",fontSize:11,fill:"#212B36",content:k}}},l.dataKey)})]})})})},Xr=oa;var pa=({series:e,hiddenKeys:r,onToggleSerie:o})=>jsx(S,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:e.map(t=>jsx(Wr,{control:jsx(_r,{checked:!r.has(t.dataKey),onChange:()=>o(t.dataKey),sx:{"&.Mui-checked":{color:t.color}}}),label:t.name},t.dataKey))}),$r=pa;var fa=({data:e,isFetching:r,config:o,onBarClick:t,children:a$3})=>{let i=b("down","sm"),n=b("down","lg"),[d,m$1]=useState(new Set),[h,x]=useState(12),[P,v]=useState(null),[C,k]=useState(0),l=useRef(null),s=useMemo(()=>[...e].sort((y,f)=>f._total-y._total),[e]),u=useMemo(()=>i?10:n?25:30,[n,i]),c=s.length,g=!i&&c>10,T=Math.min(c,u),_=Math.min(i?c:h,c,u),M=useMemo(()=>s.slice(0,_),[s,_]),Ne=useMemo(()=>C===0||M.length===0?!1:(C-60)/M.length<80,[C,M.length]),he=useMemo(()=>o.series.filter(y=>!d.has(y.dataKey)),[o.series,d]),ue=useMemo(()=>M.map(y=>({...y,_visibleTotal:he.reduce((f,D)=>f+(Number(y[D.dataKey])||0),0)})),[M,he]),$=useCallback(y=>{l.current&&(l.current.disconnect(),l.current=null),y&&(k(y.clientWidth),l.current=new ResizeObserver(()=>k(y.clientWidth)),l.current.observe(y));},[]),Ke=useCallback(y=>{m$1(f=>{let D=new Set(f);return D.has(y)?D.delete(y):D.add(y),D});},[]),Oe=useCallback(y=>{y?.activeTooltipIndex!=null&&v(Number(y.activeTooltipIndex));},[]),Ve=useCallback(()=>{v(null);},[]),Ge=useCallback((y,f)=>{t?.(y,f);},[t]),He=useCallback((y,f)=>{x(f);},[]);return jsxs(a,{children:[jsx(b$1,{title:"Carteira de clientes do vendedor",action:a$3}),jsx(mt,{children:jsx(a$1,{isEmpty:M.length===0,empty:jsx(m,{}),children:jsxs(S,{alignItems:"center",gap:1.5,children:[jsx(S,{width:"100%",ref:$,children:jsx(a$2,{active:r,children:jsx(Xr,{data:ue,config:o,visibleSeries:he,hiddenKeys:d,activeBarIndex:P,shouldRotateLabels:Ne,onMouseMove:Oe,onMouseLeave:Ve,onBarClick:Ge})})}),jsx($r,{series:o.series,hiddenKeys:d,onToggleSerie:Ke}),g&&jsx(Po,{size:"small",min:10,max:T,value:_,valueLabelDisplay:"auto",onChange:He})]})})})]})},ga=fa;var ha=[{dataKey:"ACTIVE",name:"Ativos",color:"#22C55E"},{dataKey:"AT_RISK",name:"Em risco",color:"#FFAB00"},{dataKey:"INACTIVE",name:"Inativos",color:"#FF5630"},{dataKey:"NEW_CLIENT",name:"Novos clientes",color:"#8E33FF"},{dataKey:"PROSPECT",name:"Prospects",color:"#00B8D9"},{dataKey:"LOST",name:"Perdidos",color:"#C4CDD5"}],ua=[{dataKey:"A",name:"Curva A",color:"#22C55E"},{dataKey:"B",name:"Curva B",color:"#FFAB00"},{dataKey:"C",name:"Curva C",color:"#FF5630"}],ya={["CLASSIFICATION"]:{label:"Por classifica\xE7\xE3o",series:ha,formatYAxis:d},["ABC_CURVE"]:{label:"Por curva ABC",series:ua,formatYAxis:d}};
|
|
46
46
|
|
|
47
47
|
export { Vt as PROFILE_MAX_VISIBLE, gt as PartnerBreakdown, Kt as PartnersByProfile, Qt as PartnersDetail, jt as ProfileDetail, ro as RANKING_CONFIG, To as Ranking, Go as RankingDetail, Do as RankingItemButton, Ot as SEGMENT_COLORS, ya as SELLER_PORTFOLIO_CONFIG, ga as SellerPortfolio };
|
|
48
48
|
//# sourceMappingURL=index.js.map
|
|
@@ -25,7 +25,7 @@ import _ from '@mui/lab/LoadingButton';
|
|
|
25
25
|
import j from '@mui/material/Button';
|
|
26
26
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
27
27
|
|
|
28
|
-
var T=styled(c)({width:40,height:40,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid #1C1C1C",cursor:"pointer"}),w=styled(a)(({theme:o})=>({width:322,marginTop:20,"& .MuiPopover-paper":{width:540,padding:0,backgroundColor:o.palette.background.paper,borderRadius:o.spacing(1),backgroundImage:"none"}})),R=styled(c)(({theme:o})=>({alignItems:"center",justifyContent:"center",gap:o.spacing(1.5),padding:o.spacing(3),backgroundColor:alpha(o.palette.primary.main,.04)})),p=styled(c)(({theme:o})=>({marginLeft:o.spacing(1.75),marginRight:o.spacing(1.75),marginTop:o.spacing(2),marginBottom:o.spacing(2),gap:o.spacing(1)})),S=styled(j)(({theme:o})=>({width:"100%",alignItems:"flex-start",justifyContent:"flex-start",color:o.palette.text.primary})),A=styled(c)(({theme:o})=>({display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:o.spacing(2),cursor:"pointer"})),d=styled(c)(({theme:o})=>({alignItems:"center",gap:o.spacing(.5),color:o.palette.text.secondary,textAlign:"center","&:hover":{color:o.palette.primary.main}})),B=styled(_)(({theme:o})=>({width:"100%",alignItems:"flex-start",justifyContent:"flex-start",color:o.palette.error.main}));var U=({name:o="",email:g="",src:P,content:y,menuItems:f,subContent:v,logout:L,loadingLogout:x})=>{let m=a$1();return jsxs(Fragment,{children:[jsx(T,{"data-testid":"avatar-trigger-button",children:jsx(a$2,{alt:o,name:o,src:P,onClick:m.onOpen,"data-testid":"avatar-trigger",sx:{maxWidth:34,maxHeight:34}})}),jsxs(w,{open:m.open,onClose:m.onClose,arrow:"top-right",disableRestoreFocus:!0,"data-testid":"avatar-menu",children:[jsxs(R,{"data-testid":"avatar-account",children:[jsx(E,{sx:{bgcolor:r=>r.palette.mode==="dark"?alpha(r.palette.primary.main,.04):"success.lighter",border:r=>r.palette.mode==="dark"?"1px solid rgb(255, 252, 252)":"none",color:r=>r.palette.mode==="dark"?"primary.contrastText":"success.main",width:60,height:60},"data-testid":"avatar-initials",children:o.slice(0,2).toUpperCase()}),jsxs(c,{alignItems:"center",textAlign:"center",children:[jsx(i,{variant:"subtitle2",color:"text.primary",children:o}),jsx(i,{variant:"body2",color:"text.secondary",children:g})]})]}),jsx(s,{}),y&&jsxs(Fragment,{children:[jsx(p,{"data-testid":"avatar-content",children:y}),jsx(s,{})]}),f&&jsxs(Fragment,{children:[jsx(p,{"data-testid":"avatar-menu-items",children:f.map(r=>jsx(S,{"data-testid":`avatar-menu-item-${r.label.toLowerCase().replace(/\s+/g,"-")}`,startIcon:jsx(a$3,{icon:r.icon,color:M=>M.palette.mode==="dark"?"text.secondary":"primary.main"}),...r.component&&{component:r.component,to:r.to},...r.onClick&&{onClick:r.onClick},children:jsxs(c,{direction:"row",alignItems:"center",justifyContent:"space-between",flex:1,gap:1,children:[jsx(i,{variant:"caption",fontSize:13,color:"text.secondary",children:r.label}),jsx(a$3,{icon:"ARROW_RIGHT_SIMPLE",color:"text.primary"})]})},r.label))}),jsx(s,{})]}),v&&jsxs(Fragment,{children:[jsx(p,{"data-testid":"avatar-subcontent",children:v}),jsx(s,{})]}),jsx(p,{"data-testid":"avatar-resources",children:jsxs(A,{children:[jsxs(d,{"data-testid":"resource-youtube",onClick:()=>window.open("https://youtube.com/playlist?list=PLqv8txNiT9o_LReCh5wKPiQaeBTg2Q1i3&si=3nGSAU3AdcPwoa-R","_blank","noopener noreferrer"),children:[jsx(a$3,{icon:"YOUTUBE",color:"primary.main"}),jsx(i,{variant:"caption",children:"Videos"})]}),jsxs(d,{"data-testid":"resource-ajuda",onClick:()=>window.open("https://ajuda.zydon.com.br","_blank","noopener noreferrer"),children:[jsx(a$3,{icon:"HELP_CIRCLE",color:"primary.main"}),jsx(i,{variant:"caption",children:"Ajuda"})]}),jsxs(d,{"data-testid":"resource-docs",onClick:()=>window.open("https://
|
|
28
|
+
var T=styled(c)({width:40,height:40,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid #1C1C1C",cursor:"pointer"}),w=styled(a)(({theme:o})=>({width:322,marginTop:20,"& .MuiPopover-paper":{width:540,padding:0,backgroundColor:o.palette.background.paper,borderRadius:o.spacing(1),backgroundImage:"none"}})),R=styled(c)(({theme:o})=>({alignItems:"center",justifyContent:"center",gap:o.spacing(1.5),padding:o.spacing(3),backgroundColor:alpha(o.palette.primary.main,.04)})),p=styled(c)(({theme:o})=>({marginLeft:o.spacing(1.75),marginRight:o.spacing(1.75),marginTop:o.spacing(2),marginBottom:o.spacing(2),gap:o.spacing(1)})),S=styled(j)(({theme:o})=>({width:"100%",alignItems:"flex-start",justifyContent:"flex-start",color:o.palette.text.primary})),A=styled(c)(({theme:o})=>({display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:o.spacing(2),cursor:"pointer"})),d=styled(c)(({theme:o})=>({alignItems:"center",gap:o.spacing(.5),color:o.palette.text.secondary,textAlign:"center","&:hover":{color:o.palette.primary.main}})),B=styled(_)(({theme:o})=>({width:"100%",alignItems:"flex-start",justifyContent:"flex-start",color:o.palette.error.main}));var U=({name:o="",email:g="",src:P,content:y,menuItems:f,subContent:v,logout:L,loadingLogout:x})=>{let m=a$1();return jsxs(Fragment,{children:[jsx(T,{"data-testid":"avatar-trigger-button",children:jsx(a$2,{alt:o,name:o,src:P,onClick:m.onOpen,"data-testid":"avatar-trigger",sx:{maxWidth:34,maxHeight:34}})}),jsxs(w,{open:m.open,onClose:m.onClose,arrow:"top-right",disableRestoreFocus:!0,"data-testid":"avatar-menu",children:[jsxs(R,{"data-testid":"avatar-account",children:[jsx(E,{sx:{bgcolor:r=>r.palette.mode==="dark"?alpha(r.palette.primary.main,.04):"success.lighter",border:r=>r.palette.mode==="dark"?"1px solid rgb(255, 252, 252)":"none",color:r=>r.palette.mode==="dark"?"primary.contrastText":"success.main",width:60,height:60},"data-testid":"avatar-initials",children:o.slice(0,2).toUpperCase()}),jsxs(c,{alignItems:"center",textAlign:"center",children:[jsx(i,{variant:"subtitle2",color:"text.primary",children:o}),jsx(i,{variant:"body2",color:"text.secondary",children:g})]})]}),jsx(s,{}),y&&jsxs(Fragment,{children:[jsx(p,{"data-testid":"avatar-content",children:y}),jsx(s,{})]}),f&&jsxs(Fragment,{children:[jsx(p,{"data-testid":"avatar-menu-items",children:f.map(r=>jsx(S,{"data-testid":`avatar-menu-item-${r.label.toLowerCase().replace(/\s+/g,"-")}`,startIcon:jsx(a$3,{icon:r.icon,color:M=>M.palette.mode==="dark"?"text.secondary":"primary.main"}),...r.component&&{component:r.component,to:r.to},...r.onClick&&{onClick:r.onClick},children:jsxs(c,{direction:"row",alignItems:"center",justifyContent:"space-between",flex:1,gap:1,children:[jsx(i,{variant:"caption",fontSize:13,color:"text.secondary",children:r.label}),jsx(a$3,{icon:"ARROW_RIGHT_SIMPLE",color:"text.primary"})]})},r.label))}),jsx(s,{})]}),v&&jsxs(Fragment,{children:[jsx(p,{"data-testid":"avatar-subcontent",children:v}),jsx(s,{})]}),jsx(p,{"data-testid":"avatar-resources",children:jsxs(A,{children:[jsxs(d,{"data-testid":"resource-youtube",onClick:()=>window.open("https://youtube.com/playlist?list=PLqv8txNiT9o_LReCh5wKPiQaeBTg2Q1i3&si=3nGSAU3AdcPwoa-R","_blank","noopener noreferrer"),children:[jsx(a$3,{icon:"YOUTUBE",color:"primary.main"}),jsx(i,{variant:"caption",children:"Videos"})]}),jsxs(d,{"data-testid":"resource-ajuda",onClick:()=>window.open("https://ajuda.zydon.com.br","_blank","noopener noreferrer"),children:[jsx(a$3,{icon:"HELP_CIRCLE",color:"primary.main"}),jsx(i,{variant:"caption",children:"Ajuda"})]}),jsxs(d,{"data-testid":"resource-docs",onClick:()=>window.open("https://api.zydon.com.br/api/reference","_blank","noopener noreferrer"),children:[jsx(a$3,{icon:"CODE_FOLDER",color:"primary.main"}),jsx(i,{variant:"caption",children:"Docs"})]})]})}),jsx(s,{}),jsxs(p,{direction:"row",children:[jsx(B,{"data-testid":"logout-button",startIcon:jsx(a$3,{icon:"LOGOUT_02"}),size:"small",onClick:L,loading:x,children:x?"Saindo...":"Sair"}),a$4(g)&&jsxs(c,{direction:"row",alignItems:"center",gap:1,children:[jsx(i,{variant:"overline",fontSize:11,color:"text.disabled",children:"Apar\xEAncia:"}),jsx(a$5,{})]})]})]})]})},rt=U;
|
|
29
29
|
|
|
30
30
|
export { rt as default };
|
|
31
31
|
//# sourceMappingURL=index.js.map
|