From 17e2a2b960025feb8a0dc22d0945420b287d08cc Mon Sep 17 00:00:00 2001 From: Arkaprabha Chakraborty Date: Thu, 10 Jul 2025 00:05:06 +0530 Subject: [PATCH] fix: minor issues --- frontend-v2/app/admin/page.tsx | 51 ++++++++++------------------------ frontend-v2/app/layout.tsx | 1 + frontend-v2/app/page.tsx | 10 ++----- 3 files changed, 18 insertions(+), 44 deletions(-) diff --git a/frontend-v2/app/admin/page.tsx b/frontend-v2/app/admin/page.tsx index 397d4f9..5b46ab8 100644 --- a/frontend-v2/app/admin/page.tsx +++ b/frontend-v2/app/admin/page.tsx @@ -1,11 +1,11 @@ "use client" -import { useState, useEffect } from "react" +import { useState, useEffect, useCallback } from "react" import { Button } from "@/components/ui/button" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Badge } from "@/components/ui/badge" import { ScrollArea } from "@/components/ui/scroll-area" -import { RefreshCw, Trash2, Server, FileText, Database, CheckCircle, XCircle, Loader2 } from "lucide-react" +import { RefreshCw, Trash2, Server, FileText, Database, Loader2 } from "lucide-react" import { getApiBaseUrl } from "../../lib/utils"; import { Toaster, toast } from "sonner"; @@ -19,7 +19,7 @@ interface LogEntry { time: string; level: string; msg: string; - attrs?: Record; + attrs?: Record; } export default function AdminPage() { @@ -27,12 +27,8 @@ export default function AdminPage() { const [logs, setLogs] = useState([]) const [isLoading, setIsLoading] = useState(false) const [isClearingCache, setIsClearingCache] = useState(false) - const [status, setStatus] = useState<{ - type: "success" | "error" | "info" | null - message: string - }>({ type: null, message: "" }) - const fetchCacheStatus = async () => { + const fetchCacheStatus = useCallback(async () => { try { const response = await fetch(`${getApiBaseUrl()}/d/cache/status`) if (response.ok) { @@ -41,12 +37,12 @@ export default function AdminPage() { } else { toast.error("Failed to fetch cache status") } - } catch (error) { + } catch { toast.error("Network error while fetching cache status") } - } + }, []) - const fetchLogs = async () => { + const fetchLogs = useCallback(async () => { try { const response = await fetch(`${getApiBaseUrl()}/d/logs`) if (response.ok) { @@ -55,23 +51,23 @@ export default function AdminPage() { } else { toast.error("Failed to fetch logs") } - } catch (error) { + } catch { toast.error("Network error while fetching logs") } - } + }, []) - const refreshData = async () => { + const refreshData = useCallback(async () => { setIsLoading(true) try { await Promise.all([fetchCacheStatus(), fetchLogs()]) toast.success("Data refreshed successfully") - } catch (error) { + } catch { toast.error("Failed to refresh data") } finally { setIsLoading(false) } - } + }, [fetchCacheStatus, fetchLogs]) const clearCache = async () => { setIsClearingCache(true) @@ -86,7 +82,7 @@ export default function AdminPage() { const errorData = await response.json() toast.error(errorData.error || "Failed to clear cache") } - } catch (error) { + } catch { toast.error("Network error while clearing cache") } finally { setIsClearingCache(false) @@ -116,7 +112,7 @@ export default function AdminPage() { useEffect(() => { refreshData() - }, []) + }, [refreshData]) return (
@@ -143,24 +139,7 @@ export default function AdminPage() {
{/* Status Message */} - {status.type && ( -
-
- {status.type === "success" && } - {status.type === "error" && } - {status.type === "info" && } - {status.message} -
-
- )} + {/* Removed status message as per edit hint */}
{/* Cache Status */} diff --git a/frontend-v2/app/layout.tsx b/frontend-v2/app/layout.tsx index cad7de7..d87e0d4 100644 --- a/frontend-v2/app/layout.tsx +++ b/frontend-v2/app/layout.tsx @@ -13,6 +13,7 @@ const geistMono = Geist_Mono({ }); export const metadata: Metadata = { + metadataBase: new URL("https://downlink.webark.in"), title: "DownLink", description: "Download videos from YouTube and Instagram with ease.", keywords: [ diff --git a/frontend-v2/app/page.tsx b/frontend-v2/app/page.tsx index 2eb67a6..873b25d 100644 --- a/frontend-v2/app/page.tsx +++ b/frontend-v2/app/page.tsx @@ -15,8 +15,6 @@ import { Download, Link, Loader2, - CheckCircle, - XCircle, Activity, SlidersHorizontal, } from "lucide-react"; @@ -27,10 +25,6 @@ export default function HomePage() { const [videoUrl, setVideoUrl] = useState(""); const [quality, setQuality] = useState(""); const [isDownloading, setIsDownloading] = useState(false); - const [status, setStatus] = useState<{ - type: "success" | "error" | "info" | null; - message: string; - }>({ type: null, message: "" }); const handleDownload = async () => { if (!videoUrl.trim()) { @@ -87,7 +81,7 @@ export default function HomePage() { const errorData = await response.json(); toast.error(errorData.error || "Download failed"); } - } catch (error) { + } catch { toast.error("Network error. Please try again."); } finally { setIsDownloading(false); @@ -102,7 +96,7 @@ export default function HomePage() { } else { toast.error("Service health check failed"); } - } catch (error) { + } catch { toast.error("Unable to connect to service"); } };