Files
WooNooW/admin-spa/src/routes/Dashboard/data/dummyTaxes.ts
dwindown 232059e928 feat: Complete Dashboard API Integration with Analytics Controller
 Features:
- Implemented API integration for all 7 dashboard pages
- Added Analytics REST API controller with 7 endpoints
- Full loading and error states with retry functionality
- Seamless dummy data toggle for development

📊 Dashboard Pages:
- Customers Analytics (complete)
- Revenue Analytics (complete)
- Orders Analytics (complete)
- Products Analytics (complete)
- Coupons Analytics (complete)
- Taxes Analytics (complete)
- Dashboard Overview (complete)

🔌 Backend:
- Created AnalyticsController.php with REST endpoints
- All endpoints return 501 (Not Implemented) for now
- Ready for HPOS-based implementation
- Proper permission checks

🎨 Frontend:
- useAnalytics hook for data fetching
- React Query caching
- ErrorCard with retry functionality
- TypeScript type safety
- Zero build errors

📝 Documentation:
- DASHBOARD_API_IMPLEMENTATION.md guide
- Backend implementation roadmap
- Testing strategy

🔧 Build:
- All pages compile successfully
- Production-ready with dummy data fallback
- Zero TypeScript errors
2025-11-04 11:19:00 +07:00

141 lines
2.8 KiB
TypeScript

/**
* Dummy Taxes Report Data
* Structure matches /woonoow/v1/analytics/taxes API response
*/
export interface TaxesOverview {
total_tax: number;
avg_tax_per_order: number;
orders_with_tax: number;
change_percent: number;
}
export interface TaxByRate {
rate_id: number;
rate: string;
percentage: number;
orders: number;
tax_amount: number;
}
export interface TaxByLocation {
country: string;
country_name: string;
state: string;
state_name: string;
orders: number;
tax_amount: number;
percentage: number;
}
export interface TaxChartData {
date: string;
tax: number;
orders: number;
}
export interface TaxesData {
overview: TaxesOverview;
by_rate: TaxByRate[];
by_location: TaxByLocation[];
chart_data: TaxChartData[];
}
// Generate 30 days of tax data
const generateChartData = (): TaxChartData[] => {
const data: TaxChartData[] = [];
const today = new Date();
for (let i = 29; i >= 0; i--) {
const date = new Date(today);
date.setDate(date.getDate() - i);
const orders = Math.floor(30 + Math.random() * 30);
const avgOrderValue = 250000 + Math.random() * 300000;
const tax = orders * avgOrderValue * 0.11;
data.push({
date: date.toISOString().split('T')[0],
tax: Math.round(tax),
orders,
});
}
return data;
};
export const DUMMY_TAXES_DATA: TaxesData = {
overview: {
total_tax: 37922500,
avg_tax_per_order: 30534,
orders_with_tax: 1242,
change_percent: 15.3,
},
by_rate: [
{
rate_id: 1,
rate: 'PPN 11%',
percentage: 11.0,
orders: 1242,
tax_amount: 37922500,
},
],
by_location: [
{
country: 'ID',
country_name: 'Indonesia',
state: 'JK',
state_name: 'DKI Jakarta',
orders: 486,
tax_amount: 14850000,
percentage: 39.2,
},
{
country: 'ID',
country_name: 'Indonesia',
state: 'JB',
state_name: 'Jawa Barat',
orders: 324,
tax_amount: 9900000,
percentage: 26.1,
},
{
country: 'ID',
country_name: 'Indonesia',
state: 'JT',
state_name: 'Jawa Tengah',
orders: 186,
tax_amount: 5685000,
percentage: 15.0,
},
{
country: 'ID',
country_name: 'Indonesia',
state: 'JI',
state_name: 'Jawa Timur',
orders: 124,
tax_amount: 3792250,
percentage: 10.0,
},
{
country: 'ID',
country_name: 'Indonesia',
state: 'BT',
state_name: 'Banten',
orders: 74,
tax_amount: 2263875,
percentage: 6.0,
},
{
country: 'ID',
country_name: 'Indonesia',
state: 'YO',
state_name: 'DI Yogyakarta',
orders: 48,
tax_amount: 1467375,
percentage: 3.9,
},
],
chart_data: generateChartData(),
};