fk
This commit is contained in:
@@ -6,6 +6,9 @@ import { Button } from "@/components/ui/button";
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { AnimatedStatsSection } from "@/components/animated-stats-section";
|
import { AnimatedStatsSection } from "@/components/animated-stats-section";
|
||||||
|
|
||||||
|
// Force the page to be dynamically rendered
|
||||||
|
export const dynamic = 'force-dynamic';
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
const PY_20 = 20;
|
const PY_20 = 20;
|
||||||
const PY_32 = 32;
|
const PY_32 = 32;
|
||||||
|
|||||||
17
lib/api.ts
17
lib/api.ts
@@ -45,13 +45,24 @@ export {
|
|||||||
type ShippingOptionsResponse,
|
type ShippingOptionsResponse,
|
||||||
} from './services/shipping-service';
|
} from './services/shipping-service';
|
||||||
|
|
||||||
|
// 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
|
// Re-export stats services
|
||||||
export {
|
export {
|
||||||
getPlatformStats,
|
getPlatformStats,
|
||||||
getVendorStats,
|
getVendorStats,
|
||||||
|
|
||||||
// Types
|
|
||||||
type PlatformStats,
|
|
||||||
} from './services/stats-service';
|
} from './services/stats-service';
|
||||||
|
|
||||||
// Re-export server API functions
|
// Re-export server API functions
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ export const getCustomerDetailsServer = async (userId: string): Promise<Customer
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Server-side platform stats function
|
// Server-side platform stats function
|
||||||
export async function getPlatformStatsServer(): Promise<any> {
|
export async function getPlatformStatsServer() {
|
||||||
try {
|
try {
|
||||||
// Try to fetch from server first
|
// Try to fetch from server first
|
||||||
const serverData = await fetchServer('/stats/platform')
|
const serverData = await fetchServer('/stats/platform')
|
||||||
@@ -131,21 +131,31 @@ export async function getPlatformStatsServer(): Promise<any> {
|
|||||||
// If API call failed or returned empty data, use sample data
|
// If API call failed or returned empty data, use sample data
|
||||||
console.info('Using sample stats data for demo');
|
console.info('Using sample stats data for demo');
|
||||||
return {
|
return {
|
||||||
totalProducts: 243,
|
orders: {
|
||||||
totalVendors: 15,
|
completed: 1289
|
||||||
totalOrders: 1289,
|
},
|
||||||
totalCustomers: 756,
|
vendors: {
|
||||||
gmv: 38450
|
total: 15
|
||||||
|
},
|
||||||
|
transactions: {
|
||||||
|
volume: 38450,
|
||||||
|
averageOrderValue: 29.83
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching platform stats (server):', error);
|
console.error('Error fetching platform stats (server):', error);
|
||||||
// Return default stats to prevent UI breakage
|
// Return default stats to prevent UI breakage
|
||||||
return {
|
return {
|
||||||
totalProducts: 0,
|
orders: {
|
||||||
totalVendors: 0,
|
completed: 0
|
||||||
totalOrders: 0,
|
},
|
||||||
totalCustomers: 0,
|
vendors: {
|
||||||
gmv: 0
|
total: 0
|
||||||
|
},
|
||||||
|
transactions: {
|
||||||
|
volume: 0,
|
||||||
|
averageOrderValue: 0
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
|
output: 'standalone',
|
||||||
images: {
|
images: {
|
||||||
remotePatterns: [
|
remotePatterns: [
|
||||||
{
|
{
|
||||||
@@ -24,6 +25,9 @@ const nextConfig = {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
experimental: {
|
||||||
|
serverExternalPackages: [],
|
||||||
|
},
|
||||||
// Reduce memory usage during builds
|
// Reduce memory usage during builds
|
||||||
onDemandEntries: {
|
onDemandEntries: {
|
||||||
// Period (in ms) where the server will keep pages in the buffer
|
// Period (in ms) where the server will keep pages in the buffer
|
||||||
|
|||||||
Reference in New Issue
Block a user