From 7bb89ce20232ecfd1837d74359f1a59f39dac06c Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Sat, 7 Sep 2024 09:12:48 +0200 Subject: [PATCH] style: style the code according to Prettier rules --- app/(auth)/_components/Card.tsx | 24 +- app/(auth)/_components/Mobilenav.tsx | 82 +- app/(auth)/_components/Sidebar.tsx | 100 +-- app/(auth)/admin/changelogs/layout.tsx | 4 +- app/(auth)/admin/changelogs/page.tsx | 394 +++++----- app/(auth)/admin/downloads/layout.tsx | 4 +- app/(auth)/admin/downloads/page.tsx | 438 +++++------ app/(auth)/admin/email/page.tsx | 220 +++--- app/(auth)/admin/layout.tsx | 18 +- app/(auth)/admin/mods/layout.tsx | 4 +- app/(auth)/admin/mods/page.tsx | 738 +++++++++--------- app/(auth)/admin/multi-logs/[slug]/page.tsx | 130 +-- app/(auth)/admin/multi-logs/layout.tsx | 4 +- app/(auth)/admin/multi-logs/page.tsx | 268 +++---- app/(auth)/admin/page.tsx | 24 +- app/(auth)/admin/vulnerabilities/layout.tsx | 4 +- app/(auth)/admin/vulnerabilities/page.tsx | 368 ++++----- app/(auth)/email-editor/page.tsx | 244 +++--- app/(auth)/layout.tsx | 10 +- app/(root)/blog/[slug]/page.tsx | 302 +++---- app/(root)/blog/page.tsx | 98 +-- app/(root)/changelogs/[slug]/page.tsx | 224 +++--- app/(root)/changelogs/layout.tsx | 56 +- app/(root)/changelogs/page.tsx | 168 ++-- app/(root)/contact/layout.tsx | 56 +- app/(root)/contact/page.tsx | 338 ++++---- app/(root)/contribute/page.tsx | 88 +-- app/(root)/downloads/layout.tsx | 60 +- app/(root)/downloads/page.tsx | 182 ++--- app/(root)/forum/page.tsx | 4 +- app/(root)/layout.tsx | 90 +-- app/(root)/mods/layout.tsx | 56 +- app/(root)/mods/page.tsx | 4 +- app/(root)/newsletter/page.tsx | 2 +- app/(root)/not-found.tsx | 26 +- app/(root)/page.tsx | 24 +- app/(root)/privacy-policy/page.tsx | 86 +- app/(root)/tos/page.tsx | 86 +- app/(root)/vulnerabilities/layout.tsx | 56 +- app/(root)/vulnerabilities/page.tsx | 268 +++---- app/api/auth/[...nextauth]/options.ts | 14 +- app/api/contact/route.ts | 112 +-- app/api/delete/downloads/[id]/route.ts | 38 +- app/api/delete/logs/[id]/route.ts | 38 +- app/api/delete/mods/[id]/route.ts | 38 +- app/api/delete/vulnerability/[id]/route.ts | 58 +- app/api/login/route.ts | 44 +- app/api/logs/route.ts | 22 +- app/api/mdx/pages/[slug]/route.ts | 160 ++-- app/api/mdx/pages/route.ts | 64 +- app/api/newsletter/send/route.ts | 94 +-- app/api/newsletter/subscriber/route.ts | 58 +- app/api/newsletter/test/route.ts | 76 +- app/api/subscribe/route.ts | 100 +-- app/api/update/mods/[id]/route.ts | 68 +- app/api/upload/route.ts | 2 +- app/api/uploadlogs/route.ts | 20 +- app/api/uploadmods/route.ts | 2 +- app/api/uploadthing/core.ts | 10 +- app/api/uploadthing/route.ts | 2 +- app/api/uploadvulnerabilities/route.ts | 18 +- app/api/vulnerabilities/route.ts | 22 +- app/layout.tsx | 95 ++- app/login/page.tsx | 2 +- app/not-found.tsx | 44 +- app/rss.xml/route.ts | 64 +- app/sitemap.ts | 46 +- components/cards/BlogCards.tsx | 196 ++--- components/cards/MonacoEditor.tsx | 36 +- components/cards/testimonialCard.tsx | 76 +- components/loader/prismLoader.tsx | 12 +- components/shared/About.tsx | 66 +- components/shared/FAQ.tsx | 2 +- components/shared/Footer.tsx | 190 ++--- components/shared/Hero.tsx | 294 +++---- components/shared/HeroCards.tsx | 322 ++++---- components/shared/HowItWorks.tsx | 54 +- components/shared/MobileNav.tsx | 124 +-- components/shared/Navbar.tsx | 140 ++-- components/shared/Newsletter.tsx | 240 +++--- components/shared/Partners.tsx | 76 +- components/shared/Statistics.tsx | 28 +- components/shared/Testimonials.tsx | 188 ++--- components/shared/copyButton.tsx | 38 +- components/shared/providers/AuthProvider.tsx | 2 +- .../shared/providers/changelogLayout.tsx | 18 +- components/shared/providers/themeprovider.tsx | 10 +- components/ui/accordion.tsx | 62 +- components/ui/animated-gradient-text.tsx | 4 +- components/ui/animated-shiny-text.tsx | 6 +- components/ui/avatar.tsx | 4 +- components/ui/badge.tsx | 10 +- components/ui/border-beam.tsx | 4 +- components/ui/button.tsx | 32 +- components/ui/card.tsx | 37 +- components/ui/dialog.tsx | 46 +- components/ui/dropdown-menu.tsx | 70 +- components/ui/form.tsx | 99 +-- components/ui/grid-pattern.tsx | 2 +- components/ui/heroVideoAction.tsx | 270 +++---- components/ui/icons.tsx | 208 ++--- components/ui/input.tsx | 12 +- components/ui/label.tsx | 18 +- components/ui/navigation-menu.tsx | 44 +- components/ui/pagination.tsx | 46 +- components/ui/select.tsx | 48 +- components/ui/separator.tsx | 14 +- components/ui/sheet.tsx | 10 +- components/ui/skeleton.tsx | 6 +- components/ui/table.tsx | 40 +- components/ui/textarea.tsx | 12 +- components/ui/theme-toggle.tsx | 2 +- components/ui/toast.tsx | 58 +- components/ui/toaster.tsx | 14 +- components/ui/use-toast.ts | 153 ++-- components/widgets/Banner.tsx | 182 ++--- components/widgets/num-tick.tsx | 82 +- lib/db.ts | 10 +- lib/getBlogPost.ts | 6 +- lib/nodemailer/nodemailer.ts | 20 +- lib/sanity.ts | 10 +- lib/uploadthing.ts | 2 +- lib/utils.ts | 6 +- lib/validations/validation.ts | 74 +- pages/_app.tsx | 28 +- 125 files changed, 5263 insertions(+), 5263 deletions(-) diff --git a/app/(auth)/_components/Card.tsx b/app/(auth)/_components/Card.tsx index 584104f..7a82b19 100644 --- a/app/(auth)/_components/Card.tsx +++ b/app/(auth)/_components/Card.tsx @@ -3,21 +3,21 @@ import Link from "next/link"; import { FC } from "react"; interface CardProps { - title: string; - url: string; + title: string; + url: string; } const Card: FC = ({ title, url }) => { - return ( -
- -
-

{title}

- -
- -
- ); + return ( +
+ +
+

{title}

+ +
+ +
+ ); }; export default Card; diff --git a/app/(auth)/_components/Mobilenav.tsx b/app/(auth)/_components/Mobilenav.tsx index d185248..09fee8c 100644 --- a/app/(auth)/_components/Mobilenav.tsx +++ b/app/(auth)/_components/Mobilenav.tsx @@ -9,49 +9,49 @@ import { Menu } from "lucide-react"; import Logo from "@/components/shared/Logo"; const MobileNav = () => { - const pathname = usePathname(); - return ( -
- - - + const pathname = usePathname(); + return ( +
+ + + -
- ); + return ( +
  • + + + {link.name} + +
  • + ); + })} + + + + + +
    + ); }; export default MobileNav; diff --git a/app/(auth)/_components/Sidebar.tsx b/app/(auth)/_components/Sidebar.tsx index d568eb0..ca53b4c 100644 --- a/app/(auth)/_components/Sidebar.tsx +++ b/app/(auth)/_components/Sidebar.tsx @@ -6,60 +6,60 @@ import { AdminLinks } from "@/constants"; import Logo from "@/components/shared/Logo"; const Sidebar = () => { - const pathname = usePathname(); - return ( - <> - + + ); }; export default Sidebar; diff --git a/app/(auth)/admin/changelogs/layout.tsx b/app/(auth)/admin/changelogs/layout.tsx index f534f4d..2419f7d 100644 --- a/app/(auth)/admin/changelogs/layout.tsx +++ b/app/(auth)/admin/changelogs/layout.tsx @@ -1,9 +1,9 @@ import type { Metadata } from "next"; export const metadata: Metadata = { - title: "Admin // Changelogs", + title: "Admin // Changelogs" }; export default function logPages({ children }: { children: React.ReactNode }) { - return <>{children}; + return <>{children}; } diff --git a/app/(auth)/admin/changelogs/page.tsx b/app/(auth)/admin/changelogs/page.tsx index 02a5ba3..2269d2d 100644 --- a/app/(auth)/admin/changelogs/page.tsx +++ b/app/(auth)/admin/changelogs/page.tsx @@ -5,21 +5,21 @@ import { useForm, SubmitHandler, useFieldArray } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { Button } from "@/components/ui/button"; import { - Form, - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, + Form, + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage } from "@/components/ui/form"; import { - Table, - TableBody, - TableCaption, - TableCell, - TableHead, - TableHeader, - TableRow, + Table, + TableBody, + TableCaption, + TableCell, + TableHead, + TableHeader, + TableRow } from "@/components/ui/table"; import { Input } from "@/components/ui/input"; import { logsSchema } from "@/lib/validations/validation"; @@ -27,206 +27,206 @@ import { z } from "zod"; import { useToast } from "@/components/ui/use-toast"; interface LogEntry { - _id: string; - version: string; - date: string; - bullets: { point: string }[]; + _id: string; + version: string; + date: string; + bullets: { point: string }[]; } type LogsFormValues = z.infer; const AdminLogPage = () => { - const [logs, setLogs] = useState([]); - const [error, setError] = useState(""); - const { toast } = useToast(); - const [loading, setLoading] = useState(false); + const [logs, setLogs] = useState([]); + const [error, setError] = useState(""); + const { toast } = useToast(); + const [loading, setLoading] = useState(false); - const form = useForm({ - resolver: zodResolver(logsSchema), - defaultValues: { - version: "", - date: "", - bullets: [{ point: "" }], - }, - }); + const form = useForm({ + resolver: zodResolver(logsSchema), + defaultValues: { + version: "", + date: "", + bullets: [{ point: "" }] + } + }); - const { fields, append, remove } = useFieldArray({ - control: form.control, - name: "bullets", - }); + const { fields, append, remove } = useFieldArray({ + control: form.control, + name: "bullets" + }); - const fetchLogs = async () => { - try { - const response = await fetch("/api/logs", { method: "GET" }); - if (response.ok) { - const data: LogEntry[] = await response.json(); - setLogs(data); - } else { - throw new Error(`HTTP error! status: ${response.status}`); - } - } catch (error: any) { - setError(error.message || "Failed to fetch logs"); - } - }; + const fetchLogs = async () => { + try { + const response = await fetch("/api/logs", { method: "GET" }); + if (response.ok) { + const data: LogEntry[] = await response.json(); + setLogs(data); + } else { + throw new Error(`HTTP error! status: ${response.status}`); + } + } catch (error: any) { + setError(error.message || "Failed to fetch logs"); + } + }; - const onSubmit: SubmitHandler = async (data) => { - setLoading(true); - const response = await fetch("/api/uploadlogs", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify(data), - }); + const onSubmit: SubmitHandler = async (data) => { + setLoading(true); + const response = await fetch("/api/uploadlogs", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(data) + }); - if (response.ok) { - form.reset(); - fetchLogs(); - setLoading(false); - toast({ description: "Logs successfully added" }); - } else { - setLoading(false); - toast({ description: "Upload Failed", variant: "destructive" }); - } - }; + if (response.ok) { + form.reset(); + fetchLogs(); + setLoading(false); + toast({ description: "Logs successfully added" }); + } else { + setLoading(false); + toast({ description: "Upload Failed", variant: "destructive" }); + } + }; - const deleteLog = async (id: string) => { - try { - const response = await fetch(`/api/delete/logs/${id}`, { - method: "DELETE", - }); - if (response.ok) { - fetchLogs(); - } else { - throw new Error(`HTTP error! status: ${response.status}`); - } - } catch (error: any) { - setError(error.message || "Failed to delete log"); - } - }; + const deleteLog = async (id: string) => { + try { + const response = await fetch(`/api/delete/logs/${id}`, { + method: "DELETE" + }); + if (response.ok) { + fetchLogs(); + } else { + throw new Error(`HTTP error! status: ${response.status}`); + } + } catch (error: any) { + setError(error.message || "Failed to delete log"); + } + }; - useEffect(() => { - fetchLogs(); - const interval = setInterval(() => { - fetchLogs(); - }, 10000); + useEffect(() => { + fetchLogs(); + const interval = setInterval(() => { + fetchLogs(); + }, 10000); - return () => clearInterval(interval); - }, []); + return () => clearInterval(interval); + }, []); - return ( -
    -

    Server Logs Form

    -
    - - ( - - Version Name - - - - - - )} - /> - ( - - Date - - - - - - )} - /> + return ( +
    +

    Server Logs Form

    + + + ( + + Version Name + + + + + + )} + /> + ( + + Date + + + + + + )} + /> - {fields.map((field, index) => ( - ( - - Key Point {index + 1} - - - - - - - )} - /> - ))} - - - - + {fields.map((field, index) => ( + ( + + Key Point {index + 1} + + + + + + + )} + /> + ))} + + + + - {/* Section to list and delete logs */} -
    -

    Existing Logs

    - {error &&

    {error}

    } - - - - Version - Date - Actions - - - - {logs - .slice() - .reverse() - .map((log) => ( - - - {log.version} - - - {log.date} - - - - - - ))} - -
    -
    -
    - ); + {/* Section to list and delete logs */} +
    +

    Existing Logs

    + {error &&

    {error}

    } + + + + Version + Date + Actions + + + + {logs + .slice() + .reverse() + .map((log) => ( + + + {log.version} + + + {log.date} + + + + + + ))} + +
    +
    +
    + ); }; export default AdminLogPage; diff --git a/app/(auth)/admin/downloads/layout.tsx b/app/(auth)/admin/downloads/layout.tsx index 9bb582f..cb690a1 100644 --- a/app/(auth)/admin/downloads/layout.tsx +++ b/app/(auth)/admin/downloads/layout.tsx @@ -1,9 +1,9 @@ import type { Metadata } from "next"; export const metadata: Metadata = { - title: "Admin // Downloads", + title: "Admin // Downloads" }; export default function logPages({ children }: { children: React.ReactNode }) { - return <>{children}; + return <>{children}; } diff --git a/app/(auth)/admin/downloads/page.tsx b/app/(auth)/admin/downloads/page.tsx index f91975f..c4f26eb 100644 --- a/app/(auth)/admin/downloads/page.tsx +++ b/app/(auth)/admin/downloads/page.tsx @@ -6,246 +6,246 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; import { Button } from "@/components/ui/button"; import { - Form, - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, + Form, + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { UploadButton } from "@/lib/uploadthing"; import { downloadSchema } from "@/lib/validations/validation"; import { useToast } from "@/components/ui/use-toast"; import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow } from "@/components/ui/table"; interface DownloadEntry { - _id: string; - fileName: string; - version: string; - downloadLink: string; - fileSize: string; + _id: string; + fileName: string; + version: string; + downloadLink: string; + fileSize: string; } const DownloadsPage = () => { - const { toast } = useToast(); - const [downloads, setDownloads] = useState([]); - const [error, setError] = useState(null); - const [loading, setLoading] = useState(false); + const { toast } = useToast(); + const [downloads, setDownloads] = useState([]); + const [error, setError] = useState(null); + const [loading, setLoading] = useState(false); - const form = useForm>({ - resolver: zodResolver(downloadSchema), - defaultValues: { - fileName: "", - version: "", - downloadLink: "", - fileSize: "", - }, - }); + const form = useForm>({ + resolver: zodResolver(downloadSchema), + defaultValues: { + fileName: "", + version: "", + downloadLink: "", + fileSize: "" + } + }); - const fetchDownloads = async () => { - try { - const response = await fetch("/api/downloads", { - method: "GET", - }); - if (response.ok) { - const data: DownloadEntry[] = await response.json(); - setDownloads(data); - } else { - throw new Error(`HTTP error! status: ${response.status}`); - } - } catch (error: any) { - setError(error.message || "Failed to fetch downloads"); - } - }; + const fetchDownloads = async () => { + try { + const response = await fetch("/api/downloads", { + method: "GET" + }); + if (response.ok) { + const data: DownloadEntry[] = await response.json(); + setDownloads(data); + } else { + throw new Error(`HTTP error! status: ${response.status}`); + } + } catch (error: any) { + setError(error.message || "Failed to fetch downloads"); + } + }; - useEffect(() => { - fetchDownloads(); - const interval = setInterval(() => { - fetchDownloads(); - }, 10000); + useEffect(() => { + fetchDownloads(); + const interval = setInterval(() => { + fetchDownloads(); + }, 10000); - return () => clearInterval(interval); - }, []); + return () => clearInterval(interval); + }, []); - const onSubmit: SubmitHandler> = async ( - data - ) => { - setLoading(true); - const response = await fetch("/api/upload", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(data), - }); + const onSubmit: SubmitHandler> = async ( + data + ) => { + setLoading(true); + const response = await fetch("/api/upload", { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify(data) + }); - if (response.ok) { - form.reset(); - fetchDownloads(); - setLoading(false); - toast({ description: "Download Successfully Updated" }); - } else { - console.error("Upload failed"); - setLoading(false); - toast({ description: "Uploading Failed", variant: "destructive" }); - } - }; + if (response.ok) { + form.reset(); + fetchDownloads(); + setLoading(false); + toast({ description: "Download Successfully Updated" }); + } else { + console.error("Upload failed"); + setLoading(false); + toast({ description: "Uploading Failed", variant: "destructive" }); + } + }; - const deleteDownload = async (id: string) => { - try { - const response = await fetch(`/api/delete/downloads/${id}`, { - method: "DELETE", - }); - if (response.ok) { - fetchDownloads(); - } else { - throw new Error(`HTTP error! status: ${response.status}`); - } - } catch (error: any) { - setError(error.message || "Failed to delete download"); - } - }; + const deleteDownload = async (id: string) => { + try { + const response = await fetch(`/api/delete/downloads/${id}`, { + method: "DELETE" + }); + if (response.ok) { + fetchDownloads(); + } else { + throw new Error(`HTTP error! status: ${response.status}`); + } + } catch (error: any) { + setError(error.message || "Failed to delete download"); + } + }; - return ( -
    -

    Downloads Form

    -
    - - ( - - File Name - - - - - - )} - /> - ( - - Version - - - - - - )} - /> - ( - - Download Link - { - field.onChange(res[0].url); - }} - onUploadError={(error: Error) => { - alert(`ERROR! ${error.message}`); - }} - /> - - - - - - )} - /> - ( - - File Size - - - - - - )} - /> - - - + return ( +
    +

    Downloads Form

    +
    + + ( + + File Name + + + + + + )} + /> + ( + + Version + + + + + + )} + /> + ( + + Download Link + { + field.onChange(res[0].url); + }} + onUploadError={(error: Error) => { + alert(`ERROR! ${error.message}`); + }} + /> + + + + + + )} + /> + ( + + File Size + + + + + + )} + /> + + + - {/* Section to list and delete downloads */} -
    -

    Existing Downloads

    - {error &&

    {error}

    } - - - - File Name - Version - - Download Link - - File Size - Actions - - - - {downloads - .slice() - .reverse() - .map((download) => ( - - - {download.fileName} - - - {download.version} - - - - {download.downloadLink} - - - - {download.fileSize} - - - - - - ))} - -
    -
    -
    - ); + {/* Section to list and delete downloads */} +
    +

    Existing Downloads

    + {error &&

    {error}

    } + + + + File Name + Version + + Download Link + + File Size + Actions + + + + {downloads + .slice() + .reverse() + .map((download) => ( + + + {download.fileName} + + + {download.version} + + + + {download.downloadLink} + + + + {download.fileSize} + + + + + + ))} + +
    +
    +
    + ); }; export default DownloadsPage; diff --git a/app/(auth)/admin/email/page.tsx b/app/(auth)/admin/email/page.tsx index 43db6ed..4e5cce0 100644 --- a/app/(auth)/admin/email/page.tsx +++ b/app/(auth)/admin/email/page.tsx @@ -4,130 +4,130 @@ import { useState, useEffect } from "react"; import { Button } from "@/components/ui/button"; import { useToast } from "@/components/ui/use-toast"; import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow } from "@/components/ui/table"; import { - Pagination, - PaginationContent, - PaginationItem, - PaginationLink, - PaginationNext, - PaginationPrevious, + Pagination, + PaginationContent, + PaginationItem, + PaginationLink, + PaginationNext, + PaginationPrevious } from "@/components/ui/pagination"; import Link from "next/link"; interface Subscriber { - email: string; - subscribedAt: string; + email: string; + subscribedAt: string; } const EmailPage = () => { - const [subscribers, setSubscribers] = useState([]); - const [currentPage, setCurrentPage] = useState(1); - const [totalPages, setTotalPages] = useState(0); - const { toast } = useToast(); + const [subscribers, setSubscribers] = useState([]); + const [currentPage, setCurrentPage] = useState(1); + const [totalPages, setTotalPages] = useState(0); + const { toast } = useToast(); - useEffect(() => { - // Function to fetch subscribers data - const fetchSubscribers = async () => { - try { - const res = await fetch( - `/api/newsletter/subscriber?page=${currentPage}` - ); - const data = await res.json(); - setSubscribers(data.subscribers); - setTotalPages(data.totalPages); - } catch (error) { - toast({ - title: "Error fetching subscribers", - description: `${error}`, - }); - } - }; + useEffect(() => { + // Function to fetch subscribers data + const fetchSubscribers = async () => { + try { + const res = await fetch( + `/api/newsletter/subscriber?page=${currentPage}` + ); + const data = await res.json(); + setSubscribers(data.subscribers); + setTotalPages(data.totalPages); + } catch (error) { + toast({ + title: "Error fetching subscribers", + description: `${error}` + }); + } + }; - // Fetch data initially - fetchSubscribers(); + // Fetch data initially + fetchSubscribers(); - // Set up interval to fetch data every 10 seconds - const intervalId = setInterval(fetchSubscribers, 10000); + // Set up interval to fetch data every 10 seconds + const intervalId = setInterval(fetchSubscribers, 10000); - // Clear interval on component unmount - return () => clearInterval(intervalId); - }, [currentPage, toast]); + // Clear interval on component unmount + return () => clearInterval(intervalId); + }, [currentPage, toast]); - return ( -
    -

    Newsletter Emails

    - - - -
    -

    Newsletter Subscribers

    -

    - Total subscribers: {subscribers.length} -

    - - - - Email - - Subscribed At - - - - - {subscribers.map((subscriber, idx) => ( - - - {subscriber.email} - - - {new Date(subscriber.subscribedAt).toLocaleDateString()} - - - ))} - -
    -
    - {totalPages > 1 && ( - - - - {currentPage > 1 && ( - setCurrentPage(currentPage - 1)} - /> - )} - - {Array.from({ length: totalPages }).map((_, i) => ( - - setCurrentPage(i + 1)} - > - {i + 1} - - - ))} - - {currentPage < totalPages && ( - setCurrentPage(currentPage + 1)} - /> - )} - - - - )} -
    -
    -
    - ); + return ( +
    +

    Newsletter Emails

    + + + +
    +

    Newsletter Subscribers

    +

    + Total subscribers: {subscribers.length} +

    + + + + Email + + Subscribed At + + + + + {subscribers.map((subscriber, idx) => ( + + + {subscriber.email} + + + {new Date(subscriber.subscribedAt).toLocaleDateString()} + + + ))} + +
    +
    + {totalPages > 1 && ( + + + + {currentPage > 1 && ( + setCurrentPage(currentPage - 1)} + /> + )} + + {Array.from({ length: totalPages }).map((_, i) => ( + + setCurrentPage(i + 1)} + > + {i + 1} + + + ))} + + {currentPage < totalPages && ( + setCurrentPage(currentPage + 1)} + /> + )} + + + + )} +
    +
    +
    + ); }; export default EmailPage; diff --git a/app/(auth)/admin/layout.tsx b/app/(auth)/admin/layout.tsx index b39fafe..0eb755f 100644 --- a/app/(auth)/admin/layout.tsx +++ b/app/(auth)/admin/layout.tsx @@ -2,15 +2,15 @@ import MobileNav from "../_components/Mobilenav"; import Sidebar from "../_components/Sidebar"; export default function PageLayout({ - children, + children }: { - children: React.ReactNode; + children: React.ReactNode; }) { - return ( -
    - - -
    {children}
    -
    - ); + return ( +
    + + +
    {children}
    +
    + ); } diff --git a/app/(auth)/admin/mods/layout.tsx b/app/(auth)/admin/mods/layout.tsx index 948a571..9c4f55c 100644 --- a/app/(auth)/admin/mods/layout.tsx +++ b/app/(auth)/admin/mods/layout.tsx @@ -1,9 +1,9 @@ import type { Metadata } from "next"; export const metadata: Metadata = { - title: "Admin // Mods", + title: "Admin // Mods" }; export default function logPages({ children }: { children: React.ReactNode }) { - return <>{children}; + return <>{children}; } diff --git a/app/(auth)/admin/mods/page.tsx b/app/(auth)/admin/mods/page.tsx index ece2940..f5d6159 100644 --- a/app/(auth)/admin/mods/page.tsx +++ b/app/(auth)/admin/mods/page.tsx @@ -6,401 +6,401 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; import { Button } from "@/components/ui/button"; import { - Form, - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, + Form, + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { UploadButton } from "@/lib/uploadthing"; import { modsSchema } from "@/lib/validations/validation"; import { useToast } from "@/components/ui/use-toast"; import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow } from "@/components/ui/table"; import { - Dialog, - DialogContent, - DialogTitle, - DialogTrigger, + Dialog, + DialogContent, + DialogTitle, + DialogTrigger } from "@/components/ui/dialog"; interface ModEntry { - _id: string; - fileName: string; - version: string; - downloadLink: string; - fileSize: string; + _id: string; + fileName: string; + version: string; + downloadLink: string; + fileSize: string; } const SvrjsModsAdminPage = () => { - const { toast } = useToast(); - const [mods, setMods] = useState([]); - const [editMod, setEditMod] = useState(null); - const [error, setError] = useState(null); - const [loading, setLoading] = useState(false); - const [dialogOpen, setDialogOpen] = useState(false); + const { toast } = useToast(); + const [mods, setMods] = useState([]); + const [editMod, setEditMod] = useState(null); + const [error, setError] = useState(null); + const [loading, setLoading] = useState(false); + const [dialogOpen, setDialogOpen] = useState(false); - const mainForm = useForm>({ - resolver: zodResolver(modsSchema), - defaultValues: { - fileName: "", - version: "", - downloadLink: "", - fileSize: "", - }, - }); + const mainForm = useForm>({ + resolver: zodResolver(modsSchema), + defaultValues: { + fileName: "", + version: "", + downloadLink: "", + fileSize: "" + } + }); - const dialogForm = useForm>({ - resolver: zodResolver(modsSchema), - defaultValues: { - fileName: "", - version: "", - downloadLink: "", - fileSize: "", - }, - }); + const dialogForm = useForm>({ + resolver: zodResolver(modsSchema), + defaultValues: { + fileName: "", + version: "", + downloadLink: "", + fileSize: "" + } + }); - useEffect(() => { - fetchMods(); - const interval = setInterval(() => { - fetchMods(); - }, 10000); + useEffect(() => { + fetchMods(); + const interval = setInterval(() => { + fetchMods(); + }, 10000); - return () => clearInterval(interval); - }, []); + return () => clearInterval(interval); + }, []); - useEffect(() => { - if (editMod) { - dialogForm.reset({ - fileName: editMod.fileName, - version: editMod.version, - downloadLink: editMod.downloadLink, - fileSize: editMod.fileSize, - }); - setDialogOpen(true); // Open dialog when a mod is being edited - } - }, [editMod]); + useEffect(() => { + if (editMod) { + dialogForm.reset({ + fileName: editMod.fileName, + version: editMod.version, + downloadLink: editMod.downloadLink, + fileSize: editMod.fileSize + }); + setDialogOpen(true); // Open dialog when a mod is being edited + } + }, [editMod]); - const fetchMods = async () => { - try { - const response = await fetch("/api/mods", { - method: "GET", - }); - if (response.ok) { - const data: ModEntry[] = await response.json(); - setMods(data); - } else { - throw new Error(`HTTP error! status: ${response.status}`); - } - } catch (error: any) { - setError(error.message || "Failed to fetch mods"); - } - }; + const fetchMods = async () => { + try { + const response = await fetch("/api/mods", { + method: "GET" + }); + if (response.ok) { + const data: ModEntry[] = await response.json(); + setMods(data); + } else { + throw new Error(`HTTP error! status: ${response.status}`); + } + } catch (error: any) { + setError(error.message || "Failed to fetch mods"); + } + }; - const onSubmit: SubmitHandler> = async (data) => { - setLoading(true); - try { - const response = editMod - ? await fetch(`/api/update/mods/${editMod._id}`, { - method: "PUT", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(data), - }) - : await fetch("/api/uploadmods", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(data), - }); + const onSubmit: SubmitHandler> = async (data) => { + setLoading(true); + try { + const response = editMod + ? await fetch(`/api/update/mods/${editMod._id}`, { + method: "PUT", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify(data) + }) + : await fetch("/api/uploadmods", { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify(data) + }); - if (response.ok) { - mainForm.reset(); - dialogForm.reset(); - fetchMods(); - setLoading(false); - setEditMod(null); - setDialogOpen(false); // Close dialog on successful submission - toast({ - description: "Successfully Saved Changes", - }); - } else { - console.error("Save failed"); - setLoading(false); - toast({ - description: "Save failed", - variant: "destructive", - }); - } - } catch (error) { - console.error("Save failed", error); - setLoading(false); - toast({ - description: "Save failed", - variant: "destructive", - }); - } - }; + if (response.ok) { + mainForm.reset(); + dialogForm.reset(); + fetchMods(); + setLoading(false); + setEditMod(null); + setDialogOpen(false); // Close dialog on successful submission + toast({ + description: "Successfully Saved Changes" + }); + } else { + console.error("Save failed"); + setLoading(false); + toast({ + description: "Save failed", + variant: "destructive" + }); + } + } catch (error) { + console.error("Save failed", error); + setLoading(false); + toast({ + description: "Save failed", + variant: "destructive" + }); + } + }; - const deleteMod = async (id: string) => { - try { - const response = await fetch(`/api/delete/mods/${id}`, { - method: "DELETE", - }); - if (response.ok) { - fetchMods(); - } else { - throw new Error(`HTTP error! status: ${response.status}`); - } - } catch (error: any) { - setError(error.message || "Failed to delete mod"); - } - }; + const deleteMod = async (id: string) => { + try { + const response = await fetch(`/api/delete/mods/${id}`, { + method: "DELETE" + }); + if (response.ok) { + fetchMods(); + } else { + throw new Error(`HTTP error! status: ${response.status}`); + } + } catch (error: any) { + setError(error.message || "Failed to delete mod"); + } + }; - return ( -
    -

    Mods Form

    -
    - - ( - - File Name - - - - - - )} - /> - ( - - Version - - - - - - )} - /> - ( - - Download Link - { - field.onChange(res[0].url); - }} - onUploadError={(error: Error) => { - alert(`ERROR! ${error.message}`); - }} - /> - - - - - - )} - /> - ( - - File Size - - - - - - )} - /> - - - + return ( +
    +

    Mods Form

    +
    + + ( + + File Name + + + + + + )} + /> + ( + + Version + + + + + + )} + /> + ( + + Download Link + { + field.onChange(res[0].url); + }} + onUploadError={(error: Error) => { + alert(`ERROR! ${error.message}`); + }} + /> + + + + + + )} + /> + ( + + File Size + + + + + + )} + /> + + + - {/* Section to list and delete mods */} -
    -

    Existing Mods

    - {error &&

    {error}

    } - - - - File Name - Version - - Download Link - - File Size - Actions - - - - {mods - .slice() - .reverse() - .map((mod) => ( - - - {mod.fileName} - - - {mod.version} - - - - {mod.downloadLink} - - - - {mod.fileSize} - - - - - - - - Edit Content + {/* Section to list and delete mods */} +
    +

    Existing Mods

    + {error &&

    {error}

    } +
    + + + File Name + Version + + Download Link + + File Size + Actions + + + + {mods + .slice() + .reverse() + .map((mod) => ( + + + {mod.fileName} + + + {mod.version} + + + + {mod.downloadLink} + + + + {mod.fileSize} + + + + + + + + Edit Content -
    - - ( - - File Name - - - - - - )} - /> - ( - - Version - - - - - - )} - /> - ( - - Download Link - { - field.onChange(res[0].url); - }} - onUploadError={(error: Error) => { - alert(`ERROR! ${error.message}`); - }} - /> - - - - - - )} - /> - ( - - File Size - - - - - - )} - /> - - - -
    -
    - -
    -
    - ))} -
    -
    -
    -
    - ); +
    + + ( + + File Name + + + + + + )} + /> + ( + + Version + + + + + + )} + /> + ( + + Download Link + { + field.onChange(res[0].url); + }} + onUploadError={(error: Error) => { + alert(`ERROR! ${error.message}`); + }} + /> + + + + + + )} + /> + ( + + File Size + + + + + + )} + /> + + + + + + + + + ))} + + +
    + + ); }; export default SvrjsModsAdminPage; diff --git a/app/(auth)/admin/multi-logs/[slug]/page.tsx b/app/(auth)/admin/multi-logs/[slug]/page.tsx index f43f2ce..4665f7e 100644 --- a/app/(auth)/admin/multi-logs/[slug]/page.tsx +++ b/app/(auth)/admin/multi-logs/[slug]/page.tsx @@ -7,79 +7,79 @@ import { Button } from "@/components/ui/button"; import { useToast } from "@/components/ui/use-toast"; const MarkdownEditor = dynamic(() => import("@uiw/react-md-editor"), { - ssr: false, + ssr: false }); const EditPage = ({ params }: { params: { slug: string } }) => { - const router = useRouter(); - const { slug } = params; - const { toast } = useToast(); - const [title, setTitle] = useState(""); - const [content, setContent] = useState(""); - const [vulnerabilities, setVulnerabilities] = useState(""); - const [loading, setLoading] = useState(false); + const router = useRouter(); + const { slug } = params; + const { toast } = useToast(); + const [title, setTitle] = useState(""); + const [content, setContent] = useState(""); + const [vulnerabilities, setVulnerabilities] = useState(""); + const [loading, setLoading] = useState(false); - useEffect(() => { - if (slug) { - fetch(`/api/mdx/pages/${slug}`) - .then((response) => response.json()) - .then((data) => { - setTitle(data.title); - setContent(data.content); - setVulnerabilities(data.vulnerabilities || ""); - }) - .catch((error) => console.error("Failed to load page", error)); - } - }, [slug]); + useEffect(() => { + if (slug) { + fetch(`/api/mdx/pages/${slug}`) + .then((response) => response.json()) + .then((data) => { + setTitle(data.title); + setContent(data.content); + setVulnerabilities(data.vulnerabilities || ""); + }) + .catch((error) => console.error("Failed to load page", error)); + } + }, [slug]); - const savePage = async () => { - setLoading(true); - const response = await fetch(`/api/mdx/pages/${slug}`, { - method: "PUT", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ title, content, vulnerabilities }), - }); + const savePage = async () => { + setLoading(true); + const response = await fetch(`/api/mdx/pages/${slug}`, { + method: "PUT", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ title, content, vulnerabilities }) + }); - if (response.ok) { - setLoading(false); - toast({ description: "Page successfully updated" }); - router.push(`/admin/multi-logs/`); - } else { - setLoading(false); - toast({ description: "Page Updated" }); - } - }; + if (response.ok) { + setLoading(false); + toast({ description: "Page successfully updated" }); + router.push(`/admin/multi-logs/`); + } else { + setLoading(false); + toast({ description: "Page Updated" }); + } + }; - const handleEditorChange = (value?: string) => { - if (value !== undefined) { - setContent(value); - } - }; + const handleEditorChange = (value?: string) => { + if (value !== undefined) { + setContent(value); + } + }; - return ( -
    -

    Edit Page: {slug}

    - setTitle(e.target.value)} - placeholder="Page Title" - /> - -

    Vulnerabilities

    - setVulnerabilities(value || "")} - height={200} - /> - -
    - ); + return ( +
    +

    Edit Page: {slug}

    + setTitle(e.target.value)} + placeholder="Page Title" + /> + +

    Vulnerabilities

    + setVulnerabilities(value || "")} + height={200} + /> + +
    + ); }; export default EditPage; diff --git a/app/(auth)/admin/multi-logs/layout.tsx b/app/(auth)/admin/multi-logs/layout.tsx index 8c4c850..85ce248 100644 --- a/app/(auth)/admin/multi-logs/layout.tsx +++ b/app/(auth)/admin/multi-logs/layout.tsx @@ -1,9 +1,9 @@ import type { Metadata } from "next"; export const metadata: Metadata = { - title: "Admin // MultiLogs", + title: "Admin // MultiLogs" }; export default function logPages({ children }: { children: React.ReactNode }) { - return <>{children}; + return <>{children}; } diff --git a/app/(auth)/admin/multi-logs/page.tsx b/app/(auth)/admin/multi-logs/page.tsx index 9f1c6c1..a526c6b 100644 --- a/app/(auth)/admin/multi-logs/page.tsx +++ b/app/(auth)/admin/multi-logs/page.tsx @@ -2,157 +2,157 @@ import React, { useEffect, useState } from "react"; import { Button } from "@/components/ui/button"; import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow } from "@/components/ui/table"; import { Input } from "@/components/ui/input"; import { useRouter } from "next/navigation"; import { useToast } from "@/components/ui/use-toast"; import { - Dialog, - DialogContent, - DialogHeader, - DialogFooter, - DialogTitle, + Dialog, + DialogContent, + DialogHeader, + DialogFooter, + DialogTitle } from "@/components/ui/dialog"; interface PageEntry { - title: string; - slug: string; - content: string; + title: string; + slug: string; + content: string; } const MultiLogs = () => { - const [pages, setPages] = useState([]); - const { toast } = useToast(); - const router = useRouter(); - const [loading, setLoading] = useState(false); - const [open, setOpen] = useState(false); - const [pageTitle, setPageTitle] = useState(""); + const [pages, setPages] = useState([]); + const { toast } = useToast(); + const router = useRouter(); + const [loading, setLoading] = useState(false); + const [open, setOpen] = useState(false); + const [pageTitle, setPageTitle] = useState(""); - useEffect(() => { - fetch("/api/mdx/pages") - .then((response) => response.json()) - .then((data) => setPages(data)) - .catch((error) => console.error("Failed to load pages", error)); - }, []); + useEffect(() => { + fetch("/api/mdx/pages") + .then((response) => response.json()) + .then((data) => setPages(data)) + .catch((error) => console.error("Failed to load pages", error)); + }, []); - const createPage = async () => { - setLoading(true); - const slug = pageTitle.toLowerCase().replace(/\s+/g, "-"); - const response = await fetch("/api/mdx/pages", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ title: pageTitle, slug, content: "" }), - }); + const createPage = async () => { + setLoading(true); + const slug = pageTitle.toLowerCase().replace(/\s+/g, "-"); + const response = await fetch("/api/mdx/pages", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ title: pageTitle, slug, content: "" }) + }); - if (response.ok) { - const newPage = await response.json(); - setPages([...pages, newPage]); - setPageTitle(""); - setOpen(false); - router.push(`/admin/multi-logs/${slug}`); - toast({ description: "Page created successfully" }); - } else { - const errorData = await response.json(); - console.error("Failed to create page:", errorData); - toast({ description: `Error: ${errorData.message}` }); - } - setLoading(false); - }; + if (response.ok) { + const newPage = await response.json(); + setPages([...pages, newPage]); + setPageTitle(""); + setOpen(false); + router.push(`/admin/multi-logs/${slug}`); + toast({ description: "Page created successfully" }); + } else { + const errorData = await response.json(); + console.error("Failed to create page:", errorData); + toast({ description: `Error: ${errorData.message}` }); + } + setLoading(false); + }; - const deletePage = async (slug: string) => { - setLoading(true); - const response = await fetch(`/api/mdx/pages/${slug}`, { - method: "DELETE", - }); + const deletePage = async (slug: string) => { + setLoading(true); + const response = await fetch(`/api/mdx/pages/${slug}`, { + method: "DELETE" + }); - if (response.ok) { - setPages(pages.filter((page) => page.slug !== slug)); - toast({ description: "Page deleted successfully" }); - } else { - const errorData = await response.json(); - console.error("Failed to delete page:", errorData); - toast({ description: `Error: ${errorData.message}` }); - } - setLoading(false); - }; + if (response.ok) { + setPages(pages.filter((page) => page.slug !== slug)); + toast({ description: "Page deleted successfully" }); + } else { + const errorData = await response.json(); + console.error("Failed to delete page:", errorData); + toast({ description: `Error: ${errorData.message}` }); + } + setLoading(false); + }; - return ( -
    -
    -

    Create New Page

    - - - - - Enter Page Title - - setPageTitle(e.target.value)} - placeholder="Page Title" - /> - - - - - -
    -
    -

    Existing Pages

    -

    Total Pages: {pages.length}

    - - - - Slug - Actions - - - - {pages.map((page) => ( - - - - {page.slug} - - - - - - - - ))} - -
    -
    -
    - ); + return ( +
    +
    +

    Create New Page

    + + + + + Enter Page Title + + setPageTitle(e.target.value)} + placeholder="Page Title" + /> + + + + + +
    +
    +

    Existing Pages

    +

    Total Pages: {pages.length}

    + + + + Slug + Actions + + + + {pages.map((page) => ( + + + + {page.slug} + + + + + + + + ))} + +
    +
    +
    + ); }; export default MultiLogs; diff --git a/app/(auth)/admin/page.tsx b/app/(auth)/admin/page.tsx index e27ee67..24f8de8 100644 --- a/app/(auth)/admin/page.tsx +++ b/app/(auth)/admin/page.tsx @@ -3,19 +3,19 @@ import Card from "../_components/Card"; import { AdminDashboardLINKS } from "@/constants"; const AdminPage = () => { - return ( - <> -
    -

    Admin Page

    + return ( + <> +
    +

    Admin Page

    -
    - {AdminDashboardLINKS.map((item, idx) => ( - - ))} -
    -
    - - ); +
    + {AdminDashboardLINKS.map((item, idx) => ( + + ))} +
    +
    + + ); }; export default AdminPage; diff --git a/app/(auth)/admin/vulnerabilities/layout.tsx b/app/(auth)/admin/vulnerabilities/layout.tsx index 2181c4a..894ec15 100644 --- a/app/(auth)/admin/vulnerabilities/layout.tsx +++ b/app/(auth)/admin/vulnerabilities/layout.tsx @@ -1,9 +1,9 @@ import type { Metadata } from "next"; export const metadata: Metadata = { - title: "Admin // Vulnerabilities", + title: "Admin // Vulnerabilities" }; export default function logPages({ children }: { children: React.ReactNode }) { - return <>{children}; + return <>{children}; } diff --git a/app/(auth)/admin/vulnerabilities/page.tsx b/app/(auth)/admin/vulnerabilities/page.tsx index 65a3e3e..880499a 100644 --- a/app/(auth)/admin/vulnerabilities/page.tsx +++ b/app/(auth)/admin/vulnerabilities/page.tsx @@ -5,217 +5,217 @@ import { useForm, SubmitHandler, useFieldArray } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { Button } from "@/components/ui/button"; import { - Form, - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, + Form, + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage } from "@/components/ui/form"; import { - Table, - TableBody, - TableCaption, - TableCell, - TableHead, - TableHeader, - TableRow, + Table, + TableBody, + TableCaption, + TableCell, + TableHead, + TableHeader, + TableRow } from "@/components/ui/table"; import { Input } from "@/components/ui/input"; import { z } from "zod"; import { useToast } from "@/components/ui/use-toast"; import { vulnerabilitiesSchema } from "@/lib/validations/validation"; import { - Select, - SelectContent, - SelectItem, - SelectTrigger, + Select, + SelectContent, + SelectItem, + SelectTrigger } from "@/components/ui/select"; interface VulnerabiltyEntry { - _id: string; - version: string; - bullets: { point: string }[]; + _id: string; + version: string; + bullets: { point: string }[]; } type VulnerabiltiesForm = z.infer; const AdminLogPage = () => { - const [logs, setLogs] = useState([]); - const [error, setError] = useState(""); - const { toast } = useToast(); - const [loading, setLoading] = useState(false); + const [logs, setLogs] = useState([]); + const [error, setError] = useState(""); + const { toast } = useToast(); + const [loading, setLoading] = useState(false); - const form = useForm({ - resolver: zodResolver(vulnerabilitiesSchema), - defaultValues: { - version: "", - bullets: [{ point: "" }], - }, - }); + const form = useForm({ + resolver: zodResolver(vulnerabilitiesSchema), + defaultValues: { + version: "", + bullets: [{ point: "" }] + } + }); - const { fields, append, remove } = useFieldArray({ - control: form.control, - name: "bullets", - }); + const { fields, append, remove } = useFieldArray({ + control: form.control, + name: "bullets" + }); - const fetchLogs = async () => { - try { - const response = await fetch("/api/vulnerabilities", { method: "GET" }); - if (response.ok) { - const data: VulnerabiltyEntry[] = await response.json(); - setLogs(data); - } else { - throw new Error(`HTTP error! status: ${response.status}`); - } - } catch (error: any) { - setError(error.message || "Failed to fetch logs"); - } - }; + const fetchLogs = async () => { + try { + const response = await fetch("/api/vulnerabilities", { method: "GET" }); + if (response.ok) { + const data: VulnerabiltyEntry[] = await response.json(); + setLogs(data); + } else { + throw new Error(`HTTP error! status: ${response.status}`); + } + } catch (error: any) { + setError(error.message || "Failed to fetch logs"); + } + }; - const onSubmit: SubmitHandler = async (data) => { - setLoading(true); - const response = await fetch("/api/uploadvulnerabilities", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify(data), - }); + const onSubmit: SubmitHandler = async (data) => { + setLoading(true); + const response = await fetch("/api/uploadvulnerabilities", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(data) + }); - if (response.ok) { - form.reset(); - fetchLogs(); - setLoading(false); - toast({ description: "Logs successfully added" }); - } else { - setLoading(false); - toast({ description: "Upload Failed", variant: "destructive" }); - } - }; + if (response.ok) { + form.reset(); + fetchLogs(); + setLoading(false); + toast({ description: "Logs successfully added" }); + } else { + setLoading(false); + toast({ description: "Upload Failed", variant: "destructive" }); + } + }; - const deleteLog = async (id: string) => { - try { - const response = await fetch(`/api/delete/vulnerability/${id}`, { - method: "DELETE", - }); - if (response.ok) { - fetchLogs(); - } else { - throw new Error(`HTTP error! status: ${response.status}`); - } - } catch (error: any) { - setError(error.message || "Failed to delete log"); - } - }; + const deleteLog = async (id: string) => { + try { + const response = await fetch(`/api/delete/vulnerability/${id}`, { + method: "DELETE" + }); + if (response.ok) { + fetchLogs(); + } else { + throw new Error(`HTTP error! status: ${response.status}`); + } + } catch (error: any) { + setError(error.message || "Failed to delete log"); + } + }; - useEffect(() => { - fetchLogs(); - const interval = setInterval(() => { - fetchLogs(); - }, 10000); + useEffect(() => { + fetchLogs(); + const interval = setInterval(() => { + fetchLogs(); + }, 10000); - return () => clearInterval(interval); - }, []); + return () => clearInterval(interval); + }, []); - return ( -
    -

    Server Vulnerabilties Form

    -
    - - ( - - Version Name - - - - - - )} - /> + return ( +
    +

    Server Vulnerabilties Form

    + + + ( + + Version Name + + + + + + )} + /> - {fields.map((field, index) => ( - ( - - Key Point {index + 1} - - - - - - - )} - /> - ))} - - - - + {fields.map((field, index) => ( + ( + + Key Point {index + 1} + + + + + + + )} + /> + ))} + + + + - {/* Section to list and delete logs */} -
    -

    - Existing Vulnerabilties -

    - {error &&

    {error}

    } - - - - Version - Actions - - - - {logs - .slice() - .reverse() - .map((log) => ( - - - {log.version} - - - - - - ))} - -
    -
    -
    - ); + {/* Section to list and delete logs */} +
    +

    + Existing Vulnerabilties +

    + {error &&

    {error}

    } + + + + Version + Actions + + + + {logs + .slice() + .reverse() + .map((log) => ( + + + {log.version} + + + + + + ))} + +
    +
    +
    + ); }; export default AdminLogPage; diff --git a/app/(auth)/email-editor/page.tsx b/app/(auth)/email-editor/page.tsx index 9c53874..7e71dd7 100644 --- a/app/(auth)/email-editor/page.tsx +++ b/app/(auth)/email-editor/page.tsx @@ -8,140 +8,140 @@ import { EXAMPLE_A1 } from "@/constants"; import { useToast } from "@/components/ui/use-toast"; const EmailEditor = () => { - const { toast } = useToast(); - const [subject, setSubject] = useState(""); - const [previewContent, setPreviewContent] = useState(EXAMPLE_A1); - const [loading, setLoading] = useState(false); + const { toast } = useToast(); + const [subject, setSubject] = useState(""); + const [previewContent, setPreviewContent] = useState(EXAMPLE_A1); + const [loading, setLoading] = useState(false); - const validateInputs = () => { - if (!subject.trim() || !previewContent.trim()) { - toast({ - title: "Validation Error", - description: "Subject and content cannot be empty.", - variant: "destructive", - }); - return false; - } - return true; - }; + const validateInputs = () => { + if (!subject.trim() || !previewContent.trim()) { + toast({ + title: "Validation Error", + description: "Subject and content cannot be empty.", + variant: "destructive" + }); + return false; + } + return true; + }; - const handleSendAll = async () => { - if (!validateInputs()) return; + const handleSendAll = async () => { + if (!validateInputs()) return; - setLoading(true); - try { - const response = await fetch("/api/newsletter/send", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - subject: subject, - html: previewContent, - }), - }); + setLoading(true); + try { + const response = await fetch("/api/newsletter/send", { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + subject: subject, + html: previewContent + }) + }); - if (!response.ok) { - throw new Error("Network response was not ok"); - } + if (!response.ok) { + throw new Error("Network response was not ok"); + } - const result = await response.json(); - toast({ - title: "Success!", - description: result.message || "Emails sent successfully", - }); - } catch (error) { - console.error("Error:", error); - toast({ - title: "Uh oh!", - description: `Failed to send emails: ${error}`, - variant: "destructive", - }); - } finally { - setLoading(false); - } - }; + const result = await response.json(); + toast({ + title: "Success!", + description: result.message || "Emails sent successfully" + }); + } catch (error) { + console.error("Error:", error); + toast({ + title: "Uh oh!", + description: `Failed to send emails: ${error}`, + variant: "destructive" + }); + } finally { + setLoading(false); + } + }; - const handleSendTest = async () => { - if (!validateInputs()) return; + const handleSendTest = async () => { + if (!validateInputs()) return; - setLoading(true); - try { - const response = await fetch("/api/newsletter/test", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - subject: subject, - html: previewContent, - }), - }); + setLoading(true); + try { + const response = await fetch("/api/newsletter/test", { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + subject: subject, + html: previewContent + }) + }); - if (!response.ok) { - throw new Error("Network response was not ok"); - } + if (!response.ok) { + throw new Error("Network response was not ok"); + } - const result = await response.json(); - toast({ - title: "Success!", - description: result.message || "Test email sent successfully", - }); - } catch (error) { - console.error("Error:", error); - toast({ - title: "Uh oh!", - description: `Failed to send test email: ${error}`, - variant: "destructive", - }); - } finally { - setLoading(false); - } - }; + const result = await response.json(); + toast({ + title: "Success!", + description: result.message || "Test email sent successfully" + }); + } catch (error) { + console.error("Error:", error); + toast({ + title: "Uh oh!", + description: `Failed to send test email: ${error}`, + variant: "destructive" + }); + } finally { + setLoading(false); + } + }; - const handleEditorChange = (value: string) => { - setPreviewContent(value); - }; + const handleEditorChange = (value: string) => { + setPreviewContent(value); + }; - return ( -
    -
    - - Back - - setSubject(e.target.value)} - className="border rounded-md p-2" - /> - -
    - - -
    -
    + return ( +
    +
    + + Back + + setSubject(e.target.value)} + className="border rounded-md p-2" + /> + +
    + + +
    +
    -
    -

    - Email Preview -

    -
    -
    -
    - ); +
    +

    + Email Preview +

    +
    +
    +
    + ); }; export default EmailEditor; diff --git a/app/(auth)/layout.tsx b/app/(auth)/layout.tsx index 6bf5bb6..3b818c1 100644 --- a/app/(auth)/layout.tsx +++ b/app/(auth)/layout.tsx @@ -2,13 +2,9 @@ import React from "react"; import AuthProvider from "../../components/shared/providers/AuthProvider"; export default function AdminLayout({ - children, + children }: { - children: React.ReactNode; + children: React.ReactNode; }) { - return ( - - {children} - - ); + return {children}; } diff --git a/app/(root)/blog/[slug]/page.tsx b/app/(root)/blog/[slug]/page.tsx index b5ffe76..89ac979 100644 --- a/app/(root)/blog/[slug]/page.tsx +++ b/app/(root)/blog/[slug]/page.tsx @@ -19,7 +19,7 @@ import PrismLoader from "@/components/loader/prismLoader"; import { Button } from "@/components/ui/button"; async function getData(slug: string) { - const query = ` + const query = ` *[_type == "blog" && slug.current == '${slug}'] { "currentSlug": slug.current, title, @@ -28,177 +28,177 @@ async function getData(slug: string) { _createdAt }[0]`; - const data = await client.fetch(query); - return data; + const data = await client.fetch(query); + return data; } interface BlogSlugArticle { - currentSlug: string; - title: string; - content: any; - titleImage: string; - _createdAt: string; + currentSlug: string; + title: string; + content: any; + titleImage: string; + _createdAt: string; } export async function generateMetadata({ - params, + params }: { - params: { slug: string }; + params: { slug: string }; }): Promise { - const data = await getData(params.slug); + const data = await getData(params.slug); - if (!data) { - return { - title: "Not Found", - description: "Blog post not found", - }; - } + if (!data) { + return { + title: "Not Found", + description: "Blog post not found" + }; + } - return { - title: `${data.title} - SVRJS`, - description: data.smallDescription, - openGraph: { - title: `${data.title} - SVRJS`, - description: data.smallDescription, - url: `https://svrjs.org/blog/${data.currentSlug}`, - type: "website", - images: [ - { - url: urlFor(data.titleImage).url(), - width: 800, - height: 600, - alt: `${data.title} - SVRJS`, - }, - ], - }, - twitter: { - card: "summary_large_image", - site: "@SVR_JS", - title: `${data.title} - SVRJS`, - description: data.smallDescription, - images: [urlFor(data.titleImage).url()], - creator: "@SVR_JS", - }, - }; + return { + title: `${data.title} - SVRJS`, + description: data.smallDescription, + openGraph: { + title: `${data.title} - SVRJS`, + description: data.smallDescription, + url: `https://svrjs.org/blog/${data.currentSlug}`, + type: "website", + images: [ + { + url: urlFor(data.titleImage).url(), + width: 800, + height: 600, + alt: `${data.title} - SVRJS` + } + ] + }, + twitter: { + card: "summary_large_image", + site: "@SVR_JS", + title: `${data.title} - SVRJS`, + description: data.smallDescription, + images: [urlFor(data.titleImage).url()], + creator: "@SVR_JS" + } + }; } const customPortableTextComponents: PortableTextComponents = { - types: { - image: ({ value }) => { - return ( -
    - {value.alt - {value.caption && ( -

    - {value.caption} -

    - )} -
    - ); - }, - code: ({ value }) => { - const language = value.language || "javascript"; - const grammar = Prism.languages[language]; + types: { + image: ({ value }) => { + return ( +
    + {value.alt + {value.caption && ( +

    + {value.caption} +

    + )} +
    + ); + }, + code: ({ value }) => { + const language = value.language || "javascript"; + const grammar = Prism.languages[language]; - if (!grammar) { - console.error(`No grammar found for language: "${language}"`); - return ( -
    -						{value.code}
    -					
    - ); - } + if (!grammar) { + console.error(`No grammar found for language: "${language}"`); + return ( +
    +            {value.code}
    +          
    + ); + } - return ( -
    -
    -						{value.code}
    -					
    - - -
    - ); - }, - }, + return ( +
    +
    +            {value.code}
    +          
    + + +
    + ); + } + } }; export default async function BlogSlugArticle({ - params, + params }: { - params: { slug: string }; + params: { slug: string }; }) { - const data: BlogSlugArticle = await getData(params.slug); + const data: BlogSlugArticle = await getData(params.slug); - if (!data) { - notFound(); - } + if (!data) { + notFound(); + } - const formattedDate = format(new Date(data._createdAt), "MMMM d, yyyy"); + const formattedDate = format(new Date(data._createdAt), "MMMM d, yyyy"); - return ( - <> -
    -
    - - - - - - -
    -
    - {data.titleImage && ( -
    -

    - {data.title} -

    - {data.title} -

    - Uploaded at {formattedDate} -

    -
    - )} -
    - -
    - -
    -
    - - ); + return ( + <> +
    +
    + + + + + + +
    +
    + {data.titleImage && ( +
    +

    + {data.title} +

    + {data.title} +

    + Uploaded at {formattedDate} +

    +
    + )} +
    + +
    + +
    +
    + + ); } diff --git a/app/(root)/blog/page.tsx b/app/(root)/blog/page.tsx index a0d089f..51aa92a 100644 --- a/app/(root)/blog/page.tsx +++ b/app/(root)/blog/page.tsx @@ -6,61 +6,61 @@ import { Button } from "@/components/ui/button"; import Link from "next/link"; export const metadata: Metadata = { - title: "Blog - SVRJS", - description: - "Welcome to the SVR.JS Blog! Explore our latest blog posts featuring web development, web application security, and web server administration tips. Stay tuned for the latest SVR.JS updates.", - openGraph: { - title: "Blog - SVRJS", - description: - "Welcome to the SVR.JS Blog! Explore our latest blog posts featuring web development, web application security, and web server administration tips. Stay tuned for the latest SVR.JS updates.", - url: "https://svrjs.org/blog", - type: "website", - images: [ - { - url: "https://svrjs.vercel.app/metadata/svrjs-cover.png", - width: 800, - height: 600, - alt: "Blog - SVRJS", - }, - ], - }, - twitter: { - card: "summary_large_image", - site: "@SVR_JS", - title: "Blog - SVRJS", - description: - "Welcome to the SVR.JS Blog! Explore our latest blog posts featuring web development, web application security, and web server administration tips. Stay tuned for the latest SVR.JS updates.", - images: ["https://svrjs.vercel.app/metadata/svrjs-cover.png"], - creator: "@SVR_JS", - }, + title: "Blog - SVRJS", + description: + "Welcome to the SVR.JS Blog! Explore our latest blog posts featuring web development, web application security, and web server administration tips. Stay tuned for the latest SVR.JS updates.", + openGraph: { + title: "Blog - SVRJS", + description: + "Welcome to the SVR.JS Blog! Explore our latest blog posts featuring web development, web application security, and web server administration tips. Stay tuned for the latest SVR.JS updates.", + url: "https://svrjs.org/blog", + type: "website", + images: [ + { + url: "https://svrjs.vercel.app/metadata/svrjs-cover.png", + width: 800, + height: 600, + alt: "Blog - SVRJS" + } + ] + }, + twitter: { + card: "summary_large_image", + site: "@SVR_JS", + title: "Blog - SVRJS", + description: + "Welcome to the SVR.JS Blog! Explore our latest blog posts featuring web development, web application security, and web server administration tips. Stay tuned for the latest SVR.JS updates.", + images: ["https://svrjs.vercel.app/metadata/svrjs-cover.png"], + creator: "@SVR_JS" + } }; const BlogPage = async ({ - searchParams, + searchParams }: { - searchParams: { page?: string }; + searchParams: { page?: string }; }) => { - // Optionally, you can fetch some initial data here if needed. + // Optionally, you can fetch some initial data here if needed. - return ( -
    -

    - SVRJS Blog Post -

    -

    - Stay updated with our latest blog posts by subscribing to our - - - -

    - -
    - ); + return ( +
    +

    + SVRJS Blog Post +

    +

    + Stay updated with our latest blog posts by subscribing to our + + + +

    + +
    + ); }; export default BlogPage; diff --git a/app/(root)/changelogs/[slug]/page.tsx b/app/(root)/changelogs/[slug]/page.tsx index 6cd909f..00678f0 100644 --- a/app/(root)/changelogs/[slug]/page.tsx +++ b/app/(root)/changelogs/[slug]/page.tsx @@ -5,126 +5,126 @@ import ReactMarkdown from "react-markdown"; import Head from "next/head"; const Page = ({ params }: { params: { slug: string } }) => { - const { slug } = params; - const [page, setPage] = useState<{ title: string; content: string } | null>( - null - ); - const [loading, setLoading] = useState(true); - const [notFound, setNotFound] = useState(false); + const { slug } = params; + const [page, setPage] = useState<{ title: string; content: string } | null>( + null + ); + const [loading, setLoading] = useState(true); + const [notFound, setNotFound] = useState(false); - useEffect(() => { - const fetchPage = async () => { - try { - const response = await fetch(`/api/mdx/pages/${slug}`); - if (response.ok) { - const data = await response.json(); - setPage(data); - return (document.title = `${data.title} Change Log - SVRJS`); - } else { - if (response.status === 404) { - setNotFound(true); - return (document.title = "404 Not Found"); - } - } - } catch (error) { - console.error("Failed to load page", error); - setNotFound(true); - } finally { - setLoading(false); - } - }; + useEffect(() => { + const fetchPage = async () => { + try { + const response = await fetch(`/api/mdx/pages/${slug}`); + if (response.ok) { + const data = await response.json(); + setPage(data); + return (document.title = `${data.title} Change Log - SVRJS`); + } else { + if (response.status === 404) { + setNotFound(true); + return (document.title = "404 Not Found"); + } + } + } catch (error) { + console.error("Failed to load page", error); + setNotFound(true); + } finally { + setLoading(false); + } + }; - fetchPage(); - }, [slug]); + fetchPage(); + }, [slug]); - if (loading) { - return ( - <> - - Mods Change Logs - SVRJS - -
    -
    - -
    -
    - - - - -
    -
    - - ); - } + if (loading) { + return ( + <> + + Mods Change Logs - SVRJS + +
    +
    + +
    +
    + + + + +
    +
    + + ); + } - if (notFound) { - return ( -
    -

    - 404 Page not Found -

    -

    - Please return back to Home -

    -
    - ); - } + if (notFound) { + return ( +
    +

    + 404 Page not Found +

    +

    + Please return back to Home +

    +
    + ); + } - if (!page) { - return null; - } + if (!page) { + return null; + } - return ( - <> - - {page.title} Changelog - SVRJS - - + return ( + <> + + {page.title} Changelog - SVRJS + + - - - - - - Documentation - SVRJS - - - - - + + + + + + Documentation - SVRJS + + + + + -
    -

    - {page.title} Change Log -

    - - {page.content} - -
    - - ); +
    +

    + {page.title} Change Log +

    + + {page.content} + +
    + + ); }; export default Page; diff --git a/app/(root)/changelogs/layout.tsx b/app/(root)/changelogs/layout.tsx index 6dd0e52..c2d0661 100644 --- a/app/(root)/changelogs/layout.tsx +++ b/app/(root)/changelogs/layout.tsx @@ -2,36 +2,36 @@ import { Metadata } from "next"; // baseURL [ENV] export const metadata: Metadata = { - title: "ChangeLogs - SVRJS", - description: - "Stay up-to-date with the latest improvements and updates to SVR.JS web server. Our change log page provides a comprehensive list of new features, bug fixes, and enhancements for each release.", - openGraph: { - title: "ChangeLogs - SVRJS", - description: - "Stay up-to-date with the latest improvements and updates to SVR.JS web server. Our change log page provides a comprehensive list of new features, bug fixes, and enhancements for each release.", - url: "https://svrjs.org/changelogs", - type: "website", - images: [ - { - url: "https://svrjs.vercel.app/metadata/svrjs-cover.png", - width: 800, - height: 600, - alt: "ChangeLogs - SVRJS", - }, - ], - }, - twitter: { - card: "summary_large_image", - site: "@SVR_JS", - title: "ChangeLogs - SVRJS", - description: - "Stay up-to-date with the latest improvements and updates to SVR.JS web server. Our change log page provides a comprehensive list of new features, bug fixes, and enhancements for each release.", - images: ["https://svrjs.vercel.app/metadata/svrjs-cover.png"], - creator: "@SVR_JS", - }, + title: "ChangeLogs - SVRJS", + description: + "Stay up-to-date with the latest improvements and updates to SVR.JS web server. Our change log page provides a comprehensive list of new features, bug fixes, and enhancements for each release.", + openGraph: { + title: "ChangeLogs - SVRJS", + description: + "Stay up-to-date with the latest improvements and updates to SVR.JS web server. Our change log page provides a comprehensive list of new features, bug fixes, and enhancements for each release.", + url: "https://svrjs.org/changelogs", + type: "website", + images: [ + { + url: "https://svrjs.vercel.app/metadata/svrjs-cover.png", + width: 800, + height: 600, + alt: "ChangeLogs - SVRJS" + } + ] + }, + twitter: { + card: "summary_large_image", + site: "@SVR_JS", + title: "ChangeLogs - SVRJS", + description: + "Stay up-to-date with the latest improvements and updates to SVR.JS web server. Our change log page provides a comprehensive list of new features, bug fixes, and enhancements for each release.", + images: ["https://svrjs.vercel.app/metadata/svrjs-cover.png"], + creator: "@SVR_JS" + } }; const ContactLayout = ({ children }: { children: React.ReactNode }) => { - return
    {children}
    ; + return
    {children}
    ; }; export default ContactLayout; diff --git a/app/(root)/changelogs/page.tsx b/app/(root)/changelogs/page.tsx index de52650..4ad7694 100644 --- a/app/(root)/changelogs/page.tsx +++ b/app/(root)/changelogs/page.tsx @@ -9,103 +9,103 @@ import { CHANGE_LOGS } from "@/constants/guidelines"; import { Skeleton } from "@/components/ui/skeleton"; interface Bullet { - point: string; + point: string; } interface LOGS { - _id: string; - date: string; - version: string; - bullets?: Bullet[]; // Make bullets optional + _id: string; + date: string; + version: string; + bullets?: Bullet[]; // Make bullets optional } const LogsPage: React.FC = () => { - const [downloads, setDownloads] = useState([]); - const [error, setError] = useState(""); - const [loading, setLoading] = useState(true); + const [downloads, setDownloads] = useState([]); + const [error, setError] = useState(""); + const [loading, setLoading] = useState(true); - const fetchDownloads = async () => { - try { - const response = await fetch("/api/logs", { - method: "GET", - }); - if (response.ok) { - const data: LOGS[] = await response.json(); - setDownloads(data); - } else { - throw new Error(`HTTP error! status: ${response.status}`); - } - } catch (error: any) { - setError(error.message || "Failed to fetch downloads"); - } finally { - setLoading(false); - } - }; + const fetchDownloads = async () => { + try { + const response = await fetch("/api/logs", { + method: "GET" + }); + if (response.ok) { + const data: LOGS[] = await response.json(); + setDownloads(data); + } else { + throw new Error(`HTTP error! status: ${response.status}`); + } + } catch (error: any) { + setError(error.message || "Failed to fetch downloads"); + } finally { + setLoading(false); + } + }; - useEffect(() => { - fetchDownloads(); + useEffect(() => { + fetchDownloads(); - const interval = setInterval(() => { - fetchDownloads(); - }, 10000); + const interval = setInterval(() => { + fetchDownloads(); + }, 10000); - return () => clearInterval(interval); - }, []); - const reversedDownloads = [...downloads].reverse(); + return () => clearInterval(interval); + }, []); + const reversedDownloads = [...downloads].reverse(); - if (loading) { - return ( - <> - - Change Logs - SVRJS - -
    -
    - -
    -
    - - - - -
    -
    - - ); - } + if (loading) { + return ( + <> + + Change Logs - SVRJS + +
    +
    + +
    +
    + + + + +
    +
    + + ); + } - return ( -
    -

    - Server LOGS -

    -

    - Get all the latest version of SVRJS download and compiled Files here! -

    - {error &&

    {error}

    } + return ( +
    +

    + Server LOGS +

    +

    + Get all the latest version of SVRJS download and compiled Files here! +

    + {error &&

    {error}

    } - {reversedDownloads.map((download) => ( -
    -

    {download.version}

    - {download.date} -
      - {(download.bullets ?? []).map((bullet, index) => ( -
    • {bullet.point}
    • - ))} -
    -
    - ))} -
    - {CHANGE_LOGS} -
    -
    - ); + {reversedDownloads.map((download) => ( +
    +

    {download.version}

    + {download.date} +
      + {(download.bullets ?? []).map((bullet, index) => ( +
    • {bullet.point}
    • + ))} +
    +
    + ))} +
    + {CHANGE_LOGS} +
    +
    + ); }; export default LogsPage; diff --git a/app/(root)/contact/layout.tsx b/app/(root)/contact/layout.tsx index b2e614c..15d542c 100644 --- a/app/(root)/contact/layout.tsx +++ b/app/(root)/contact/layout.tsx @@ -2,36 +2,36 @@ import { Metadata } from "next"; // baseURL [ENV] export const metadata: Metadata = { - title: "Contact Us - SVRJS", - description: - "Have questions about SVR.JS? Need technical support? Visit our Contact Us page to find various ways to get in touch with our team, including email, forums, and our official support channel.", - openGraph: { - title: "Contact Us - SVRJS", - description: - "Have questions about SVR.JS? Need technical support? Visit our Contact Us page to find various ways to get in touch with our team, including email, forums, and our official support channel.", - url: "https://svrjs.org/contact", - type: "website", - images: [ - { - url: "https://svrjs.vercel.app/metadata/svrjs-cover.png", - width: 800, - height: 600, - alt: "Contact Us - SVRJS", - }, - ], - }, - twitter: { - card: "summary_large_image", - site: "@SVR_JS", - title: "Contact Us - SVRJS", - description: - "Have questions about SVR.JS? Need technical support? Visit our Contact Us page to find various ways to get in touch with our team, including email, forums, and our official support channel.", - images: ["https://svrjs.vercel.app/metadata/svrjs-cover.png"], - creator: "@SVR_JS", - }, + title: "Contact Us - SVRJS", + description: + "Have questions about SVR.JS? Need technical support? Visit our Contact Us page to find various ways to get in touch with our team, including email, forums, and our official support channel.", + openGraph: { + title: "Contact Us - SVRJS", + description: + "Have questions about SVR.JS? Need technical support? Visit our Contact Us page to find various ways to get in touch with our team, including email, forums, and our official support channel.", + url: "https://svrjs.org/contact", + type: "website", + images: [ + { + url: "https://svrjs.vercel.app/metadata/svrjs-cover.png", + width: 800, + height: 600, + alt: "Contact Us - SVRJS" + } + ] + }, + twitter: { + card: "summary_large_image", + site: "@SVR_JS", + title: "Contact Us - SVRJS", + description: + "Have questions about SVR.JS? Need technical support? Visit our Contact Us page to find various ways to get in touch with our team, including email, forums, and our official support channel.", + images: ["https://svrjs.vercel.app/metadata/svrjs-cover.png"], + creator: "@SVR_JS" + } }; const ContactLayout = ({ children }: { children: React.ReactNode }) => { - return
    {children}
    ; + return
    {children}
    ; }; export default ContactLayout; diff --git a/app/(root)/contact/page.tsx b/app/(root)/contact/page.tsx index 8eeab8b..42e72ae 100644 --- a/app/(root)/contact/page.tsx +++ b/app/(root)/contact/page.tsx @@ -7,12 +7,12 @@ import { z } from "zod"; import { contactFormSchema } from "@/lib/validations/validation"; import { Button } from "@/components/ui/button"; import { - Form, - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, + Form, + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; @@ -23,179 +23,179 @@ import { emails } from "@/constants"; import HCaptcha from "@hcaptcha/react-hcaptcha"; const ContactUs = () => { - const { toast } = useToast(); - const [loading, setLoading] = useState(false); - const [showCaptcha, setShowCaptcha] = useState(false); - const [captchaToken, setCaptchaToken] = useState(null); + const { toast } = useToast(); + const [loading, setLoading] = useState(false); + const [showCaptcha, setShowCaptcha] = useState(false); + const [captchaToken, setCaptchaToken] = useState(null); - const form = useForm>({ - resolver: zodResolver(contactFormSchema), - defaultValues: { - name: "", - email: "", - message: "", - }, - }); + const form = useForm>({ + resolver: zodResolver(contactFormSchema), + defaultValues: { + name: "", + email: "", + message: "" + } + }); - async function onSubmit(values: z.infer) { - if (!captchaToken) { - setShowCaptcha(true); - return; - } + async function onSubmit(values: z.infer) { + if (!captchaToken) { + setShowCaptcha(true); + return; + } - setLoading(true); - try { - const res = await fetch("/api/contact", { - method: "POST", - body: JSON.stringify({ ...values, captchaToken }), - headers: { - "Content-Type": "application/json", - Accept: "application/json", - }, - }); + setLoading(true); + try { + const res = await fetch("/api/contact", { + method: "POST", + body: JSON.stringify({ ...values, captchaToken }), + headers: { + "Content-Type": "application/json", + Accept: "application/json" + } + }); - if (res.ok) { - form.reset(); - setCaptchaToken(null); // Reset captcha token after successful submission - toast({ - description: "Your message has been sent.", - }); - } else { - toast({ - title: "Uh oh! Something went wrong.", - variant: "destructive", - }); - } - } catch (error) { - console.error(error); - toast({ - title: "Uh oh! Something went wrong.", - variant: "destructive", - }); - } finally { - setLoading(false); - setShowCaptcha(false); // Hide captcha after submission attempt - } - } + if (res.ok) { + form.reset(); + setCaptchaToken(null); // Reset captcha token after successful submission + toast({ + description: "Your message has been sent." + }); + } else { + toast({ + title: "Uh oh! Something went wrong.", + variant: "destructive" + }); + } + } catch (error) { + console.error(error); + toast({ + title: "Uh oh! Something went wrong.", + variant: "destructive" + }); + } finally { + setLoading(false); + setShowCaptcha(false); // Hide captcha after submission attempt + } + } - function handleCaptchaVerify(token: string) { - setCaptchaToken(token); - onSubmit(form.getValues()); // Trigger form submission after captcha is verified - } + function handleCaptchaVerify(token: string) { + setCaptchaToken(token); + onSubmit(form.getValues()); // Trigger form submission after captcha is verified + } - return ( - <> -
    -

    - Contact Us -

    -
    + return ( + <> +
    +

    + Contact Us +

    +
    -
    -
    - {/* Left contact page */} -
    - - ( - - Name - - - - - - )} - /> - ( - - Email - - - - - - )} - /> - ( - - Message - -