@mui/icons-material#LockRounded TypeScript Examples

The following examples show how to use @mui/icons-material#LockRounded. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DetailError.tsx    From airmessage-web with Apache License 2.0 5 votes vote down vote up
function DetailErrorAuth(props: {resetCallback?: VoidFunction | undefined}) {
	const [password, setPassword] = useState("");
	const updatePassword = useCallback((event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) => setPassword(event.target.value), [setPassword]);
	
	const [isLoading, setIsLoading] = useState(false);
	const confirm = useCallback(() => {
		if(password.trim().length === 0) return;
		
		setIsLoading(true);
		Promise.all([setCryptoPassword(password), setSecureLS(SecureStorageKey.ServerPassword, password)]).then(connect);
	}, [setIsLoading, password]);
	const onKeyDown = useCallback((event: React.KeyboardEvent<HTMLDivElement>) => {
		//Confirm when enter is pressed
		if(event.key === "Enter") {
			confirm();
		}
	}, [confirm]);
	
	return (<>
		<LockRounded className={styles.icon} />
		<div className={styles.split}>
			<Typography variant="h4" gutterBottom>Server is password-protected</Typography>
			<Typography color="textSecondary" gutterBottom>Please enter your server password</Typography>
			<TextField label="Password" variant="filled" type="password" autoComplete="current-password" margin="normal" autoFocus
					   value={password} onChange={updatePassword} onKeyDown={onKeyDown} />
			<div className={`${styles.buttonRow} ${styles.buttonRowReverse}`}>
				<Button variant="contained" disableElevation onClick={confirm} disabled={password.trim().length === 0 || isLoading}>Continue</Button>
				{props.resetCallback && <Button onClick={props.resetCallback}>Reconfigure</Button>}
			</div>
		</div>
	</>);
}