Skip to content

Commit f1940bd

Browse files
committed
update package
1 parent a097756 commit f1940bd

4 files changed

Lines changed: 74 additions & 14 deletions

File tree

app/analytics/page.tsx

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use client';
22

33
import { useState, useEffect } from 'react';
4+
import { useSearchParams } from 'next/navigation';
45
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
56
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
67
import { Skeleton } from '@/components/ui/skeleton';
@@ -72,6 +73,9 @@ const COLORS = {
7273
const PIE_COLORS = [COLORS.primary, COLORS.secondary, COLORS.tertiary, COLORS.quaternary, COLORS.quinary];
7374

7475
export default function AnalyticsPage() {
76+
const searchParams = useSearchParams();
77+
const isEmptyPreview = searchParams.get('preview') === 'empty';
78+
7579
const [data, setData] = useState<AnalyticsData | null>(null);
7680
const [insights, setInsights] = useState<Insight[]>([]);
7781
const [loading, setLoading] = useState(true);
@@ -122,8 +126,24 @@ export default function AnalyticsPage() {
122126
};
123127

124128
useEffect(() => {
129+
// Skip fetch if in empty preview mode
130+
if (isEmptyPreview) {
131+
setLoading(false);
132+
setData({
133+
totalAnalyses: 0,
134+
maturityRate: 0,
135+
averageSweetness: 0,
136+
averageConfidence: 0,
137+
typeDistribution: [],
138+
trendData: [],
139+
skinQualityDistribution: [],
140+
sweetnessDistribution: [],
141+
});
142+
setInsights([]);
143+
return;
144+
}
125145
fetchAnalytics();
126-
}, []);
146+
}, [isEmptyPreview]);
127147

128148
const handleApplyFilters = () => {
129149
fetchAnalytics();
@@ -214,6 +234,35 @@ export default function AnalyticsPage() {
214234
return null;
215235
}
216236

237+
// Empty state when no data
238+
const isEmpty = data.totalAnalyses === 0;
239+
240+
if (isEmpty) {
241+
return (
242+
<div className="container mx-auto p-4 space-y-6">
243+
<div>
244+
<h1 className="text-3xl font-bold">Dashboard Analitik</h1>
245+
<p className="text-muted-foreground">
246+
Statistik dan tren analisis semangka & melon
247+
</p>
248+
</div>
249+
250+
<Card>
251+
<CardContent className="py-12 text-center">
252+
<TrendingUp className="mx-auto h-12 w-12 text-muted-foreground mb-4" />
253+
<h3 className="text-lg font-semibold mb-2">Belum Ada Data Analitik</h3>
254+
<p className="text-muted-foreground mb-4">
255+
Belum ada analisis yang dilakukan. Mulai analisis pertama Anda untuk melihat statistik!
256+
</p>
257+
<Button asChild>
258+
<a href="/">Mulai Analisis</a>
259+
</Button>
260+
</CardContent>
261+
</Card>
262+
</div>
263+
);
264+
}
265+
217266
return (
218267
<div className="container mx-auto p-4 space-y-6">
219268
{/* Header */}

app/history/page.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use client';
22

33
import { useState, useEffect } from 'react';
4+
import { useSearchParams } from 'next/navigation';
45
import Image from 'next/image';
56
import { Calendar, Filter, Search } from 'lucide-react';
67
import { Card, CardContent } from '@/components/ui/card';
@@ -43,6 +44,9 @@ interface HistoryResponse {
4344
}
4445

4546
export default function HistoryPage() {
47+
const searchParams = useSearchParams();
48+
const isEmptyPreview = searchParams.get('preview') === 'empty';
49+
4650
const [analyses, setAnalyses] = useState<Analysis[]>([]);
4751
const [loading, setLoading] = useState(true);
4852
const [error, setError] = useState<string | null>(null);
@@ -98,8 +102,15 @@ export default function HistoryPage() {
98102

99103
// Fetch on mount and when filters change
100104
useEffect(() => {
105+
// Skip fetch if in empty preview mode
106+
if (isEmptyPreview) {
107+
setLoading(false);
108+
setAnalyses([]);
109+
setPagination({ total: 0, totalPages: 0, hasNextPage: false, hasPreviousPage: false });
110+
return;
111+
}
101112
fetchAnalyses();
102-
}, [page, maturityFilter]);
113+
}, [page, maturityFilter, isEmptyPreview]);
103114

104115
// Handle analysis click
105116
const handleAnalysisClick = (analysis: Analysis) => {

bun.lock

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"clsx": "^2.1.1",
3838
"dexie": "^4.2.1",
3939
"lucide-react": "^0.468.0",
40-
"next": "16.0.3",
40+
"next": "16.0.7",
4141
"next-pwa": "^5.6.0",
4242
"next-themes": "^0.4.4",
4343
"react": "^19.0.0",

0 commit comments

Comments
 (0)