erp-platform/ui/src/components/template/Footer.tsx

100 lines
3.1 KiB
TypeScript
Raw Normal View History

2025-09-19 20:36:10 +00:00
import { useEffect, useState } from "react"
import classNames from "classnames"
import Container from "@/components/shared/Container"
import { APP_NAME } from "@/constants/app.constant"
import { PAGE_CONTAINER_GUTTER_X } from "@/constants/theme.constant"
import { useStoreActions, useStoreState } from "@/store"
import { Link, useNavigate } from "react-router-dom"
import { ROUTES_ENUM } from "@/routes/route.constant"
import UiDialog from "@/views/shared/UiDialog"
2025-05-06 06:45:49 +00:00
2025-09-19 20:36:10 +00:00
export type FooterPageContainerType = "gutterless" | "contained"
2025-05-06 06:45:49 +00:00
type FooterProps = {
pageContainerType: FooterPageContainerType
}
const FooterContent = () => {
const navigate = useNavigate()
const { currentUiVersion } = useStoreState((a) => a.locale)
const { setUiVersion } = useStoreActions((a) => a.locale)
const apiConfig = useStoreState((state) => state.abpConfig.config?.extraProperties)
const uiMode = import.meta.env.MODE
2025-09-19 20:36:10 +00:00
const [latestVersion, setLatestVersion] = useState<string | null>(null)
// version.json'dan en güncel UI versiyonunu al
useEffect(() => {
fetch("/version.json?ts=" + Date.now())
.then((res) => res.json())
.then((data) => {
if (data?.releases?.length > 0) {
setLatestVersion(data.releases[0].version) // en güncel hep en üstte
}
})
.catch(() => setLatestVersion(null))
}, [])
2025-05-06 06:45:49 +00:00
return (
<>
<div className="flex flex-col sm:flex-row items-center justify-between w-full">
<div className="space-x-1">
<span>Copyright &copy; {new Date().getFullYear()}</span>
<span className="font-semibold">{APP_NAME}</span>
</div>
2025-06-28 21:34:28 +00:00
<Link to={ROUTES_ENUM.protected.admin.changeLog}>
2025-05-06 06:45:49 +00:00
<div className="text-muted capitalize">
<span>
<b>UI: </b>
{uiMode}:{currentUiVersion}
</span>
<span className="mx-2">|</span>
{apiConfig && (
<span>
<b>API: </b>
2025-09-19 20:36:10 +00:00
{apiConfig["environment"].toString()}:{apiConfig["version"].toString()}
2025-05-06 06:45:49 +00:00
</span>
)}
</div>
</Link>
</div>
2025-09-19 20:36:10 +00:00
{latestVersion && latestVersion !== currentUiVersion && (
2025-05-06 06:45:49 +00:00
<UiDialog
2025-09-19 20:36:10 +00:00
key={`version-${latestVersion}`}
2025-05-06 06:45:49 +00:00
isOpen={true}
type="info"
onConfirm={() => {
2025-09-19 20:36:10 +00:00
setUiVersion(latestVersion)
2025-06-28 21:34:28 +00:00
navigate(ROUTES_ENUM.protected.admin.changeLog)
2025-05-06 06:45:49 +00:00
}}
title="🎉 Yeni Güncelleme"
>
2025-09-19 20:36:10 +00:00
Sözsoft Kurs Platform Sistemi <b>v{latestVersion}</b> sürümüne güncellendi.
2025-05-06 06:45:49 +00:00
<p>Detayları, "Güncelleme Günlüğü" ekranında görebilirsiniz.</p>
</UiDialog>
)}
</>
)
}
2025-09-19 20:36:10 +00:00
export default function Footer({ pageContainerType = "contained" }: FooterProps) {
2025-05-06 06:45:49 +00:00
return (
<footer
2025-09-19 20:36:10 +00:00
className={classNames(
`print:hidden footer flex flex-auto items-center h-6 ${PAGE_CONTAINER_GUTTER_X}`
)}
2025-05-06 06:45:49 +00:00
>
2025-09-19 20:36:10 +00:00
{pageContainerType === "contained" ? (
2025-05-06 06:45:49 +00:00
<Container>
<FooterContent />
</Container>
) : (
<FooterContent />
)}
</footer>
)
}