diff --git a/src/app/[lang]/(dashboard)/(private)/apps/report/sales/sales-product-category/page.tsx b/src/app/[lang]/(dashboard)/(private)/apps/report/sales/sales-product-category/page.tsx new file mode 100644 index 0000000..47f0e0c --- /dev/null +++ b/src/app/[lang]/(dashboard)/(private)/apps/report/sales/sales-product-category/page.tsx @@ -0,0 +1,18 @@ +import ReportTitle from '@/components/report/ReportTitle' +import ReportSalesProductCategoryContent from '@/views/apps/report/sales/sales-product-category/ReportSalesProductCategoryReport' +import Grid from '@mui/material/Grid2' + +const SalesProductCategoryReportPage = () => { + return ( + + + + + + + + + ) +} + +export default SalesProductCategoryReportPage diff --git a/src/views/apps/report/ReportSalesList.tsx b/src/views/apps/report/ReportSalesList.tsx index aab3e7b..1c809f1 100644 --- a/src/views/apps/report/ReportSalesList.tsx +++ b/src/views/apps/report/ReportSalesList.tsx @@ -30,13 +30,13 @@ const ReportSalesList: React.FC = () => { title: 'Penjualan per Produk', iconClass: 'tabler-receipt-2', link: getLocalizedUrl(`/apps/report/sales/sales-product`, locale as Locale) + }, + { + title: 'Penjualan per Kategori Produk', + iconClass: 'tabler-receipt-2', + link: getLocalizedUrl(`/apps/report/sales/sales-product-category`, locale as Locale) } // { - // title: 'Penjualan per Kategori Produk', - // iconClass: 'tabler-receipt-2', - // link: '' - // }, - // { // title: 'Penjualan Produk per Pelanggan', // iconClass: 'tabler-receipt-2', // link: '' diff --git a/src/views/apps/report/sales/sales-product-category/ReportSalesProductCategoryReport.tsx b/src/views/apps/report/sales/sales-product-category/ReportSalesProductCategoryReport.tsx new file mode 100644 index 0000000..4fe9f43 --- /dev/null +++ b/src/views/apps/report/sales/sales-product-category/ReportSalesProductCategoryReport.tsx @@ -0,0 +1,90 @@ +'use client' + +import DateRangePicker from '@/components/RangeDatePicker' +import { ReportItemHeader, ReportItemSubheader } from '@/components/report/ReportItem' +import { useCategoryAnalytics } from '@/services/queries/analytics' +import { formatCurrency, formatDateDDMMYYYY } from '@/utils/transform' +import { Button, Card, CardContent } from '@mui/material' +import { useState } from 'react' + +const ReportSalesProductCategoryContent = () => { + const [startDate, setStartDate] = useState(new Date()) + const [endDate, setEndDate] = useState(new Date()) + + const { data: category } = useCategoryAnalytics({ + date_from: formatDateDDMMYYYY(startDate!), + date_to: formatDateDDMMYYYY(endDate!) + }) + + const categorySummary = { + totalRevenue: category?.data?.reduce((sum, item) => sum + (item?.total_revenue || 0), 0) || 0, + orderCount: category?.data?.reduce((sum, item) => sum + (item?.order_count || 0), 0) || 0, + productCount: category?.data?.reduce((sum, item) => sum + (item?.product_count || 0), 0) || 0, + totalQuantity: category?.data?.reduce((sum, item) => sum + (item?.total_quantity || 0), 0) || 0 + } + + return ( + +
+
+ + +
+
+ + +
+ + + + + + + + + + + {category?.data?.map((c, index) => ( + + + + + + + )) || []} + + + + + + + + + +
NamaTotal ProdukQtyPendapatan
{c.category_name}{c.product_count}{c.total_quantity} + {formatCurrency(c.total_revenue)} +
TOTAL{categorySummary?.productCount ?? 0}{categorySummary?.totalQuantity ?? 0}{formatCurrency(categorySummary?.totalRevenue ?? 0)}
+
+ +
+
+ ) +} + +export default ReportSalesProductCategoryContent