import React, { FormEvent, useCallback, useState } from 'react' import { Alert, Button, Card, Form } from 'react-bootstrap' import { Trans, useTranslation } from 'react-i18next' import { useSelector } from 'react-redux' import { Link } from 'react-router-dom' import { doInternalLogin } from '../../../api/auth' import { ApplicationState } from '../../../redux' import { ShowIf } from '../../common/show-if/show-if' import { getAndSetUser } from './utils' export const ViaInternal: React.FC = () => { const { t } = useTranslation() const [username, setUsername] = useState('') const [password, setPassword] = useState('') const [error, setError] = useState(false) const allowRegister = useSelector((state: ApplicationState) => state.config.allowRegister) const onLoginSubmit = useCallback((event: FormEvent) => { doInternalLogin(username, password) .then(() => getAndSetUser()) .catch(() => setError(true)) event.preventDefault() }, [username, password]) return (
setUsername(event.currentTarget.value)} className="bg-dark text-light" autoComplete='username' /> setPassword(event.currentTarget.value)} className="bg-dark text-light" autoComplete='current-password' />
) }