2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 03:26:45 +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:
Matthias Mair 2025-03-16 23:03:42 +01:00 committed by GitHub
parent a453c9b286
commit 897afd029b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,7 +1,7 @@
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 { useEffect, useMemo } from 'react';
import { useEffect, useMemo, useState } from 'react';
import { useLocation, useNavigate, useSearchParams } from 'react-router-dom';
import { setApiDefaults } from '../../App';
import { AuthFormOptions } from '../../components/forms/AuthFormOptions';
@ -27,6 +27,7 @@ export default function Login() {
state.server,
state.fetchServerApiState
]);
const [isLoggingIn, setIsLoggingIn] = useState<boolean>(false);
const hostname =
hostList[hostKey] === undefined ? t`No selection` : hostList[hostKey]?.name;
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)
if (searchParams.has('login') && searchParams.has('password')) {
setIsLoggingIn(true);
doBasicLogin(
searchParams.get('login') ?? '',
searchParams.get('password') ?? '',
@ -94,22 +96,28 @@ export default function Login() {
) : (
<>
<Wrapper titleText={t`Login`} smallPadding>
<AuthenticationForm />
{both_reg_enabled === false && (
<Text ta='center' size={'xs'} mt={'md'}>
<Trans>Don&apos;t have an account?</Trans>{' '}
<Anchor
component='button'
type='button'
c='dimmed'
size='xs'
onClick={() => navigate('/register')}
>
<Trans>Register</Trans>
</Anchor>
</Text>
{isLoggingIn ? (
<Loader />
) : (
<>
<AuthenticationForm />
{both_reg_enabled === false && (
<Text ta='center' size={'xs'} mt={'md'}>
<Trans>Don&apos;t have an account?</Trans>{' '}
<Anchor
component='button'
type='button'
c='dimmed'
size='xs'
onClick={() => navigate('/register')}
>
<Trans>Register</Trans>
</Anchor>
</Text>
)}
{LoginMessage}{' '}
</>
)}
{LoginMessage}
</Wrapper>
<AuthFormOptions hostname={hostname} toggleHostEdit={setHostEdit} />
</>