mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-18 11:59:26 +00:00
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import React from "react";
|
|
import Layout from "../components/ui/layout";
|
|
import { Title } from "../components/ui/styles/title";
|
|
import { loginAndGetToken } from "../services/auth";
|
|
|
|
const Login = () => {
|
|
const [email, setEmail] = React.useState("");
|
|
const [password, setPassword] = React.useState("");
|
|
|
|
const handleSubmit = (e: any) => {
|
|
e.preventDefault();
|
|
console.log({ email, password });
|
|
alert(JSON.stringify({ email, password }));
|
|
loginAndGetToken(email, password);
|
|
};
|
|
|
|
const handleEmailChange = (e: any) => {
|
|
setEmail(e.target.value);
|
|
};
|
|
|
|
const handlePasswordChange = (e: any) => {
|
|
setPassword(e.target.value);
|
|
};
|
|
|
|
return (
|
|
<div>
|
|
<Layout title="Login">
|
|
<Title>Login</Title>
|
|
|
|
<form>
|
|
<input onChange={handleEmailChange} type="text" placeholder="email" />
|
|
<input onChange={handlePasswordChange} type="password" placeholder="password" />
|
|
<button onClick={handleSubmit} type="submit">
|
|
Login
|
|
</button>
|
|
</form>
|
|
</Layout>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default Login;
|