diff --git a/.env.example b/.env.example
deleted file mode 100644
index 8be556e..0000000
--- a/.env.example
+++ /dev/null
@@ -1,7 +0,0 @@
-PG_DATABASE_URL="postgresql://user:password@host:5432/database"
-CH_DATABASE_URL="clickhouse://user:password@host:8123/database"
-REDIS_URL="redis://localhost:6379/0"
-NEXTAUTH_SECRET="test_secret"
-GOOGLE_CLIENT_ID="test-app-google.apps.googleusercontent.com"
-GOOGLE_CLIENT_SECRET="test-secret"
-REDIRECT_URL="https://eurl.dev"
diff --git a/app/app/(dashboard)/links/[id]/page.tsx b/app/app/(dashboard)/links/[id]/page.tsx
index f736ea7..341266d 100644
--- a/app/app/(dashboard)/links/[id]/page.tsx
+++ b/app/app/(dashboard)/links/[id]/page.tsx
@@ -108,34 +108,17 @@ export default function Page({
long_url: "https://example.com/e7b9f3a7-0a15-4b7d-8d62-0d5f1a52e73e",
created_at: new Date("2023-05-28T12:34:56Z"),
title: "Sample Title",
+ _count: {
+ click_analytics: 100
+ }
});
const router = useRouter();
useEffect(() => {
setLoading(true);
getLinkDetails(decodeId(params.id).toString()).then((res) => {
- if (res.status == HTTP_STATUS.NOT_FOUND) {
- toast.error("Link not found");
- router.push("/app/links");
- return;
- }
-
- if (res.link) {
- //@ts-ignore
- setfetchLink(res.link);
- //@ts-ignore
- setTitle(res.link.title);
- //@ts-ignore
- setShortcode(res.link.short_code);
- }
- //@ts-ignore
- // getAnalyticsAction(res.link.short_code).then((e) => {
- // //@ts-ignore
- // // setLink(e);
- // setNoDataSet(Object.keys(e.devices).length);
- // setLoading(false);
- // });
- setLoading(false);
+ setfetchLink(res.link)
+ setLoading(false)
});
}, [router, params.id]);
@@ -261,7 +244,7 @@ export default function Page({
Engagements
- {link.engagement}
+ {fetchLink._count.click_analytics}
Last 7 days
diff --git a/components/CardComponents/LinkCard.tsx b/components/CardComponents/LinkCard.tsx
index 1e7abb4..903f2e1 100644
--- a/components/CardComponents/LinkCard.tsx
+++ b/components/CardComponents/LinkCard.tsx
@@ -1,5 +1,6 @@
"use client";
import {
+ BarChart2,
Calendar,
Copy,
LinkIcon,
@@ -14,21 +15,32 @@ import { linkType } from "@/interfaces/types";
import { useState } from "react";
import { useRouter } from "next/navigation";
import encodeId from "@/lib/services/encodeId";
+import {
+ HoverCard,
+ HoverCardContent,
+ HoverCardTrigger,
+} from "@radix-ui/react-hover-card";
const months = [
- "January", "February", "March", "April", "May", "June",
- "July", "August", "September", "October", "November", "December"
+ "January",
+ "February",
+ "March",
+ "April",
+ "May",
+ "June",
+ "July",
+ "August",
+ "September",
+ "October",
+ "November",
+ "December",
];
-export function LinkCard({
- link,
-}: {
- link: linkType;
-}) {
- const REDIRECT_URL:string = process.env.REDIRECT_URL || "https://eurl.dev";
- const [shortCode,setShortcode] = useState(link.short_code);
- const shortLink:string = `${REDIRECT_URL}/${shortCode}`
- const [title,setTitle] = useState(link.title)
+export function LinkCard({ link }: { link: linkType }) {
+ const REDIRECT_URL: string = process.env.REDIRECT_URL || "https://eurl.dev";
+ const [shortCode, setShortcode] = useState(link.short_code);
+ const shortLink: string = `${REDIRECT_URL}/${shortCode}`;
+ const [title, setTitle] = useState(link.title);
const router = useRouter();
return (
@@ -39,11 +51,19 @@ export function LinkCard({
-
router.push(`/app/links/${encodeId(link.id)}`)} className="text-lg lg:w-[53%] w-full break-all font-bold hover:underline cursor-pointer">
+ router.push(`/app/links/${encodeId(link.id)}`)}
+ className="text-lg lg:w-[53%] w-full break-all font-bold hover:underline cursor-pointer"
+ >
{title}
-
-
+
Edit
@@ -62,33 +86,57 @@ export function LinkCard({
-
{
- window.open(
- shortLink,
- "_blank"
- )
- }} className="text-blue-400 mt-1 hover:underline cursor-pointer w-fit">
+ {
+ window.open(shortLink, "_blank");
+ }}
+ className="text-blue-400 mt-1 hover:underline cursor-pointer w-fit"
+ >
{shortLink}
- {
- window.open(
- link.long_url,
- "_blank"
- )
- }} className="mt-2 text-sm hover:underline cursor-pointer">
- {link.long_url.length >= 10?<>{link.long_url.slice(0,30)}.....>:<>{link.long_url}>}
+ {
+ window.open(link.long_url, "_blank");
+ }}
+ className="mt-2 text-sm hover:underline cursor-pointer"
+ >
+ {link.long_url.length >= 10 ? (
+ <>{link.long_url.slice(0, 30)}.....>
+ ) : (
+ <>{link.long_url}>
+ )}
+
+
+
+ {link._count.click_analytics}{" "}
+
+
+
+ Includes short link clicks, QR Code scans
+
+
+
+
-
{months[link.created_at.getMonth()]} {link.created_at.getDate()},{link.created_at.getFullYear()}
+
+ {months[link.created_at.getMonth()]} {link.created_at.getDate()}
+ ,{link.created_at.getFullYear()}
+