network-resurrector-frontend/src/features/login/components/LoginComponent.js

69 lines
1.7 KiB
JavaScript
Raw Normal View History

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 13:16:53 +02:00
import {
TextField,
InputAdornment,
Button,
Card,
CardActions,
CardContent
} 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),
2020-12-24 05:35:05 +02:00
width: "300px"
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 (
2020-12-24 13:16:53 +02:00
<Card variant="outlined">
<CardContent>
<TextField
className={classes.field}
id="username"
label={t("Login.Username")}
onChange={onChange("userName")}
value={credentials.userName}
InputProps={{
startAdornment: (
<InputAdornment position="start">
<AccountCircleOutlined />
</InputAdornment>
)
}}
/>
<br />
<PasswordField
id="password"
label={t("Login.Password")}
className={classes.field}
onChange={onChange("password")}
value={credentials.password}
/>
</CardContent>
<CardActions>
<Button variant="contained" color="primary" onClick={onLogin}>
{t("Login.Label")}
</Button>
</CardActions>
</Card>
2020-12-16 01:29:56 +02:00
);
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;