mhsf-dev/src/components/Banner.tsx

41 lines
889 B
TypeScript
Raw Normal View History

2024-08-07 16:37:54 -05:00
"use client";
import { getCustomization } from "@/lib/api";
import { useEffect, useState } from "react";
2024-08-07 21:15:13 -05:00
import { Spinner } from "./ui/spinner";
2024-08-07 16:37:54 -05:00
export default function Banner({ server }: { server: string }) {
const [bannerURL, setBannerURL] = useState("");
2024-08-07 21:15:13 -05:00
const [loading, setLoading] = useState(true);
2024-08-07 16:37:54 -05:00
useEffect(() => {
getCustomization(server).then((c) => {
if (c != null) {
setLoading(false);
setBannerURL(c.banner == undefined ? "" : c.banner);
}
2024-08-07 16:37:54 -05:00
});
}, [server]);
2024-08-07 21:15:13 -05:00
if (loading) {
return (
<>
<Spinner className="flex items-center" />
<br />
</>
);
}
2024-08-07 16:37:54 -05:00
return (
<>
2024-08-07 21:15:13 -05:00
{bannerURL != "" && (
<img
src={"https://i.imgur.com/" + bannerURL}
className="rounded align-middle block ml-auto mr-auto w-[50%] max-h-[150px]"
/>
)}
2024-08-07 16:37:54 -05:00
<br />
</>
);
}