Refactor UI imports and update component paths
Some checks failed
Build Frontend / build (push) Failing after 7s
Some checks failed
Build Frontend / build (push) Failing after 7s
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.
This commit is contained in:
@@ -5,7 +5,7 @@ import Dashboard from "@/components/dashboard/dashboard";
|
||||
import AnalyticsDashboard from '@/components/analytics/AnalyticsDashboard';
|
||||
import AnalyticsDashboardSkeleton from '@/components/analytics/AnalyticsDashboardSkeleton';
|
||||
import StoreSelector from '@/components/analytics/StoreSelector';
|
||||
import { getAnalyticsOverviewServer } from '@/lib/server-api';
|
||||
import { getAnalyticsOverviewServer } from '@/lib/api/server-api';
|
||||
import { fetchServer } from '@/lib/api';
|
||||
import { performance } from 'perf_hooks';
|
||||
import { Info, GitCommit, User, Zap, BarChart3 } from 'lucide-react';
|
||||
@@ -34,14 +34,14 @@ export default async function AnalyticsPage({
|
||||
|
||||
// Await searchParams as required by Next.js 15+
|
||||
const resolvedSearchParams = await searchParams;
|
||||
|
||||
|
||||
// Check for storeId in query parameters (for staff users)
|
||||
const storeId = resolvedSearchParams?.storeId;
|
||||
|
||||
|
||||
// Check for storeId in cookies (alternative method for staff users)
|
||||
const cookieStore = await cookies();
|
||||
const cookieStoreId = cookieStore.get('storeId')?.value;
|
||||
|
||||
|
||||
// Use query parameter first, then cookie, then undefined (for vendors)
|
||||
const finalStoreId = storeId || cookieStoreId;
|
||||
|
||||
@@ -73,7 +73,7 @@ export default async function AnalyticsPage({
|
||||
|
||||
<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" />
|
||||
<Info size={12} className="text-muted-foreground/80" />
|
||||
<span>v{panelVersion}</span>
|
||||
</div>
|
||||
|
||||
@@ -100,12 +100,12 @@ export default async function AnalyticsPage({
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('Error fetching analytics data:', error);
|
||||
|
||||
|
||||
// If it's a 401/403 error, redirect to login
|
||||
if (error instanceof Error && error.message.includes('401')) {
|
||||
redirect('/login');
|
||||
redirect('/auth/login');
|
||||
}
|
||||
|
||||
|
||||
// If it's a 400 error (missing storeId for staff), show store selector
|
||||
if (error instanceof Error && error.message.includes('400')) {
|
||||
return (
|
||||
@@ -122,7 +122,7 @@ export default async function AnalyticsPage({
|
||||
</Dashboard>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// For other errors, show a fallback
|
||||
return (
|
||||
<Dashboard>
|
||||
@@ -142,4 +142,4 @@ export default async function AnalyticsPage({
|
||||
</Dashboard>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user