From c17d902b9ae63568685dbfc676e4e2705b939522 Mon Sep 17 00:00:00 2001 From: Tola Leng Date: Wed, 28 May 2025 15:35:36 +0800 Subject: [PATCH] Fixed: in About System page, make it auto-updates with each new release on GitHub without any hardcoded values --- .../settings/about-system/AboutSystem.tsx | 71 +++++++++++++------ 1 file changed, 48 insertions(+), 23 deletions(-) diff --git a/application/src/components/settings/about-system/AboutSystem.tsx b/application/src/components/settings/about-system/AboutSystem.tsx index 9509d2e..ae2ce8d 100644 --- a/application/src/components/settings/about-system/AboutSystem.tsx +++ b/application/src/components/settings/about-system/AboutSystem.tsx @@ -1,30 +1,51 @@ - -import React from 'react'; -import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; +import React, { useEffect, useState } from 'react'; +import { format } from 'date-fns'; +import { + Card, CardContent, CardDescription, CardHeader, CardTitle, +} from "@/components/ui/card"; import { Separator } from "@/components/ui/separator"; -import { Github, FileText, Twitter, MessageCircle, Code2, ServerIcon } from "lucide-react"; +import { + Github, FileText, Twitter, MessageCircle, Code2, ServerIcon, +} from "lucide-react"; import { Button } from "@/components/ui/button"; import { useLanguage } from "@/contexts/LanguageContext"; import { useTheme } from "@/contexts/ThemeContext"; import { useSystemSettings } from "@/hooks/useSystemSettings"; + export const AboutSystem: React.FC = () => { - const { - t - } = useLanguage(); - const { - theme - } = useTheme(); - const { - systemName - } = useSystemSettings(); - return
+ const { t } = useLanguage(); + const { theme } = useTheme(); + const { systemName } = useSystemSettings(); + + const [version, setVersion] = useState('...'); + const [releaseDate, setReleaseDate] = useState('...'); + + useEffect(() => { + const fetchLatestRelease = async () => { + try { + const res = await fetch('https://api.github.com/repos/operacle/checkcle/releases/latest'); + const data = await res.json(); + setVersion(data.tag_name || 'v1.x.x'); + setReleaseDate(data.published_at ? format(new Date(data.published_at), 'MMMM d, yyyy') : t('unknown')); + } catch (err) { + setVersion('v1.x.x'); + setReleaseDate(t('unknown')); + } + }; + fetchLatestRelease(); + }, [t]); + + return ( +

{t('aboutSystem')}

-

{t('aboutCheckcle')}

+

+ {t('aboutCheckcle')} +

- + - +
@@ -38,7 +59,7 @@ export const AboutSystem: React.FC = () => {
{t('systemVersion')} - {t('version')} 1.1.0 + {version}
@@ -48,20 +69,22 @@ export const AboutSystem: React.FC = () => {
{t('releasedOn')} - May 16, 2025 + {releaseDate}
- + {t('links')} - {systemName || 'ReamStack'} {t('resources').toLowerCase()} + + {systemName || 'ReamStack'} {t('resources').toLowerCase()} +
@@ -85,6 +108,8 @@ export const AboutSystem: React.FC = () => {
-
; +
+ ); }; -export default AboutSystem; \ No newline at end of file + +export default AboutSystem;