mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 12:06:44 +00:00
feat(frontend): show if redirecting inline (#9122)
* https://github.com/inventree/InvenTree/pull/6293 * refactor to a shared component * refactoring container stuff to a wrapper * move title to wrapper * move logoff and loader to wrapper * mvoe functions to general auth * seperate login and register into seperate pages * unify auth styling * rename component * adapt to new look * check if registration is enabled * feat(frontend):show if redirecting * reduce diff * fix missing import * remove double warning
This commit is contained in:
parent
a453c9b286
commit
897afd029b
@ -1,7 +1,7 @@
|
|||||||
import { Trans, t } from '@lingui/macro';
|
import { Trans, t } from '@lingui/macro';
|
||||||
import { Anchor, Divider, Text } from '@mantine/core';
|
import { Anchor, Divider, Loader, Text } from '@mantine/core';
|
||||||
import { useToggle } from '@mantine/hooks';
|
import { useToggle } from '@mantine/hooks';
|
||||||
import { useEffect, useMemo } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
import { useLocation, useNavigate, useSearchParams } from 'react-router-dom';
|
import { useLocation, useNavigate, useSearchParams } from 'react-router-dom';
|
||||||
import { setApiDefaults } from '../../App';
|
import { setApiDefaults } from '../../App';
|
||||||
import { AuthFormOptions } from '../../components/forms/AuthFormOptions';
|
import { AuthFormOptions } from '../../components/forms/AuthFormOptions';
|
||||||
@ -27,6 +27,7 @@ export default function Login() {
|
|||||||
state.server,
|
state.server,
|
||||||
state.fetchServerApiState
|
state.fetchServerApiState
|
||||||
]);
|
]);
|
||||||
|
const [isLoggingIn, setIsLoggingIn] = useState<boolean>(false);
|
||||||
const hostname =
|
const hostname =
|
||||||
hostList[hostKey] === undefined ? t`No selection` : hostList[hostKey]?.name;
|
hostList[hostKey] === undefined ? t`No selection` : hostList[hostKey]?.name;
|
||||||
const [hostEdit, setHostEdit] = useToggle([false, true] as const);
|
const [hostEdit, setHostEdit] = useToggle([false, true] as const);
|
||||||
@ -73,6 +74,7 @@ export default function Login() {
|
|||||||
|
|
||||||
// check if we got login params (login and password)
|
// check if we got login params (login and password)
|
||||||
if (searchParams.has('login') && searchParams.has('password')) {
|
if (searchParams.has('login') && searchParams.has('password')) {
|
||||||
|
setIsLoggingIn(true);
|
||||||
doBasicLogin(
|
doBasicLogin(
|
||||||
searchParams.get('login') ?? '',
|
searchParams.get('login') ?? '',
|
||||||
searchParams.get('password') ?? '',
|
searchParams.get('password') ?? '',
|
||||||
@ -94,22 +96,28 @@ export default function Login() {
|
|||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Wrapper titleText={t`Login`} smallPadding>
|
<Wrapper titleText={t`Login`} smallPadding>
|
||||||
<AuthenticationForm />
|
{isLoggingIn ? (
|
||||||
{both_reg_enabled === false && (
|
<Loader />
|
||||||
<Text ta='center' size={'xs'} mt={'md'}>
|
) : (
|
||||||
<Trans>Don't have an account?</Trans>{' '}
|
<>
|
||||||
<Anchor
|
<AuthenticationForm />
|
||||||
component='button'
|
{both_reg_enabled === false && (
|
||||||
type='button'
|
<Text ta='center' size={'xs'} mt={'md'}>
|
||||||
c='dimmed'
|
<Trans>Don't have an account?</Trans>{' '}
|
||||||
size='xs'
|
<Anchor
|
||||||
onClick={() => navigate('/register')}
|
component='button'
|
||||||
>
|
type='button'
|
||||||
<Trans>Register</Trans>
|
c='dimmed'
|
||||||
</Anchor>
|
size='xs'
|
||||||
</Text>
|
onClick={() => navigate('/register')}
|
||||||
|
>
|
||||||
|
<Trans>Register</Trans>
|
||||||
|
</Anchor>
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
{LoginMessage}{' '}
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
{LoginMessage}
|
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
<AuthFormOptions hostname={hostname} toggleHostEdit={setHostEdit} />
|
<AuthFormOptions hostname={hostname} toggleHostEdit={setHostEdit} />
|
||||||
</>
|
</>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user