mirror of
https://github.com/logto-io/logto.git
synced 2025-01-20 21:32:31 -05:00
style(ui): update error page back button (#3457)
This commit is contained in:
parent
58cd11b2b8
commit
62843e20c8
5 changed files with 8 additions and 20 deletions
|
@ -81,7 +81,7 @@ const translation = {
|
||||||
password_changed: 'Password changed',
|
password_changed: 'Password changed',
|
||||||
no_account: 'No account yet? ',
|
no_account: 'No account yet? ',
|
||||||
have_account: 'Already had an account?',
|
have_account: 'Already had an account?',
|
||||||
enter_password: 'Enter ppassword',
|
enter_password: 'Enter password',
|
||||||
enter_password_for: 'Sign in with the password to {{method}} {{value}}',
|
enter_password_for: 'Sign in with the password to {{method}} {{value}}',
|
||||||
enter_username: 'Set username',
|
enter_username: 'Set username',
|
||||||
enter_username_description:
|
enter_username_description:
|
||||||
|
|
|
@ -81,7 +81,7 @@ const App = () => {
|
||||||
<Route element={<AppLayout />}>
|
<Route element={<AppLayout />}>
|
||||||
<Route
|
<Route
|
||||||
path="unknown-session"
|
path="unknown-session"
|
||||||
element={<ErrorPage isRootPath message="error.invalid_session" />}
|
element={<ErrorPage message="error.invalid_session" />}
|
||||||
/>
|
/>
|
||||||
<Route path="springboard" element={<Springboard />} />
|
<Route path="springboard" element={<Springboard />} />
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ const App = () => {
|
||||||
<Route path="callback/:connectorId" element={<Callback />} />
|
<Route path="callback/:connectorId" element={<Callback />} />
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
<Route path="*" element={<ErrorPage isRootPath />} />
|
<Route path="*" element={<ErrorPage />} />
|
||||||
</Route>
|
</Route>
|
||||||
</Routes>
|
</Routes>
|
||||||
</AppBoundary>
|
</AppBoundary>
|
||||||
|
|
|
@ -2,12 +2,10 @@ import { Theme } from '@logto/schemas';
|
||||||
import { useContext } from 'react';
|
import { useContext } from 'react';
|
||||||
import type { TFuncKey } from 'react-i18next';
|
import type { TFuncKey } from 'react-i18next';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
|
|
||||||
import StaticPageLayout from '@/Layout/StaticPageLayout';
|
import StaticPageLayout from '@/Layout/StaticPageLayout';
|
||||||
import EmptyStateDark from '@/assets/icons/empty-state-dark.svg';
|
import EmptyStateDark from '@/assets/icons/empty-state-dark.svg';
|
||||||
import EmptyState from '@/assets/icons/empty-state.svg';
|
import EmptyState from '@/assets/icons/empty-state.svg';
|
||||||
import Button from '@/components/Button';
|
|
||||||
import NavBar from '@/components/NavBar';
|
import NavBar from '@/components/NavBar';
|
||||||
import { PageContext } from '@/hooks/use-page-context';
|
import { PageContext } from '@/hooks/use-page-context';
|
||||||
|
|
||||||
|
@ -17,33 +15,23 @@ type Props = {
|
||||||
title?: TFuncKey;
|
title?: TFuncKey;
|
||||||
message?: TFuncKey;
|
message?: TFuncKey;
|
||||||
rawMessage?: string;
|
rawMessage?: string;
|
||||||
isRootPath?: boolean;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const ErrorPage = ({ title = 'description.not_found', message, rawMessage, isRootPath }: Props) => {
|
const ErrorPage = ({ title = 'description.not_found', message, rawMessage }: Props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const navigate = useNavigate();
|
|
||||||
const { theme } = useContext(PageContext);
|
const { theme } = useContext(PageContext);
|
||||||
|
|
||||||
const errorMessage = rawMessage ?? (message && t(message));
|
const errorMessage = rawMessage ?? (message && t(message));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StaticPageLayout>
|
<StaticPageLayout>
|
||||||
{!isRootPath && <NavBar />}
|
{history.length > 1 && <NavBar />}
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
{theme === Theme.Light ? <EmptyState /> : <EmptyStateDark />}
|
{theme === Theme.Light ? <EmptyState /> : <EmptyStateDark />}
|
||||||
<div className={styles.title}>{t(title)}</div>
|
<div className={styles.title}>{t(title)}</div>
|
||||||
{errorMessage && <div className={styles.message}>{String(errorMessage)}</div>}
|
{errorMessage && <div className={styles.message}>{String(errorMessage)}</div>}
|
||||||
</div>
|
</div>
|
||||||
{!isRootPath && (
|
|
||||||
<Button
|
|
||||||
className={styles.backButton}
|
|
||||||
title="action.back"
|
|
||||||
onClick={() => {
|
|
||||||
navigate(-1);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</StaticPageLayout>
|
</StaticPageLayout>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,7 +17,7 @@ const Register = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
if (!signInMode || signInMode === SignInMode.SignIn) {
|
if (!signInMode || signInMode === SignInMode.SignIn) {
|
||||||
return <ErrorPage isRootPath />;
|
return <ErrorPage />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -17,7 +17,7 @@ const SignIn = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
if (!signInMode || signInMode === SignInMode.Register) {
|
if (!signInMode || signInMode === SignInMode.Register) {
|
||||||
return <ErrorPage isRootPath />;
|
return <ErrorPage />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Add table
Reference in a new issue