Files
ember-market-frontend/lib/api/index.ts
g fe01f31538
Some checks failed
Build Frontend / build (push) Failing after 7s
Refactor UI imports and update component paths
Replaces imports from 'components/ui' with 'components/common' across the app and dashboard pages, and updates model and API imports to use new paths under 'lib'. Removes redundant authentication checks from several dashboard pages. Adds new dashboard components and utility files, and reorganizes hooks and services into the 'lib' directory for improved structure.
2026-01-13 05:02:13 +00:00

154 lines
4.0 KiB
TypeScript

// Re-export client API functions
export {
// Core client API functions
clientFetch,
fetchClient,
getAuthToken,
getCookie,
// Customer API
getCustomers,
getCustomerDetails,
// Orders API
exportOrdersToCSV,
// Types
type CustomerStats,
type CustomerResponse,
} from './api-client';
// Re-export product services
export {
getProducts,
getProductDetails,
createProduct,
updateProduct,
deleteProduct,
uploadProductImage,
getProductStock,
updateProductStock,
// Types
type Product,
type ProductsResponse,
type StockData,
} from '../services/product-service';
// Re-export shipping services
export {
getShippingOptions,
getShippingOption,
createShippingOption,
updateShippingOption,
deleteShippingOption,
// Types
type ShippingOption,
type ShippingOptionsResponse,
} from '../services/shipping-service';
// Re-export analytics services
export {
getAnalyticsOverview,
getRevenueTrends,
getProductPerformance,
getCustomerInsights,
getOrderAnalytics,
getAnalyticsOverviewWithStore,
getRevenueTrendsWithStore,
getProductPerformanceWithStore,
getCustomerInsightsWithStore,
getOrderAnalyticsWithStore,
getStoreIdForUser,
// Types
type AnalyticsOverview,
type RevenueData,
type ProductPerformance,
type CustomerInsights,
type OrderAnalytics,
} from '../services/analytics-service';
export { formatGBP, formatNumber } from '../utils/format';
// Define the PlatformStats interface to match the expected format
export interface PlatformStats {
orders: {
completed: number;
};
vendors: {
total: number;
};
transactions: {
volume: number;
averageOrderValue?: number;
};
}
// Re-export stats services
export {
getPlatformStats,
getVendorStats,
} from '../services/stats-service';
// Re-export server API functions
export {
fetchServer,
getCustomersServer,
getCustomerDetailsServer,
getPlatformStatsServer,
getAnalyticsOverviewServer,
getRevenueTrendsServer,
getProductPerformanceServer,
getCustomerInsightsServer,
getOrderAnalyticsServer,
type AnalyticsOverview as ServerAnalyticsOverview,
type RevenueData as ServerRevenueData,
type ProductPerformance as ServerProductPerformance,
type CustomerInsights as ServerCustomerInsights,
type OrderAnalytics as ServerOrderAnalytics,
} from './server-api';
// Get clientFetch first so we can use it in the compatibility functions
import { clientFetch } from './api-client';
import { getProductDetails, updateProduct } from '../services/product-service';
import { getPlatformStats } from '../services/stats-service';
// Add missing functions for backward compatibility
// These are functions from the old style that we need to maintain compatibility
export const fetchData = async (endpoint: string, options: any = {}) => {
console.warn('fetchData is deprecated, use clientFetch instead');
return clientFetch(endpoint, options);
};
export const apiRequest = async (endpoint: string, method = 'GET', data: any = null, token: string | null = null) => {
console.warn('apiRequest is deprecated, use clientFetch instead');
const options: RequestInit & { headers: Record<string, string> } = {
method,
headers: { 'Content-Type': 'application/json' },
body: data ? JSON.stringify(data) : undefined,
};
if (token) {
options.headers.Authorization = `Bearer ${token}`;
}
return clientFetch(endpoint, options);
};
// Product-specific compatibility functions
export const fetchProductData = async (productId: string, token?: string) => {
console.warn('fetchProductData is deprecated, use getProductDetails instead');
return getProductDetails(productId);
};
export const saveProductData = async (productData: any, productId: string, token?: string) => {
console.warn('saveProductData is deprecated, use updateProduct instead');
return updateProduct(productId, productData);
};
// Stats compatibility function
export const fetchPlatformStats = async () => {
console.warn('fetchPlatformStats is deprecated, use getPlatformStats instead');
return getPlatformStats();
};