2024-08-05 03:11:03 +02:00
|
|
|
import React, {createContext, useEffect, useState} from "react";
|
|
|
|
|
import {Button, Card} from "antd";
|
2024-07-28 15:36:22 +02:00
|
|
|
import {t} from 'ttag'
|
2024-08-05 02:29:42 +02:00
|
|
|
import TextPage from "./TextPage";
|
2024-08-05 03:11:03 +02:00
|
|
|
import {LoginForm} from "../components/LoginForm";
|
|
|
|
|
import {getConfiguration, InstanceConfig} from "../utils/api";
|
|
|
|
|
import {RegisterForm} from "../components/RegisterForm";
|
2024-07-26 18:31:47 +02:00
|
|
|
|
2024-08-05 02:29:42 +02:00
|
|
|
|
2024-07-26 18:31:47 +02:00
|
|
|
export const AuthenticatedContext = createContext<any>(null)
|
2024-07-23 18:37:59 +02:00
|
|
|
|
2024-08-02 16:17:55 +02:00
|
|
|
export default function LoginPage() {
|
2024-07-26 18:31:47 +02:00
|
|
|
|
2024-08-05 03:11:03 +02:00
|
|
|
const [wantRegister, setWantRegister] = useState<boolean>(false)
|
2024-08-04 15:49:38 +02:00
|
|
|
const [configuration, setConfiguration] = useState<InstanceConfig>()
|
2024-07-26 18:31:47 +02:00
|
|
|
|
2024-08-05 03:11:03 +02:00
|
|
|
const toggleWantRegister = () => {
|
|
|
|
|
setWantRegister(!wantRegister)
|
2024-07-26 18:31:47 +02:00
|
|
|
}
|
|
|
|
|
|
2024-08-02 16:17:55 +02:00
|
|
|
useEffect(() => {
|
2024-08-04 15:49:38 +02:00
|
|
|
getConfiguration().then(setConfiguration)
|
2024-08-02 16:17:55 +02:00
|
|
|
}, [])
|
|
|
|
|
|
2024-08-05 03:11:03 +02:00
|
|
|
return <Card title={wantRegister ? t`Register` : t`Log in`} style={{width: '100%'}}>
|
2024-08-21 02:01:20 +02:00
|
|
|
<Card.Grid style={{width: '50%', textAlign: 'center'}} hoverable={false}>
|
2024-08-05 03:11:03 +02:00
|
|
|
{wantRegister ? <RegisterForm/> : <LoginForm ssoLogin={configuration?.ssoLogin}/>}
|
|
|
|
|
{
|
|
|
|
|
configuration?.registerEnabled &&
|
|
|
|
|
<Button type='link'
|
|
|
|
|
block
|
|
|
|
|
style={{marginTop: '1em'}}
|
2024-08-05 03:43:02 +02:00
|
|
|
onClick={toggleWantRegister}>{wantRegister ? t`Log in` : t`Create an account`}</Button>
|
2024-08-05 03:11:03 +02:00
|
|
|
}
|
2024-08-05 02:29:42 +02:00
|
|
|
</Card.Grid>
|
2024-08-05 14:21:52 +02:00
|
|
|
<Card.Grid style={{width: '50%'}} hoverable={false}>
|
2024-08-05 02:29:42 +02:00
|
|
|
<TextPage resource='ads.md'/>
|
|
|
|
|
</Card.Grid>
|
2024-07-26 18:31:47 +02:00
|
|
|
</Card>
|
2024-07-23 18:37:59 +02:00
|
|
|
}
|