fix up
This commit is contained in:
@@ -27,12 +27,15 @@ interface User {
|
||||
export default async function AnalyticsPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: { storeId?: string };
|
||||
searchParams: Promise<{ storeId?: string }>;
|
||||
}) {
|
||||
const startTime = performance.now();
|
||||
|
||||
// Await searchParams as required by Next.js 15+
|
||||
const resolvedSearchParams = await searchParams;
|
||||
|
||||
// Check for storeId in query parameters (for staff users)
|
||||
const storeId = searchParams.storeId;
|
||||
const storeId = resolvedSearchParams?.storeId;
|
||||
|
||||
// Check for storeId in cookies (alternative method for staff users)
|
||||
const cookieStore = await cookies();
|
||||
@@ -74,7 +77,6 @@ export default async function AnalyticsPage({
|
||||
</Suspense>
|
||||
</div>
|
||||
|
||||
{/* Footer with version info */}
|
||||
<div className="fixed bottom-2 right-2 text-xs text-muted-foreground bg-background/80 backdrop-blur-sm px-2 py-1 rounded border border-border/50 z-50 flex items-center space-x-2">
|
||||
<div className="flex items-center gap-1">
|
||||
<Info size={12} className="text-muted-foreground/80" />
|
||||
|
||||
@@ -133,29 +133,6 @@ export default function AnalyticsDashboard({ initialData }: AnalyticsDashboardPr
|
||||
|
||||
{/* Analytics Tabs */}
|
||||
<div className="space-y-6">
|
||||
{/* Global Date Selector */}
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h2 className="text-xl font-semibold">Analytics Dashboard</h2>
|
||||
<p className="text-muted-foreground">
|
||||
Detailed insights into your business performance
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-sm text-muted-foreground">Time period:</span>
|
||||
<Select value={timeRange} onValueChange={setTimeRange}>
|
||||
<SelectTrigger className="w-32">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="7">7 days</SelectItem>
|
||||
<SelectItem value="30">30 days</SelectItem>
|
||||
<SelectItem value="90">90 days</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Tabs defaultValue="revenue" className="space-y-6">
|
||||
<TabsList className="grid w-full grid-cols-4">
|
||||
<TabsTrigger value="revenue" className="flex items-center gap-2">
|
||||
@@ -177,42 +154,18 @@ export default function AnalyticsDashboard({ initialData }: AnalyticsDashboardPr
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="revenue" className="space-y-6">
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold">Revenue Trends</h3>
|
||||
<p className="text-muted-foreground">
|
||||
Track your revenue performance over the selected time period
|
||||
</p>
|
||||
</div>
|
||||
<RevenueChart timeRange={timeRange} />
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="products" className="space-y-6">
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold">Product Performance</h3>
|
||||
<p className="text-muted-foreground">
|
||||
Analyze which products are performing best (all-time data)
|
||||
</p>
|
||||
</div>
|
||||
<ProductPerformanceChart />
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="customers" className="space-y-6">
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold">Customer Insights</h3>
|
||||
<p className="text-muted-foreground">
|
||||
Understand your customer base and behavior (all-time data)
|
||||
</p>
|
||||
</div>
|
||||
<CustomerInsightsChart />
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="orders" className="space-y-6">
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold">Order Analytics</h3>
|
||||
<p className="text-muted-foreground">
|
||||
Order status distribution for the selected time period
|
||||
</p>
|
||||
</div>
|
||||
<OrderAnalyticsChart timeRange={timeRange} />
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
|
||||
@@ -131,7 +131,7 @@ export default function ProductPerformanceChart() {
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>Product</TableHead>
|
||||
<TableHead className="text-right">Sold</TableHead>
|
||||
<TableHead className="text-right">Units Sold</TableHead>
|
||||
<TableHead className="text-right">Revenue</TableHead>
|
||||
<TableHead className="text-right">Orders</TableHead>
|
||||
<TableHead className="text-right">Avg Price</TableHead>
|
||||
@@ -152,14 +152,11 @@ export default function ProductPerformanceChart() {
|
||||
/>
|
||||
<div>
|
||||
<div className="font-medium">{product.name}</div>
|
||||
<div className="text-sm text-muted-foreground">
|
||||
{product.unitType}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell className="text-right font-medium">
|
||||
{product.totalSold.toFixed(2)}
|
||||
{parseInt(product.totalSold.toFixed(0)).toLocaleString()} {product.unitType}
|
||||
</TableCell>
|
||||
<TableCell className="text-right font-medium text-green-600">
|
||||
{formatGBP(product.totalRevenue)}
|
||||
|
||||
Reference in New Issue
Block a user