mirror of
https://github.com/logto-io/logto.git
synced 2025-01-27 21:39:16 -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 React, { ReactNode, AnchorHTMLAttributes } from 'react';
|
||||
import { TFuncKey, useTranslation } from 'react-i18next';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import * as styles from './index.module.scss';
|
||||
|
||||
|
@ -9,11 +10,20 @@ export type Props = AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|||
children?: ReactNode;
|
||||
text?: TFuncKey<'translation', 'main_flow'>;
|
||||
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' });
|
||||
|
||||
if (to) {
|
||||
return (
|
||||
<Link className={classNames(styles.link, styles[type], className)} to={to}>
|
||||
{children ?? (text ? t(text) : '')}
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<a className={classNames(styles.link, styles[type], className)} {...rest} rel="noreferrer">
|
||||
{children ?? (text ? t(text) : '')}
|
||||
|
|
|
@ -87,7 +87,7 @@ export const CreateAccountLink = ({
|
|||
<TextLink
|
||||
className={styles.createAccount}
|
||||
type="secondary"
|
||||
href={`/register/${primarySignInMethod}`}
|
||||
to={`/register/${primarySignInMethod}`}
|
||||
text="action.create_account"
|
||||
/>
|
||||
</>
|
||||
|
|
Loading…
Add table
Reference in a new issue