Disable login page errors on the web

This commit is contained in:
Zoe Roux 2024-03-07 01:18:17 +01:00
parent a7fd96800a
commit c319f6117a
4 changed files with 12 additions and 5 deletions

View File

@ -117,10 +117,16 @@ const YoshikiDebug = ({ children }: { children: JSX.Element }) => {
return <StyleRegistryProvider registry={registry}>{children}</StyleRegistryProvider>; return <StyleRegistryProvider registry={registry}>{children}</StyleRegistryProvider>;
}; };
const ConnectionErrorVerifier = ({ children }: { children: JSX.Element }) => { const ConnectionErrorVerifier = ({
children,
skipErrors,
}: {
children: JSX.Element;
skipErrors?: boolean;
}) => {
const { error } = useContext(ConnectionErrorContext); const { error } = useContext(ConnectionErrorContext);
if (!error) return children; if (!error || skipErrors) return children;
return <WithLayout Component={ConnectionError} />; return <WithLayout Component={ConnectionError} />;
}; };
@ -158,7 +164,7 @@ const App = ({ Component, pageProps }: AppProps) => {
<PortalProvider> <PortalProvider>
<SnackbarProvider> <SnackbarProvider>
<GlobalCssTheme /> <GlobalCssTheme />
<ConnectionErrorVerifier> <ConnectionErrorVerifier skipErrors={(Component as QueryPage).isPublic}>
<WithLayout <WithLayout
Component={Component} Component={Component}
randomItems={ randomItems={

View File

@ -183,6 +183,7 @@ export type QueryPage<Props = {}, Items = unknown> = ComponentType<
| { Layout: QueryPage<{ page: ReactElement }>; props: object }; | { Layout: QueryPage<{ page: ReactElement }>; props: object };
requiredPermissions?: string[]; requiredPermissions?: string[];
randomItems?: Items[]; randomItems?: Items[];
isPublic?: boolean
}; };
export const toQueryKey = (query: { export const toQueryKey = (query: {

View File

@ -96,5 +96,5 @@ export const LoginPage: QueryPage<{ apiUrl?: string; error?: string }> = ({
}; };
LoginPage.getFetchUrls = () => [OidcLogin.query()]; LoginPage.getFetchUrls = () => [OidcLogin.query()];
LoginPage.isPublic = true;
LoginPage.getLayout = DefaultLayout; LoginPage.getLayout = DefaultLayout;

View File

@ -106,5 +106,5 @@ export const RegisterPage: QueryPage<{ apiUrl?: string }> = ({ apiUrl }) => {
}; };
RegisterPage.getFetchUrls = () => [OidcLogin.query()]; RegisterPage.getFetchUrls = () => [OidcLogin.query()];
RegisterPage.isPublic = true;
RegisterPage.getLayout = DefaultLayout; RegisterPage.getLayout = DefaultLayout;