diff --git a/src/app/[lang]/(dashboard)/(private)/dashboards/overview/page.tsx b/src/app/[lang]/(dashboard)/(private)/dashboards/overview/page.tsx index bfed1f3..c0b24a0 100644 --- a/src/app/[lang]/(dashboard)/(private)/dashboards/overview/page.tsx +++ b/src/app/[lang]/(dashboard)/(private)/dashboards/overview/page.tsx @@ -1,98 +1,283 @@ 'use client' -// MUI Imports -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 React from 'react' import { useDashboardAnalytics } from '../../../../../../services/queries/analytics' -import { DashboardReport, PaymentDataItem, ProductData, RecentSale } from '../../../../../../types/services/analytic' +import Loading from '../../../../../../components/layout/shared/Loading' const DashboardOverview = () => { - const { data, isLoading } = useDashboardAnalytics() + // Sample data - replace with your actual data + const { data: salesData, isLoading } = useDashboardAnalytics() + + const formatCurrency = (amount: any) => { + return new Intl.NumberFormat('id-ID', { + style: 'currency', + currency: 'IDR', + minimumFractionDigits: 0 + }).format(amount) + } const formatDate = (dateString: any) => { return new Date(dateString).toLocaleDateString('id-ID', { + day: 'numeric', month: 'short', - day: 'numeric' + year: 'numeric' }) } - const transformSalesData = (data: DashboardReport) => { - return [ - { - type: 'products', - avatarIcon: 'tabler-package', - date: data.top_products.map((d: ProductData) => d.product_name), - series: [{ data: data.top_products.map((d: ProductData) => d.revenue) }] - }, - { - type: 'orders', - avatarIcon: 'tabler-shopping-cart', - date: data.recent_sales.map((d: RecentSale) => formatDate(d.date)), - series: [{ data: data.recent_sales.map((d: RecentSale) => d.net_sales) }] - }, - { - type: 'payments', - avatarIcon: 'tabler-credit-card-pay', - date: data.payment_methods.map((d: PaymentDataItem) => d.payment_method_name), - series: [{ data: data.payment_methods.map((d: PaymentDataItem) => d.total_amount) }] - }, - ] - } - if (isLoading) return + const MetricCard = ({ iconClass, title, value, subtitle, bgColor = 'bg-blue-500' }: any) => ( +
+
+
+

{title}

+

{value}

