mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-10-28 12:45:47 +00:00
refactor: update domain warning layout
This commit is contained in:
@@ -28,7 +28,7 @@ export const DomainWarning = (props: Props) => {
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardFooter className="flex flex-col items-stretch">
|
<CardFooter className="flex flex-col items-stretch">
|
||||||
<Button onClick={onClick} variant="warning">
|
<Button onClick={onClick} variant="warning">
|
||||||
Continue
|
Ignore
|
||||||
</Button>
|
</Button>
|
||||||
</CardFooter>
|
</CardFooter>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -4,10 +4,8 @@ import { Outlet } from "react-router";
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { DomainWarning } from "../domain-warning/domain-warning";
|
import { DomainWarning } from "../domain-warning/domain-warning";
|
||||||
|
|
||||||
export const Layout = () => {
|
const BaseLayout = ({ children }: { children: React.ReactNode }) => {
|
||||||
const { backgroundImage, appUrl } = useAppContext();
|
const { backgroundImage } = useAppContext();
|
||||||
const [ignoreDomainWarning, setIgnoreDomainWarning] = useState(false);
|
|
||||||
const currentUrl = window.location.origin;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -19,15 +17,41 @@ export const Layout = () => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<LanguageSelector />
|
<LanguageSelector />
|
||||||
{appUrl !== currentUrl && !ignoreDomainWarning ? (
|
{children}
|
||||||
<DomainWarning
|
|
||||||
onClick={() => setIgnoreDomainWarning(true)}
|
|
||||||
appUrl={appUrl}
|
|
||||||
currentUrl={currentUrl}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<Outlet />
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const Layout = () => {
|
||||||
|
const { appUrl } = useAppContext();
|
||||||
|
const [ignoreDomainWarning, setIgnoreDomainWarning] = useState(false);
|
||||||
|
const currentUrl = window.location.origin;
|
||||||
|
const sessionIgnore = window.sessionStorage.getItem("ignoreDomainWarning");
|
||||||
|
|
||||||
|
const handleIgnore = () => {
|
||||||
|
window.sessionStorage.setItem("ignoreDomainWarning", "true");
|
||||||
|
setIgnoreDomainWarning(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (
|
||||||
|
!ignoreDomainWarning &&
|
||||||
|
appUrl !== currentUrl &&
|
||||||
|
sessionIgnore !== "true"
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<BaseLayout>
|
||||||
|
<DomainWarning
|
||||||
|
appUrl={appUrl}
|
||||||
|
currentUrl={currentUrl}
|
||||||
|
onClick={() => handleIgnore()}
|
||||||
|
/>
|
||||||
|
</BaseLayout>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BaseLayout>
|
||||||
|
<Outlet />
|
||||||
|
</BaseLayout>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ ul {
|
|||||||
}
|
}
|
||||||
|
|
||||||
code {
|
code {
|
||||||
@apply relative rounded bg-muted px-[0.2rem] py-[0.1rem] font-mono text-sm font-semibold;
|
@apply relative rounded bg-muted px-[0.2rem] py-[0.1rem] font-mono text-sm font-semibold break-all;
|
||||||
}
|
}
|
||||||
|
|
||||||
.lead {
|
.lead {
|
||||||
|
|||||||
Reference in New Issue
Block a user