Refunded Orders
@@ -111,170 +99,14 @@ const DashboardOverview = () => {
{/* Top Products */}
-
-
-
-
-
Top Products
-
-
-
-
-
- |
- Product
- |
-
- Category
- |
-
- Qty Sold
- |
-
- Revenue
- |
-
- Avg Price
- |
-
- Orders
- |
-
-
-
- {salesData.top_products.map((product, index) => (
-
- |
-
-
- {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
-
-
-
-
-
- |
- Date
- |
-
- Sales
- |
-
- Orders
- |
-
- Items
- |
-
- Tax
- |
-
- Discount
- |
-
- Net Sales
- |
-
-
-
- {salesData.recent_sales.map((sale, index) => (
-
- |
- {formatDate(sale.date)}
- |
-
- {formatCurrency(sale.sales)}
- |
- {sale.orders} |
- {sale.items} |
-
- {formatCurrency(sale.tax)}
- |
-
- {formatCurrency(sale.discount)}
- |
-
- {formatCurrency(sale.net_sales)}
- |
-
- ))}
-
-
-
-
-
+
)}
>
diff --git a/src/app/[lang]/(dashboard)/(private)/dashboards/payment-methods/page.tsx b/src/app/[lang]/(dashboard)/(private)/dashboards/payment-methods/page.tsx
index cf4c6ef..bd5a706 100644
--- a/src/app/[lang]/(dashboard)/(private)/dashboards/payment-methods/page.tsx
+++ b/src/app/[lang]/(dashboard)/(private)/dashboards/payment-methods/page.tsx
@@ -5,27 +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 { usePaymentAnalytics } from '../../../../../../services/queries/analytics'
import { PaymentDataItem } from '../../../../../../types/services/analytic'
+import PaymentMethodReport from '../../../../../../views/dashboards/payment-methods/PaymentMethodReport'
const DashboardPayment = () => {
const { data, isLoading } = usePaymentAnalytics()
- const transformSalesData = (data: PaymentDataItem[]) => {
- return [
- {
- type: 'payment',
- avatarIcon: 'tabler-package',
- date: data.map((d: PaymentDataItem) => d.payment_method_name),
- series: [{ data: data.map((d: PaymentDataItem) => d.total_amount) }]
- }
- ]
- }
-
if (isLoading) return
return (
@@ -71,26 +60,8 @@ const DashboardPayment = () => {
/>
-
+
- {/*
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- */}
)
}
diff --git a/src/app/[lang]/(dashboard)/(private)/dashboards/products/page.tsx b/src/app/[lang]/(dashboard)/(private)/dashboards/products/page.tsx
index 463e39d..3575aca 100644
--- a/src/app/[lang]/(dashboard)/(private)/dashboards/products/page.tsx
+++ b/src/app/[lang]/(dashboard)/(private)/dashboards/products/page.tsx
@@ -10,6 +10,7 @@ import EarningReportsWithTabs from '@views/dashboards/crm/EarningReportsWithTabs
// Server Action Imports
import Loading from '../../../../../../components/layout/shared/Loading'
import { useProductSalesAnalytics } from '../../../../../../services/queries/analytics'
+import ProductSales from '../../../../../../views/dashboards/products/ProductSales'
const DashboardProduct = () => {
const { data, isLoading } = useProductSalesAnalytics()
@@ -47,67 +48,7 @@ const DashboardProduct = () => {
return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {/*
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- */}
+ {data?.data && }
)
}
diff --git a/src/utils/transform.ts b/src/utils/transform.ts
index a161f9d..df861eb 100644
--- a/src/utils/transform.ts
+++ b/src/utils/transform.ts
@@ -15,13 +15,11 @@ export const formatShortCurrency = (num: number): string => {
return num.toString()
}
-export const formatDate = (dateString: string) => {
- return new Date(dateString).toLocaleDateString('en-US', {
- year: 'numeric',
- month: 'long',
+export const formatDate = (dateString: any) => {
+ return new Date(dateString).toLocaleDateString('id-ID', {
day: 'numeric',
- hour: '2-digit',
- minute: '2-digit'
+ month: 'short',
+ year: 'numeric'
})
}
diff --git a/src/views/dashboards/orders/OrdersReport.tsx b/src/views/dashboards/orders/OrdersReport.tsx
new file mode 100644
index 0000000..cbb7221
--- /dev/null
+++ b/src/views/dashboards/orders/OrdersReport.tsx
@@ -0,0 +1,65 @@
+import { RecentSale } from '../../../types/services/analytic'
+import { formatCurrency, formatDate } from '../../../utils/transform'
+
+const OrdersReport = ({ orderData, title }: { orderData: RecentSale[]; title: string }) => {
+ return (
+
+
+
+
+
{title}
+
+
+
+
+
+ | Date |
+
+ Sales
+ |
+
+ Orders
+ |
+
+ Items
+ |
+ Tax |
+
+ Discount
+ |
+
+ Net Sales
+ |
+
+
+
+ {orderData.map((sale, index) => (
+
+ |
+ {formatDate(sale.date)}
+ |
+
+ {formatCurrency(sale.sales)}
+ |
+ {sale.orders} |
+ {sale.items} |
+
+ {formatCurrency(sale.tax)}
+ |
+
+ {formatCurrency(sale.discount)}
+ |
+
+ {formatCurrency(sale.net_sales)}
+ |
+
+ ))}
+
+
+
+
+
+ )
+}
+
+export default OrdersReport
diff --git a/src/views/dashboards/payment-methods/PaymentMethodReport.tsx b/src/views/dashboards/payment-methods/PaymentMethodReport.tsx
new file mode 100644
index 0000000..2ddafee
--- /dev/null
+++ b/src/views/dashboards/payment-methods/PaymentMethodReport.tsx
@@ -0,0 +1,44 @@
+import { PaymentDataItem } from '../../../types/services/analytic'
+import { formatCurrency } from '../../../utils/transform'
+
+const PaymentMethodReport = ({ payments }: { payments: PaymentDataItem[] }) => {
+ const ProgressBar = ({ percentage, color = 'bg-blue-500' }: any) => (
+
+ )
+
+ return (
+
+
+
+
+
Payment Methods
+
+
+ {payments.map(method => (
+
+
+ {method.payment_method_name}
+ {method.percentage.toFixed(1)}%
+
+
+
+ {formatCurrency(method.total_amount)}
+ {method.order_count} orders
+
+
+ ))}
+
+
+
+ )
+}
+
+export default PaymentMethodReport
diff --git a/src/views/dashboards/products/ProductSales.tsx b/src/views/dashboards/products/ProductSales.tsx
new file mode 100644
index 0000000..b3a49b8
--- /dev/null
+++ b/src/views/dashboards/products/ProductSales.tsx
@@ -0,0 +1,82 @@
+import { ProductData } from '../../../types/services/analytic'
+import { formatCurrency } from '../../../utils/transform'
+
+const ProductSales = ({ productData, title }: { productData: ProductData[], title: string }) => {
+ return (
+
+
+
+
+
{title}
+
+
+
+
+
+ |
+ Product
+ |
+
+ Category
+ |
+
+ Qty Sold
+ |
+
+ Revenue
+ |
+
+ Avg Price
+ |
+
+ Orders
+ |
+
+
+
+ {productData.map((product, index) => (
+
+ |
+
+
+ {product.product_name}
+
+ |
+
+
+ {product.category_name}
+
+ |
+
+ {product.quantity_sold}
+ |
+
+ {formatCurrency(product.revenue)}
+ |
+
+ {formatCurrency(product.average_price)}
+ |
+
+ {product.order_count}
+ |
+
+ ))}
+
+
+
+
+
+ )
+}
+
+export default ProductSales