2020-12-24 02:39:48 +02:00
|
|
|
import React from "react";
|
|
|
|
import PropTypes from "prop-types";
|
2020-12-16 01:29:56 +02:00
|
|
|
import { makeStyles } from "@material-ui/core/styles";
|
2020-12-24 02:39:48 +02:00
|
|
|
import { TextField, InputAdornment, Button } from "@material-ui/core";
|
2020-12-19 03:12:10 +02:00
|
|
|
import { AccountCircleOutlined } from "@material-ui/icons";
|
|
|
|
import PasswordField from "../../../components/common/inputs/PasswordField";
|
2020-12-23 02:24:38 +02:00
|
|
|
import { useTranslation } from "react-i18next";
|
2020-12-16 01:29:56 +02:00
|
|
|
|
2020-12-19 02:28:20 +02:00
|
|
|
const useStyles = makeStyles(theme => ({
|
2020-12-19 03:12:10 +02:00
|
|
|
field: {
|
|
|
|
margin: theme.spacing(1),
|
|
|
|
width: "20ch"
|
2020-12-19 02:28:20 +02:00
|
|
|
}
|
2020-12-16 01:29:56 +02:00
|
|
|
}));
|
2020-12-08 03:03:15 +02:00
|
|
|
|
2020-12-24 02:39:48 +02:00
|
|
|
const LoginComponent = ({ credentials, onChange, onLogin }) => {
|
2020-12-16 01:29:56 +02:00
|
|
|
const classes = useStyles();
|
2020-12-23 02:24:38 +02:00
|
|
|
const { t } = useTranslation();
|
2020-12-19 04:22:38 +02:00
|
|
|
|
2020-12-16 01:29:56 +02:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<TextField
|
2020-12-19 03:12:10 +02:00
|
|
|
className={classes.field}
|
2020-12-16 01:29:56 +02:00
|
|
|
id="username"
|
2020-12-23 02:24:38 +02:00
|
|
|
label={t("Login.Username")}
|
2020-12-24 02:39:48 +02:00
|
|
|
onChange={onChange("userName")}
|
|
|
|
value={credentials.userName}
|
2020-12-16 01:29:56 +02:00
|
|
|
InputProps={{
|
|
|
|
startAdornment: (
|
|
|
|
<InputAdornment position="start">
|
|
|
|
<AccountCircleOutlined />
|
|
|
|
</InputAdornment>
|
2020-12-19 02:28:20 +02:00
|
|
|
)
|
2020-12-16 01:29:56 +02:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<br />
|
2020-12-19 04:22:38 +02:00
|
|
|
<PasswordField
|
|
|
|
id="password"
|
2020-12-23 02:24:38 +02:00
|
|
|
label={t("Login.Password")}
|
2020-12-19 04:22:38 +02:00
|
|
|
className={classes.field}
|
2020-12-24 02:39:48 +02:00
|
|
|
onChange={onChange("password")}
|
|
|
|
value={credentials.password}
|
2020-12-19 04:22:38 +02:00
|
|
|
/>
|
2020-12-24 02:39:48 +02:00
|
|
|
<br />
|
|
|
|
<Button variant="contained" color="primary" onClick={onLogin}>
|
|
|
|
{t("Login.Label")}
|
|
|
|
</Button>
|
2020-12-16 01:29:56 +02:00
|
|
|
</div>
|
|
|
|
);
|
2020-12-08 03:03:15 +02:00
|
|
|
};
|
|
|
|
|
2020-12-24 02:39:48 +02:00
|
|
|
LoginComponent.propTypes = {
|
|
|
|
credentials: PropTypes.object.isRequired,
|
|
|
|
onChange: PropTypes.func.isRequired,
|
|
|
|
onLogin: PropTypes.func.isRequired
|
|
|
|
};
|
|
|
|
|
2020-12-08 03:03:15 +02:00
|
|
|
export default LoginComponent;
|