diff --git a/components/footer/Footer.tsx b/components/footer/Footer.tsx index 5108b492..3f4609e7 100644 --- a/components/footer/Footer.tsx +++ b/components/footer/Footer.tsx @@ -9,8 +9,49 @@ import DiscordIcon from "@/components/icons/discord"; import SpigotMcLikeIcon from "@/components/icons/spigotmc"; import ModrinthIcon from "@/components/icons/modrinth"; import logo from "@/public/logo.svg"; +import { useEffect, useState } from "react"; + +interface GitInfo { + commitHash: string; + lastUpdated: string; +} export default function Footer() { + const [commitInfo, setCommitInfo] = useState({ + hash: "", + date: "", + }); + + useEffect(() => { + const fetchCommitInfo = async () => { + try { + const response = await fetch("https://api.github.com/repos/EternalCodeTeam/website/commits/master"); + if (response.ok) { + const data = await response.json() as { + sha: string; + commit: { + committer: { + date: string; + }; + }; + }; + + const commitDate = new Date(data.commit.committer.date); + const formattedDate = commitDate.toLocaleString(); + + setCommitInfo({ + hash: data.sha, + date: formattedDate, + }); + } + } catch (error) { + console.error("Failed to fetch git info:", error); + } + }; + + fetchCommitInfo(); + }, []); + return (