212 lines
6.4 KiB
TypeScript
212 lines
6.4 KiB
TypeScript
import type {
|
|
DashboardStats,
|
|
SessionInfo,
|
|
} from '@/services/api/adminService';
|
|
|
|
const dailyRevenue = [
|
|
12400, 15820, 11250, 18640, 22100, 19880, 25400,
|
|
17320, 20950, 16780, 24110, 28840, 21560, 30120,
|
|
18940, 22670, 27450, 19830, 31200, 26780, 18440,
|
|
23900, 29150, 21880, 33500, 27640, 19220, 24880,
|
|
30750, 28410,
|
|
].map((revenue, index) => {
|
|
const day = String(index + 1).padStart(2, '0');
|
|
return {
|
|
date: `08-${day}`,
|
|
revenue,
|
|
orders: Math.max(4, Math.round(revenue / 1850)),
|
|
};
|
|
});
|
|
|
|
export const MOCK_DASHBOARD_STATS: DashboardStats = {
|
|
total_users: 184,
|
|
total_orders: 326,
|
|
total_products: 148,
|
|
total_brands: 22,
|
|
total_device_models: 86,
|
|
total_device_series: 31,
|
|
total_categories: 18,
|
|
revenue_all_time: 1852580,
|
|
revenue_last_30_days: 684320,
|
|
revenue_last_7_days: 186280,
|
|
orders_by_status: {
|
|
pending: 28,
|
|
confirmed: 42,
|
|
processing: 36,
|
|
shipped: 51,
|
|
delivered: 142,
|
|
cancelled: 18,
|
|
returned: 9,
|
|
},
|
|
revenue_chart_daily: dailyRevenue,
|
|
revenue_chart_monthly: [
|
|
{ label: 'January', revenue: 98200, orders: 42 },
|
|
{ label: 'February', revenue: 114500, orders: 51 },
|
|
{ label: 'March', revenue: 128800, orders: 58 },
|
|
{ label: 'April', revenue: 121400, orders: 54 },
|
|
{ label: 'May', revenue: 142600, orders: 63 },
|
|
{ label: 'June', revenue: 156200, orders: 71 },
|
|
{ label: 'July', revenue: 168900, orders: 76 },
|
|
{ label: 'August', revenue: 184320, orders: 82 },
|
|
],
|
|
top_products: [
|
|
{ name: 'iPhone 15 OLED Display Assembly', total_sold: 86, total_revenue: 412800 },
|
|
{ name: 'Samsung S23 Ultra Battery', total_sold: 64, total_revenue: 198400 },
|
|
{ name: 'iPhone 14 Charging Port Flex', total_sold: 51, total_revenue: 86700 },
|
|
{ name: 'OnePlus 12 Back Glass Panel', total_sold: 38, total_revenue: 64600 },
|
|
{ name: 'Pixel 8 Pro Camera Module', total_sold: 24, total_revenue: 91200 },
|
|
],
|
|
recent_orders: [
|
|
{
|
|
order_no: 'IFK-10482',
|
|
amount: 4899,
|
|
status: 'delivered',
|
|
payment_status: 'paid',
|
|
created_at: '2026-08-30T09:12:00Z',
|
|
customer_name: 'Arjun Mehta',
|
|
customer_email: 'arjun.mehta@gmail.com',
|
|
},
|
|
{
|
|
order_no: 'IFK-10481',
|
|
amount: 2199,
|
|
status: 'shipped',
|
|
payment_status: 'paid',
|
|
created_at: '2026-08-30T07:44:00Z',
|
|
customer_name: 'Priya Nair',
|
|
customer_email: 'priya.nair@gmail.com',
|
|
},
|
|
{
|
|
order_no: 'IFK-10480',
|
|
amount: 7499,
|
|
status: 'processing',
|
|
payment_status: 'paid',
|
|
created_at: '2026-08-29T18:21:00Z',
|
|
customer_name: 'Rahul Iyer',
|
|
customer_email: 'rahul.iyer@outlook.com',
|
|
},
|
|
{
|
|
order_no: 'IFK-10479',
|
|
amount: 1299,
|
|
status: 'confirmed',
|
|
payment_status: 'paid',
|
|
created_at: '2026-08-29T15:08:00Z',
|
|
customer_name: 'Sneha Kapoor',
|
|
customer_email: 'sneha.kapoor@gmail.com',
|
|
},
|
|
{
|
|
order_no: 'IFK-10478',
|
|
amount: 3499,
|
|
status: 'pending',
|
|
payment_status: 'unpaid',
|
|
created_at: '2026-08-29T11:36:00Z',
|
|
customer_name: 'Vikram Shah',
|
|
customer_email: 'vikram.shah@yahoo.com',
|
|
},
|
|
{
|
|
order_no: 'IFK-10477',
|
|
amount: 899,
|
|
status: 'cancelled',
|
|
payment_status: 'refunded',
|
|
created_at: '2026-08-28T20:02:00Z',
|
|
customer_name: 'Ananya Rao',
|
|
customer_email: 'ananya.rao@gmail.com',
|
|
},
|
|
],
|
|
low_stock_variants: 14,
|
|
out_of_stock_variants: 6,
|
|
total_stock_units: 4280,
|
|
};
|
|
|
|
export const MOCK_DASHBOARD_SESSIONS: SessionInfo[] = [
|
|
{
|
|
session_id: 'sess_ui_01',
|
|
user_id: 'usr_admin',
|
|
device_name: 'Office Desktop',
|
|
device_type: 'desktop',
|
|
browser: 'Chrome 128.0.0',
|
|
operating_system: 'Windows 11',
|
|
ip_address: '106.219.180.207',
|
|
expires_at: '2026-08-31T18:00:00Z',
|
|
is_active: true,
|
|
},
|
|
{
|
|
session_id: 'sess_ui_02',
|
|
user_id: 'usr_admin',
|
|
device_name: 'MacBook Pro',
|
|
device_type: 'desktop',
|
|
browser: 'Safari 18.2',
|
|
operating_system: 'macOS Sequoia',
|
|
ip_address: '49.36.112.44',
|
|
expires_at: '2026-08-31T16:30:00Z',
|
|
is_active: true,
|
|
},
|
|
{
|
|
session_id: 'sess_ui_03',
|
|
user_id: 'usr_manager',
|
|
device_name: 'Pixel 8',
|
|
device_type: 'mobile',
|
|
browser: 'Chrome 127.0.0',
|
|
operating_system: 'Android 15',
|
|
ip_address: '152.58.204.19',
|
|
expires_at: '2026-08-31T12:10:00Z',
|
|
is_active: true,
|
|
},
|
|
{
|
|
session_id: 'sess_ui_04',
|
|
user_id: 'usr_tech',
|
|
device_name: 'iPad Air',
|
|
device_type: 'tablet',
|
|
browser: 'Safari 18.1',
|
|
operating_system: 'iPadOS 18',
|
|
ip_address: '103.21.244.12',
|
|
expires_at: '2026-08-31T09:45:00Z',
|
|
is_active: true,
|
|
},
|
|
{
|
|
session_id: 'sess_ui_05',
|
|
user_id: 'usr_staff',
|
|
device_name: 'Store Counter PC',
|
|
device_type: 'desktop',
|
|
browser: 'Edge 127.0.0',
|
|
operating_system: 'Windows 10',
|
|
ip_address: '117.99.80.63',
|
|
expires_at: '2026-08-30T22:00:00Z',
|
|
is_active: true,
|
|
},
|
|
];
|
|
|
|
export function withDashboardMock(
|
|
stats: DashboardStats | null,
|
|
sessions: SessionInfo[],
|
|
): { stats: DashboardStats; sessions: SessionInfo[] } {
|
|
if (stats) {
|
|
return {
|
|
stats: {
|
|
total_users: stats.total_users ?? 0,
|
|
total_orders: stats.total_orders ?? 0,
|
|
total_products: stats.total_products ?? 0,
|
|
total_brands: stats.total_brands ?? 0,
|
|
total_device_models: stats.total_device_models ?? 0,
|
|
total_device_series: stats.total_device_series ?? 0,
|
|
total_categories: stats.total_categories ?? 0,
|
|
revenue_all_time: stats.revenue_all_time ?? 0,
|
|
revenue_last_30_days: stats.revenue_last_30_days ?? 0,
|
|
revenue_last_7_days: stats.revenue_last_7_days ?? 0,
|
|
orders_by_status: stats.orders_by_status ?? {},
|
|
revenue_chart_daily: stats.revenue_chart_daily ?? [],
|
|
revenue_chart_monthly: stats.revenue_chart_monthly ?? [],
|
|
top_products: stats.top_products ?? [],
|
|
recent_orders: stats.recent_orders ?? [],
|
|
low_stock_variants: stats.low_stock_variants ?? 0,
|
|
out_of_stock_variants: stats.out_of_stock_variants ?? 0,
|
|
total_stock_units: stats.total_stock_units ?? 0,
|
|
},
|
|
sessions: sessions ?? [],
|
|
};
|
|
}
|
|
|
|
return {
|
|
stats: MOCK_DASHBOARD_STATS,
|
|
sessions: MOCK_DASHBOARD_SESSIONS,
|
|
};
|
|
}
|