(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[531],{18002:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/dashboards/admin/AdminAnalyticsEarningReports",function(){return a(8162)}])},94744:function(e,t,a){"use strict";var n=a(5152),r=a.n(n);let o=r()(()=>Promise.all([a.e(4814),a.e(7229)]).then(a.bind(a,47229)),{loadableGenerated:{webpack:()=>[47229]},ssr:!1});t.Z=o},8162:function(e,t,a){"use strict";a.r(t);var n=a(85893),r=a(67294),o=a(99226),s=a(66242),i=a(78445),l=a(44267),c=a(86886),d=a(90948),p=a(2734),u=a(94744),m=a(81406),h=a(87066),y=a(42412),g=a(98456);let f=(0,d.ZP)(c.ZP)(e=>{let{theme:t}=e;return{[t.breakpoints.up("sm")]:{paddingTop:"0 !important"}}});t.default=e=>{let{state:t}=e,[a,d]=(0,r.useState)(null),[x,b]=(0,r.useState)(!0);(0,r.useEffect)(()=>{let fetchData=async()=>{b(!0);let e=localStorage.getItem("userData"),a=JSON.parse(e);if(null!==a){var n;null===(n=a[0])||void 0===n||n.organizationKeyId}let r=window.localStorage.getItem(y.Z.storageTokenKeyName);try{let e=await h.Z.get("".concat(m.Ao,"/api/reports/sales-or-orders-graph?type=sales&filter=week&states=").concat(t.map(e=>e.value).join(",")),{headers:{Authorization:"Bearer ".concat(r)}});d(e.data),b(!1)}catch(e){console.error("Error fetching data:",e),b(!1)}};(t.length>0||0===t.length)&&fetchData()},[t]);let v=(0,p.Z)(),w=(null==a?void 0:a.graphData["All Data"].map(e=>({day:e.day,totalSalesAmount:e.totalSalesAmount.replace("₹","").replace(",","").trim()})))||[],k=w.map(e=>e.day),S=w.map(e=>parseFloat(e.totalSalesAmount)||0),formatCurrency=e=>"₹ "+e.toLocaleString("en-IN",{minimumFractionDigits:2,maximumFractionDigits:2}),Z={chart:{type:"line",toolbar:{show:!1}},stroke:{curve:"smooth",width:3},markers:{size:5,hover:{size:7}},grid:{strokeDashArray:5,borderColor:v.palette.divider},xaxis:{categories:k,labels:{style:{colors:v.palette.text.secondary,fontSize:v.typography.body2.fontSize}}},yaxis:{labels:{formatter:e=>formatCurrency(e),style:{colors:v.palette.text.secondary,fontSize:v.typography.body2.fontSize}}},colors:[v.palette.primary.main],tooltip:{enabled:!0,theme:"dark",custom:function(e){let{series:t,seriesIndex:a,dataPointIndex:n,w:r}=e,o=t[a][n],s=r.globals.labels[n];return'\n          <div style="padding: 12px; background: '.concat(v.palette.background.paper,'; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.15); width: 200px;">\n            <div style="display: flex; flex-direction: column; align-items: flex-start;">\n              <strong style="color: ').concat(v.palette.text.primary,'; font-size: 14px;">').concat(s,'</strong>\n              <div style="margin-top: 4px; color: ').concat(v.palette.primary.main,'; font-size: 12px;">\n                <span style="font-weight: bold;">').concat(formatCurrency(o),"</span> transactions\n              </div>\n            </div>\n          </div>\n        ")}},dataLabels:{enabled:!1}};return(0,n.jsxs)(s.Z,{sx:{height:"430px",display:"flex",flexDirection:"column"},children:[(0,n.jsx)(i.Z,{title:"Transaction Trends",subheader:"Weekly Transactions Overview"}),(0,n.jsx)(l.Z,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,n.jsx)(c.ZP,{container:!0,spacing:6,children:(0,n.jsx)(f,{item:!0,xs:12,children:x?(0,n.jsx)(o.Z,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,n.jsx)(g.Z,{})}):(0,n.jsx)(u.Z,{type:"line",height:300,options:Z,series:[{name:"Transactions",data:S}]})})})})]})}}},function(e){e.O(0,[9240,9774,2888,179],function(){return e(e.s=18002)}),_N_E=e.O()}]);