mirror of
https://github.com/logto-io/logto.git
synced 2025-02-10 21:58:23 -05:00
fix(ui): fix create account page reload issue (#832)
fix create account page reload issue
This commit is contained in:
parent
78d3bb6045
commit
e2217584a4
2 changed files with 12 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import React, { ReactNode, AnchorHTMLAttributes } from 'react';
|
import React, { ReactNode, AnchorHTMLAttributes } from 'react';
|
||||||
import { TFuncKey, useTranslation } from 'react-i18next';
|
import { TFuncKey, useTranslation } from 'react-i18next';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
import * as styles from './index.module.scss';
|
import * as styles from './index.module.scss';
|
||||||
|
|
||||||
|
@ -9,11 +10,20 @@ export type Props = AnchorHTMLAttributes<HTMLAnchorElement> & {
|
||||||
children?: ReactNode;
|
children?: ReactNode;
|
||||||
text?: TFuncKey<'translation', 'main_flow'>;
|
text?: TFuncKey<'translation', 'main_flow'>;
|
||||||
type?: 'primary' | 'secondary';
|
type?: 'primary' | 'secondary';
|
||||||
|
to?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const TextLink = ({ className, children, text, type = 'primary', ...rest }: Props) => {
|
const TextLink = ({ className, children, text, type = 'primary', to, ...rest }: Props) => {
|
||||||
const { t } = useTranslation(undefined, { keyPrefix: 'main_flow' });
|
const { t } = useTranslation(undefined, { keyPrefix: 'main_flow' });
|
||||||
|
|
||||||
|
if (to) {
|
||||||
|
return (
|
||||||
|
<Link className={classNames(styles.link, styles[type], className)} to={to}>
|
||||||
|
{children ?? (text ? t(text) : '')}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<a className={classNames(styles.link, styles[type], className)} {...rest} rel="noreferrer">
|
<a className={classNames(styles.link, styles[type], className)} {...rest} rel="noreferrer">
|
||||||
{children ?? (text ? t(text) : '')}
|
{children ?? (text ? t(text) : '')}
|
||||||
|
|
|
@ -87,7 +87,7 @@ export const CreateAccountLink = ({
|
||||||
<TextLink
|
<TextLink
|
||||||
className={styles.createAccount}
|
className={styles.createAccount}
|
||||||
type="secondary"
|
type="secondary"
|
||||||
href={`/register/${primarySignInMethod}`}
|
to={`/register/${primarySignInMethod}`}
|
||||||
text="action.create_account"
|
text="action.create_account"
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
|
Loading…
Add table
Reference in a new issue