import { getBrandingApi } from "@jellyfin/sdk/lib/utils/api/branding-api"; import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api"; import { useQuery } from "@tanstack/react-query"; import { Link } from "@tanstack/react-router"; import React, { type ReactNode, useEffect } from "react"; import { useApiInContext } from "@/utils/store/api"; import { useBackdropStore } from "@/utils/store/backdrop"; import "./loginShell.scss"; type LoginShellProps = { title: ReactNode; subtitle?: ReactNode; /** Max width of the content column. */ width?: "narrow" | "wide"; children: ReactNode; footer?: ReactNode; }; /** Shared full-screen layout for the sign-in pages. */ const LoginShell = ({ title, subtitle, width = "narrow", children, footer, }: LoginShellProps) => { const api = useApiInContext((s) => s.api); const serverInfo = useQuery({ queryKey: ["login", "serverInfo"], queryFn: async () => api ? (await getSystemApi(api).getPublicSystemInfo()).data : null, enabled: Boolean(api), staleTime: 5 * 60_000, }); const branding = useQuery({ queryKey: ["login", "branding"], queryFn: async () => api ? (await getBrandingApi(api).getBrandingOptions()).data : null, enabled: Boolean(api), staleTime: 5 * 60_000, }); const setBackdrop = useBackdropStore((s) => s.setBackdrop); useEffect(() => { setBackdrop(""); }, [setBackdrop]); const serverName = serverInfo.data?.ServerName; const serverHost = api?.basePath.replace(/^https?:\/\//, ""); return (
{serverHost && (
dns {serverName ?? serverHost} Change
)}

{title}

{subtitle &&

{subtitle}

}
{children}
{footer &&
{footer}
} {branding.data?.LoginDisclaimer && ( )}
); }; export default LoginShell;