✨ 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
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
/**
|
|
* Internationalization utilities for WooNooW Admin SPA
|
|
* Uses WordPress i18n functions via wp.i18n
|
|
*/
|
|
|
|
// WordPress i18n is loaded globally
|
|
declare const wp: {
|
|
i18n: {
|
|
__: (text: string, domain: string) => string;
|
|
_x: (text: string, context: string, domain: string) => string;
|
|
_n: (single: string, plural: string, number: number, domain: string) => string;
|
|
sprintf: (format: string, ...args: any[]) => string;
|
|
};
|
|
};
|
|
|
|
const TEXT_DOMAIN = 'woonoow';
|
|
|
|
/**
|
|
* Translate a string
|
|
*/
|
|
export function __(text: string): string {
|
|
if (typeof wp !== 'undefined' && wp.i18n && wp.i18n.__) {
|
|
return wp.i18n.__(text, TEXT_DOMAIN);
|
|
}
|
|
return text; // Fallback to original text
|
|
}
|
|
|
|
/**
|
|
* Translate a string with context
|
|
*/
|
|
export function _x(text: string, context: string): string {
|
|
if (typeof wp !== 'undefined' && wp.i18n && wp.i18n._x) {
|
|
return wp.i18n._x(text, context, TEXT_DOMAIN);
|
|
}
|
|
return text;
|
|
}
|
|
|
|
/**
|
|
* Translate plural forms
|
|
*/
|
|
export function _n(single: string, plural: string, number: number): string {
|
|
if (typeof wp !== 'undefined' && wp.i18n && wp.i18n._n) {
|
|
return wp.i18n._n(single, plural, number, TEXT_DOMAIN);
|
|
}
|
|
return number === 1 ? single : plural;
|
|
}
|
|
|
|
/**
|
|
* sprintf-style formatting
|
|
*/
|
|
export function sprintf(format: string, ...args: any[]): string {
|
|
if (typeof wp !== 'undefined' && wp.i18n && wp.i18n.sprintf) {
|
|
return wp.i18n.sprintf(format, ...args);
|
|
}
|
|
// Simple fallback
|
|
return format.replace(/%s/g, () => String(args.shift() || ''));
|
|
}
|