2021-11-10 13:53:28 +01:00
|
|
|
import { FormEvent, Fragment, useState } from 'react';
|
2021-06-15 12:36:23 +02:00
|
|
|
|
2021-11-10 13:53:28 +01:00
|
|
|
// Redux
|
|
|
|
import { useDispatch, useSelector } from 'react-redux';
|
|
|
|
import { bindActionCreators } from 'redux';
|
|
|
|
import { actionCreators } from '../../../store';
|
|
|
|
import { State } from '../../../store/reducers';
|
|
|
|
|
|
|
|
// UI
|
|
|
|
import { Button, InputGroup, SettingsHeadline } from '../../UI';
|
|
|
|
|
|
|
|
// CSS
|
2021-06-15 12:36:23 +02:00
|
|
|
import classes from './AppDetails.module.css';
|
2021-11-10 13:53:28 +01:00
|
|
|
|
|
|
|
// Utils
|
2021-06-15 12:36:23 +02:00
|
|
|
import { checkVersion } from '../../../utility';
|
|
|
|
|
2021-11-09 14:33:51 +01:00
|
|
|
export const AppDetails = (): JSX.Element => {
|
2021-11-10 13:53:28 +01:00
|
|
|
const { isAuthenticated } = useSelector((state: State) => state.auth);
|
|
|
|
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
const { login, logout } = bindActionCreators(actionCreators, dispatch);
|
|
|
|
|
|
|
|
const [password, setPassword] = useState('');
|
|
|
|
|
|
|
|
const formHandler = (e: FormEvent) => {
|
|
|
|
e.preventDefault();
|
|
|
|
login(password);
|
|
|
|
setPassword('');
|
|
|
|
};
|
|
|
|
|
2021-06-15 12:36:23 +02:00
|
|
|
return (
|
|
|
|
<Fragment>
|
2021-11-10 13:53:28 +01:00
|
|
|
<SettingsHeadline text="Authentication" />
|
|
|
|
{!isAuthenticated ? (
|
|
|
|
<form onSubmit={formHandler}>
|
|
|
|
<InputGroup>
|
|
|
|
<label htmlFor="password">Password</label>
|
|
|
|
<input
|
|
|
|
type="password"
|
|
|
|
id="password"
|
|
|
|
name="password"
|
|
|
|
placeholder="••••••"
|
|
|
|
value={password}
|
|
|
|
onChange={(e) => setPassword(e.target.value)}
|
|
|
|
/>
|
|
|
|
<span>
|
|
|
|
See
|
|
|
|
<a
|
|
|
|
href="https://github.com/pawelmalak/flame/wiki/Authentication"
|
|
|
|
target="blank"
|
|
|
|
>
|
|
|
|
{` project wiki `}
|
|
|
|
</a>
|
|
|
|
to read more about authentication
|
|
|
|
</span>
|
|
|
|
</InputGroup>
|
|
|
|
|
|
|
|
<Button>Login</Button>
|
|
|
|
</form>
|
|
|
|
) : (
|
|
|
|
<div>
|
|
|
|
<p className={classes.text}>
|
|
|
|
You are logged in. Your session will expire <span>@@@@</span>
|
|
|
|
</p>
|
|
|
|
<Button click={logout}>Logout</Button>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
|
|
|
|
<hr className={classes.separator} />
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<SettingsHeadline text="App version" />
|
|
|
|
<p className={classes.text}>
|
|
|
|
<a
|
|
|
|
href="https://github.com/pawelmalak/flame"
|
|
|
|
target="_blank"
|
|
|
|
rel="noreferrer"
|
|
|
|
>
|
|
|
|
Flame
|
|
|
|
</a>{' '}
|
|
|
|
version {process.env.REACT_APP_VERSION}
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<p className={classes.text}>
|
|
|
|
See changelog{' '}
|
|
|
|
<a
|
|
|
|
href="https://github.com/pawelmalak/flame/blob/master/CHANGELOG.md"
|
|
|
|
target="_blank"
|
|
|
|
rel="noreferrer"
|
|
|
|
>
|
|
|
|
here
|
|
|
|
</a>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<Button click={() => checkVersion(true)}>Check for updates</Button>
|
|
|
|
</div>
|
2021-06-15 12:36:23 +02:00
|
|
|
</Fragment>
|
2021-11-09 14:33:51 +01:00
|
|
|
);
|
|
|
|
};
|