From d7b5b11113be0f0aefaa4a9f71eebfd0ee560b3a Mon Sep 17 00:00:00 2001 From: TZGyn Date: Thu, 21 Sep 2023 06:04:21 +0800 Subject: [PATCH] Frontend update dashboard to show where the shortener redirects to, copy shortener and better responsive view --- react-frontend/src/pages/dashboard.tsx | 38 ++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/react-frontend/src/pages/dashboard.tsx b/react-frontend/src/pages/dashboard.tsx index a5de4ac..98c0ee4 100644 --- a/react-frontend/src/pages/dashboard.tsx +++ b/react-frontend/src/pages/dashboard.tsx @@ -6,6 +6,9 @@ import { useParams } from 'react-router-dom' import { useEffect, useState } from 'react' import { Bar, BarChart, ResponsiveContainer, XAxis, YAxis } from 'recharts' +import { ArrowRight, Copy } from 'lucide-react' +import { useToast } from '@/components/ui/use-toast' +import { Toaster } from '@/components/ui/toaster' type Shortener = { id: number @@ -88,6 +91,15 @@ export default function Dashboard() { console.log(visitorData) } + const { toast } = useToast() + const copyLinkToClipboard = async (code: string) => { + await navigator.clipboard.writeText(backend_url + '/' + code) + toast({ + title: 'Link Copied', + description: `Copied ${backend_url + '/' + code} To Clipboard`, + }) + } + useEffect(() => { if (!shorteners.length) { getShorteners() @@ -103,8 +115,19 @@ export default function Dashboard() {
-
- {backend_url + '/' + shortenerId} +
+
+ copyLinkToClipboard(shorteners[0].code) + }> +
+ {backend_url + '/' + shortenerId} + +
+
+ + {shorteners[0]?.link}
@@ -146,13 +169,15 @@ export default function Dashboard() { Visitors - + - + - Top Countries + + Top Countries By Vistors + {countryVisitor.map((country) => { @@ -176,6 +201,7 @@ export default function Dashboard() {
+ ) } @@ -183,7 +209,7 @@ export default function Dashboard() { export function Overview({ visitorData }: { visitorData: VisitorData[] }) { return (