import { CircularProgress, Divider, TextField, Typography } from "@material-ui/core"; import { UserContextError } from "@saleor/auth/types"; import { FormSpacer } from "@saleor/components/FormSpacer"; import { AvailableExternalAuthenticationsQuery } from "@saleor/graphql"; import { SubmitPromise } from "@saleor/hooks/useForm"; import { commonMessages } from "@saleor/intl"; import { Button, EyeIcon, IconButton } from "@saleor/macaw-ui"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; import useStyles from "../styles"; import LoginForm, { LoginFormData } from "./form"; import { getErrorMessage } from "./messages"; export interface LoginCardProps { error?: UserContextError; disabled: boolean; loading: boolean; externalAuthentications?: AvailableExternalAuthenticationsQuery["shop"]["availableExternalAuthentications"]; onExternalAuthentication: (pluginId: string) => void; onPasswordRecovery: () => void; onSubmit?: (event: LoginFormData) => SubmitPromise; } const LoginCard: React.FC = props => { const { error, disabled, loading, externalAuthentications = [], onExternalAuthentication, onPasswordRecovery, onSubmit } = props; const classes = useStyles(props); const intl = useIntl(); const [showPassword, setShowPassword] = React.useState(false); if (loading) { return (
); } return ( {({ change: handleChange, data, submit }) => ( <> {error && (
{getErrorMessage(error, intl)}
)}
{/* Not using endAdornment as it looks weird with autocomplete */} setShowPassword(true)} onMouseUp={() => setShowPassword(false)} >
{externalAuthentications.length > 0 && ( <> )} {externalAuthentications.map(externalAuthentication => ( ))} )}
); }; LoginCard.displayName = "LoginCard"; export default LoginCard;