Skip to content

Commit b495f37

Browse files
authored
Merge pull request #1445 from mfts/marc/pm-90-hide-links-clicks-if-there-are-no-clicks
refactor: remove link clicks if there are none
2 parents 7a648fd + 663875b commit b495f37

File tree

1 file changed

+23
-42
lines changed

1 file changed

+23
-42
lines changed

components/visitors/visitor-clicks.tsx

Lines changed: 23 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,8 @@ export default function VisitorClicks({
5050
);
5151
}
5252

53-
if (!clickEvents) {
54-
return (
55-
<Card>
56-
<CardHeader>
57-
<CardTitle className="text-base font-medium">Link Clicks</CardTitle>
58-
</CardHeader>
59-
<CardContent>
60-
<div className="space-y-2">
61-
<Skeleton className="h-4 w-full" />
62-
<Skeleton className="h-4 w-3/4" />
63-
</div>
64-
</CardContent>
65-
</Card>
66-
);
53+
if (!clickEvents || clickEvents.data.length === 0) {
54+
return null;
6755
}
6856

6957
return (
@@ -72,36 +60,29 @@ export default function VisitorClicks({
7260
<CardTitle className="text-base font-medium">Link Clicks</CardTitle>
7361
</CardHeader>
7462
<CardContent>
75-
{clickEvents.data.length === 0 ? (
76-
<div className="text-sm text-gray-500">No links clicked yet</div>
77-
) : (
78-
<div className="space-y-4">
79-
{clickEvents.data.map((event, index) => (
80-
<div key={index} className="flex items-start space-x-3">
81-
<ExternalLink className="mt-0.5 h-4 w-4 flex-shrink-0 text-gray-400" />
82-
<div className="space-y-1">
83-
<div className="text-sm">
84-
<span className="font-medium">
85-
Page {event.page_number}
86-
</span>
87-
:{" "}
88-
<a
89-
href={event.href}
90-
target="_blank"
91-
rel="noopener noreferrer"
92-
className="text-blue-600 hover:underline"
93-
>
94-
{event.href}
95-
</a>
96-
</div>
97-
<div className="text-xs text-gray-500">
98-
{format(new Date(event.timestamp), "MMM d, yyyy HH:mm:ss")}
99-
</div>
63+
<div className="space-y-4">
64+
{clickEvents.data.map((event, index) => (
65+
<div key={index} className="flex items-start space-x-3">
66+
<ExternalLink className="mt-0.5 h-4 w-4 flex-shrink-0 text-gray-400" />
67+
<div className="space-y-1">
68+
<div className="text-sm">
69+
<span className="font-medium">Page {event.page_number}</span>:{" "}
70+
<a
71+
href={event.href}
72+
target="_blank"
73+
rel="noopener noreferrer"
74+
className="text-blue-600 hover:underline"
75+
>
76+
{event.href}
77+
</a>
78+
</div>
79+
<div className="text-xs text-gray-500">
80+
{format(new Date(event.timestamp), "MMM d, yyyy HH:mm:ss")}
10081
</div>
10182
</div>
102-
))}
103-
</div>
104-
)}
83+
</div>
84+
))}
85+
</div>
10586
</CardContent>
10687
</Card>
10788
);

0 commit comments

Comments
 (0)