mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-10-28 04:35:40 +00:00
* wip * refactor: update domain warning layout * i18n: add domain warning translations * refactor: rework hooks usage * feat: clear timeouts * fix: use useeffect to cleanup timeout * refactor: rework redirects and history storage * refactor: rename domain to root domain
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
import { useAppContext } from "@/context/app-context";
|
|
import { LanguageSelector } from "../language/language";
|
|
import { Outlet } from "react-router";
|
|
import { useCallback, useState } from "react";
|
|
import { DomainWarning } from "../domain-warning/domain-warning";
|
|
|
|
const BaseLayout = ({ children }: { children: React.ReactNode }) => {
|
|
const { backgroundImage } = useAppContext();
|
|
|
|
return (
|
|
<div
|
|
className="relative flex flex-col justify-center items-center min-h-svh"
|
|
style={{
|
|
backgroundImage: `url(${backgroundImage})`,
|
|
backgroundSize: "cover",
|
|
backgroundPosition: "center",
|
|
}}
|
|
>
|
|
<LanguageSelector />
|
|
{children}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export const Layout = () => {
|
|
const { appUrl } = useAppContext();
|
|
const [ignoreDomainWarning, setIgnoreDomainWarning] = useState(() => {
|
|
return window.sessionStorage.getItem("ignoreDomainWarning") === "true";
|
|
});
|
|
const currentUrl = window.location.origin;
|
|
|
|
const handleIgnore = useCallback(() => {
|
|
window.sessionStorage.setItem("ignoreDomainWarning", "true");
|
|
setIgnoreDomainWarning(true);
|
|
}, [setIgnoreDomainWarning]);
|
|
|
|
if (!ignoreDomainWarning && appUrl !== currentUrl) {
|
|
return (
|
|
<BaseLayout>
|
|
<DomainWarning
|
|
appUrl={appUrl}
|
|
currentUrl={currentUrl}
|
|
onClick={() => handleIgnore()}
|
|
/>
|
|
</BaseLayout>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<BaseLayout>
|
|
<Outlet />
|
|
</BaseLayout>
|
|
);
|
|
};
|