+ {subtitle &&

{subtitle}

} +
+
+ +
+
+
+ ) + + const ProgressBar = ({ percentage, color = 'bg-blue-500' }: any) => ( +
+
+
+ ) + return ( - - - - - - - - - - - - - - - - - + <> + {salesData && ( +
+ {/* Header */} + {/*
+

Sales Dashboard

+

+ {formatDate(salesData.date_from)} - {formatDate(salesData.date_to)} +

+
*/} + + {/* Overview Metrics */} +
+ + + + +
+ + {/* Additional Metrics */} +
+
+
+ +

Voided Orders

+
+

{salesData.overview.voided_orders}

+
+
+
+ +

Refunded Orders

+
+

{salesData.overview.refunded_orders}

+
+
+ +
+ {/* Top Products */} +
+
+
+ +

Top Products

+
+
+ + + + + + + + + + + + + {salesData.top_products.map((product, index) => ( + + + + + + + + + ))} + +
+ Product + + Category + + Qty Sold + + Revenue + + Avg Price + + Orders +
+
+ + {product.product_name} +
+
+ + {product.category_name} + + + {product.quantity_sold} + + {formatCurrency(product.revenue)} + + {formatCurrency(product.average_price)} + + {product.order_count} +
+
+
+
+ + {/* Payment Methods */} +
+
+
+ +

Payment Methods

+
+
+ {salesData.payment_methods.map(method => ( +
+
+ {method.payment_method_name} + {method.percentage.toFixed(1)}% +
+ +
+ {formatCurrency(method.total_amount)} + {method.order_count} orders +
+
+ ))} +
+
+
+
+ + {/* Recent Sales */} +
+
+
+ +

Recent Sales

+
+
+ + + + + + + + + + + + + + {salesData.recent_sales.map((sale, index) => ( + + + + + + + + + + ))} + +
+ Date + + Sales + + Orders + + Items + + Tax + + Discount + + Net Sales +
+ {formatDate(sale.date)} + + {formatCurrency(sale.sales)} + {sale.orders}{sale.items} + {formatCurrency(sale.tax)} + + {formatCurrency(sale.discount)} + + {formatCurrency(sale.net_sales)} +
+
+
+
+
+ )} + ) } diff --git a/src/components/layout/vertical/VerticalMenu.tsx b/src/components/layout/vertical/VerticalMenu.tsx index 54b83b3..abaa722 100644 --- a/src/components/layout/vertical/VerticalMenu.tsx +++ b/src/components/layout/vertical/VerticalMenu.tsx @@ -82,6 +82,8 @@ const VerticalMenu = ({ dictionary, scrollMenu }: Props) => { > }> {dictionary['navigation'].overview} + + }> {dictionary['navigation'].profitloss} {dictionary['navigation'].products} {dictionary['navigation'].orders} @@ -117,7 +119,7 @@ const VerticalMenu = ({ dictionary, scrollMenu }: Props) => { {dictionary['navigation'].list} - {dictionary['navigation'].addjustment} + {dictionary['navigation'].adjustment} {dictionary['navigation'].settings} @@ -134,23 +136,10 @@ const VerticalMenu = ({ dictionary, scrollMenu }: Props) => { }> {dictionary['navigation'].list} - {dictionary['navigation'].view} - - }> - {dictionary['navigation'].roles} - {dictionary['navigation'].permissions} + {/* {dictionary['navigation'].view} */} - {/* } - renderExpandedMenuItemIcon={{ icon: }} - menuSectionStyles={menuSectionStyles(verticalNavOptions, theme)} - > - - */} ) } diff --git a/src/data/dictionaries/ar.json b/src/data/dictionaries/ar.json index f1d047a..c99d8e2 100644 --- a/src/data/dictionaries/ar.json +++ b/src/data/dictionaries/ar.json @@ -18,7 +18,7 @@ "products": "منتجات", "list": "قائمة", "add": "يضيف", - "addjustment": "تعديل", + "adjustment": "تعديل", "category": "فئة", "overview": "نظرة عامة", "profitloss": "الربح والخسارة", @@ -27,6 +27,7 @@ "organization": "المنظمة", "outlet": "مخزن", "units": "وحدات", + "reports": "تقارير", "ingredients": "مكونات", "orders": "أوامر", "details": "تفاصيل", diff --git a/src/data/dictionaries/en.json b/src/data/dictionaries/en.json index c367431..18771ed 100644 --- a/src/data/dictionaries/en.json +++ b/src/data/dictionaries/en.json @@ -18,11 +18,12 @@ "products": "Products", "list": "List", "add": "Add", - "addjustment": "Addjustment", + "adjustment": "Adjustment", "category": "Category", "overview": "Overview", "profitloss": "Profit Loss", "units": "Units", + "reports": "Reports", "finance": "Finance", "paymentMethods": "Payment Methods", "organization": "Organization", diff --git a/src/data/dictionaries/fr.json b/src/data/dictionaries/fr.json index ea7e5a1..3215e14 100644 --- a/src/data/dictionaries/fr.json +++ b/src/data/dictionaries/fr.json @@ -18,7 +18,7 @@ "products": "Produits", "list": "Liste", "add": "Ajouter", - "addjustment": "Ajustement", + "adjustment": "Ajustement", "category": "Catégorie", "overview": "Aperçu", "profitloss": "Profit et perte", @@ -27,6 +27,7 @@ "organization": "Organisation", "outlet": "Point de vente", "units": "Unites", + "reports": "Rapports", "ingredients": "Ingrédients", "orders": "Ordres", "details": "Détails",