Build a login form component
For our login form, we must take in an email, and a password, send that to our login API call function, and insert the token into local storage if the login was successful.
To achieve this, we import the following:
// ingress/frontend/src/components/LoginForm.tsx
import React from 'react';
import '../Login.css';
import { login } from '../api/login';
interface LoginFormProps {
setToken: (token: string) => void;
}
With the preceding imports and interface, we can define our login form component's signature with the code below:
// ingress/frontend/src/components/LoginForm.tsx
export const LoginForm: React.FC<LoginFormProps> = (
{ setToken }
) => {
const [email, setEmail] = React.useState<string>("");
const [password, setPassword] = React.useState<string>("");
const submitLogin = () => {
. . .
};
const handlePasswordChange = (
...