2024-06-22 10:30:51 +02:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
import { Download } from "lucide-react";
|
|
|
|
import Link from "next/link";
|
2024-07-17 17:45:28 +02:00
|
|
|
import ReactMarkdown from "react-markdown";
|
|
|
|
import { CHANGE_LOGS } from "@/constants/guidelines";
|
2024-07-30 21:36:45 +02:00
|
|
|
import { Skeleton } from "@/components/ui/skeleton";
|
2024-07-17 17:45:28 +02:00
|
|
|
|
|
|
|
interface Bullet {
|
|
|
|
point: string;
|
|
|
|
}
|
2024-06-22 10:30:51 +02:00
|
|
|
|
|
|
|
interface LOGS {
|
2024-07-17 17:45:28 +02:00
|
|
|
_id: string;
|
|
|
|
date: string;
|
|
|
|
version: string;
|
|
|
|
bullets?: Bullet[]; // Make bullets optional
|
2024-06-22 10:30:51 +02:00
|
|
|
}
|
|
|
|
|
2024-07-17 17:45:28 +02:00
|
|
|
const LogsPage: React.FC = () => {
|
|
|
|
const [downloads, setDownloads] = useState<LOGS[]>([]);
|
|
|
|
const [error, setError] = useState("");
|
2024-07-30 21:36:45 +02:00
|
|
|
const [loading, setLoading] = useState(true);
|
2024-06-22 10:30:51 +02:00
|
|
|
|
2024-07-17 17:45:28 +02:00
|
|
|
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");
|
2024-07-30 21:36:45 +02:00
|
|
|
} finally {
|
|
|
|
setLoading(false);
|
2024-07-17 17:45:28 +02:00
|
|
|
}
|
|
|
|
};
|
2024-06-22 10:30:51 +02:00
|
|
|
|
2024-07-17 17:45:28 +02:00
|
|
|
useEffect(() => {
|
|
|
|
fetchDownloads();
|
2024-06-22 10:30:51 +02:00
|
|
|
|
2024-07-17 17:45:28 +02:00
|
|
|
const interval = setInterval(() => {
|
|
|
|
fetchDownloads();
|
|
|
|
}, 10000);
|
2024-06-22 10:30:51 +02:00
|
|
|
|
2024-07-17 17:45:28 +02:00
|
|
|
return () => clearInterval(interval);
|
|
|
|
}, []);
|
|
|
|
const reversedDownloads = [...downloads].reverse();
|
2024-06-22 10:30:51 +02:00
|
|
|
|
2024-07-30 21:36:45 +02:00
|
|
|
if (loading) {
|
|
|
|
return (
|
|
|
|
<section className="wrapper container py-24 md:py-28 gap-4 flex flex-col">
|
|
|
|
<div className="mb-3">
|
|
|
|
<Skeleton className="w-[400px] h-[50px] rounded-md" />
|
|
|
|
</div>
|
|
|
|
<div className="flex flex-col gap-4">
|
|
|
|
<Skeleton className="w-[300px] h-[30px] rounded-md" />
|
|
|
|
<Skeleton className="w-[200px] h-[20px] rounded-md" />
|
|
|
|
<Skeleton className="w-[200px] h-[20px] rounded-md" />
|
|
|
|
<Skeleton className="w-[200px] h-[20px] rounded-md" />
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-07-17 17:45:28 +02:00
|
|
|
return (
|
|
|
|
<section
|
|
|
|
id="logs"
|
2024-07-29 22:57:35 +02:00
|
|
|
className="wrapper container py-24 md:py-28 gap-2 flex flex-col"
|
2024-07-17 17:45:28 +02:00
|
|
|
>
|
2024-07-29 22:57:35 +02:00
|
|
|
<h1 className="text-3xl md:text-5xl pb-1 md:pb-2 font-bold text-black dark:bg-clip-text dark:text-transparent dark:bg-gradient-to-b dark:from-white dark:to-neutral-400">
|
2024-07-17 17:45:28 +02:00
|
|
|
Server LOGS
|
|
|
|
</h1>
|
2024-07-29 23:03:55 +02:00
|
|
|
<p className="md:text-lg text-muted-foreground text-start mb-6">
|
2024-07-17 17:45:28 +02:00
|
|
|
Get all the latest version of SVRJS download and compiled Files here!
|
|
|
|
</p>
|
|
|
|
{error && <p className="text-red-500">{error}</p>}
|
2024-06-22 10:30:51 +02:00
|
|
|
|
2024-07-17 17:45:28 +02:00
|
|
|
{reversedDownloads.map((download) => (
|
|
|
|
<div
|
|
|
|
key={download._id}
|
2024-07-29 22:57:35 +02:00
|
|
|
className="flex-start prose max-w-full md:prose-lg dark:prose-invert flex-col mb-4"
|
2024-07-17 17:45:28 +02:00
|
|
|
>
|
|
|
|
<h2 className="font-bold text-3xl">{download.version}</h2>
|
|
|
|
<span className="font-medium italic">{download.date}</span>
|
|
|
|
<ul className="list-disc pl-5">
|
|
|
|
{(download.bullets ?? []).map((bullet, index) => (
|
|
|
|
<li key={index}>{bullet.point}</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
))}
|
2024-07-29 22:29:19 +02:00
|
|
|
<div className="prose max-w-full md:prose-lg dark:prose-invert">
|
2024-07-17 17:45:28 +02:00
|
|
|
<ReactMarkdown>{CHANGE_LOGS}</ReactMarkdown>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
);
|
2024-06-22 10:30:51 +02:00
|
|
|
};
|
|
|
|
|
2024-07-17 17:45:28 +02:00
|
|
|
export default LogsPage;
|