import React, { FC, useState } from 'react'; import { Box, Button, CircularProgress, FormControlLabel, FormGroup, Switch, TextField } from '@mui/material'; import { SubmitHandler, useForm } from 'react-hook-form'; import { useCas } from '../../hook/useCas'; import { LoginEasterEgg } from './LoginEasterEgg'; import { LoginHelpCenter } from './LoginHelpCenter'; import { LoginHeader } from './LoginHeader'; import { Card } from '../../ui/Card'; import Visibility from '@mui/icons-material/Visibility'; import VisibilityOff from '@mui/icons-material/VisibilityOff'; import IconButton from '@mui/material/IconButton'; type LoginForm = { username: string; password: string; permanentLogin: boolean }; export const Login: FC = () => { const { getContextOrganisation } = useCas(); const [showPassword, setShowPassword] = useState(false); const [isLogging, setLogging] = useState(false); const organisation = getContextOrganisation(); const { register, handleSubmit, watch, formState: { errors }, } = useForm({ defaultValues: { username: '', password: '', permanentLogin: false }, }); const [username, password] = [watch('username'), watch('password')]; const onSubmit: SubmitHandler = (data) => { setLogging(true); login(data.username, data.password, data.permanentLogin).then(() => setLogging(false)); }; const login = async (username: string, password: string, permanentLogin: boolean) => { // TODO }; return ( } footer={ } label="Stay signed in" /> } >
{organisation?.description && {organisation.description}} setShowPassword(!showPassword)} edge="end" > {showPassword ? : } ), }} /> {isLogging ? ( ) : ( )}
); };