fix: analytic view

This commit is contained in:
ferdiansyah783
2025-08-10 22:56:04 +07:00
parent 0c95dd5f42
commit b648349ebd
8 changed files with 212 additions and 326 deletions
@@ -5,45 +5,16 @@ import Grid from '@mui/material/Grid2'
// Component Imports
import DistributedBarChartOrder from '@views/dashboards/crm/DistributedBarChartOrder'
import EarningReportsWithTabs from '@views/dashboards/crm/EarningReportsWithTabs'
// Server Action Imports
import Loading from '../../../../../../components/layout/shared/Loading'
import { useSalesAnalytics } from '../../../../../../services/queries/analytics'
import { RecentSale } from '../../../../../../types/services/analytic'
import OrdersReport from '../../../../../../views/dashboards/orders/OrdersReport'
const DashboardOrder = () => {
const { data, isLoading } = useSalesAnalytics()
const formatDate = (dateString: any) => {
return new Date(dateString).toLocaleDateString('id-ID', {
month: 'short',
day: 'numeric'
})
}
const transformSalesData = (data: any) => {
return [
{
type: 'items',
avatarIcon: 'tabler-shopping-cart',
date: data.map((d: any) => formatDate(d.date)),
series: [{ data: data.map((d: any) => d.items) }]
},
{
type: 'orders',
avatarIcon: 'tabler-chart-bar',
date: data.map((d: any) => formatDate(d.date)),
series: [{ data: data.map((d: any) => d.orders) }]
},
{
type: 'sales',
avatarIcon: 'tabler-currency-dollar',
date: data.map((d: any) => formatDate(d.date)),
series: [{ data: data.map((d: any) => d.sales) }]
}
]
}
if (isLoading) return <Loading />
return (
@@ -89,26 +60,8 @@ const DashboardOrder = () => {
/>
</Grid>
<Grid size={{ xs: 12, lg: 12 }}>
<EarningReportsWithTabs data={transformSalesData(data?.data)} />
<OrdersReport title='Sales Report' orderData={data?.data as RecentSale[]} />
</Grid>
{/* <Grid size={{ xs: 12, md: 6, lg: 4 }}>
<RadarSalesChart />
</Grid>
<Grid size={{ xs: 12, md: 6, lg: 4 }}>
<SalesByCountries />
</Grid>
<Grid size={{ xs: 12, md: 6, lg: 4 }}>
<ProjectStatus />
</Grid>
<Grid size={{ xs: 12, md: 6, lg: 4 }}>
<ActiveProjects />
</Grid>
<Grid size={{ xs: 12, md: 6 }}>
<LastTransaction />
</Grid>
<Grid size={{ xs: 12, md: 6 }}>
<ActivityTimeline />
</Grid> */}
</Grid>
)
}