Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 69 additions & 59 deletions src/Signin.jsx
Original file line number Diff line number Diff line change
@@ -1,69 +1,79 @@
import Button from '@mui/material/Button';
import Button from "@mui/material/Button";
import TextField from "@mui/material/TextField";
import {Card, Typography} from "@mui/material";
import {useState} from "react";
import { Card, Typography } from "@mui/material";
import { useState } from "react";
import axios from "axios";

function Signin() {
const [email, setEmail] = useState("")
const [password, setPassword] = useState("")
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");

return <div>
<div style={{
paddingTop: 150,
marginBottom: 10,
display: "flex",
justifyContent: "center"
}}>
<Typography variant={"h6"}>
Welcome to Coursera. Sign up below
</Typography>
</div>
<div style={{display: "flex", justifyContent: "center"}}>
<Card varint={"outlined"} style={{width: 400, padding: 20}}>
<TextField
onChange={(evant11) => {
let elemt = evant11.target;
setEmail(elemt.value);
}}
fullWidth={true}
label="Email"
variant="outlined"
/>
<br/><br/>
<TextField
onChange={(e) => {
setPassword(e.target.value);
}}
fullWidth={true}
label="Password"
variant="outlined"
type={"password"}
/>
<br/><br/>
return (
<div>
<div
style={{
paddingTop: 150,
marginBottom: 10,
display: "flex",
justifyContent: "center",
}}
>
<Typography variant={"h6"}>
Welcome to Coursera. Sign up below
</Typography>
</div>
<div style={{ display: "flex", justifyContent: "center" }}>
<Card varint={"outlined"} style={{ width: 400, padding: 20 }}>
<TextField
onChange={(evant11) => {
let elemt = evant11.target;
setEmail(elemt.value);
}}
fullWidth={true}
label="Email"
variant="outlined"
/>
<br />
<br />
<TextField
onChange={(e) => {
setPassword(e.target.value);
}}
fullWidth={true}
label="Password"
variant="outlined"
type={"password"}
/>
<br />
<br />

<Button
size={"large"}
variant="contained"
onClick={async () => {
const res = await axios.post("http://localhost:3000/admin/login", {
username: email,
password: password
}, {
headers: {
"Content-type": "application/json"
}
});
const data = res.data;

localStorage.setItem("token", data.token);
window.location = "/"
}}
<Button
size={"large"}
variant="contained"
onClick={async () => {
const res = await axios.post(
"http://localhost:3000/admin/login",
{},
{
headers: {
username: email,
password: password,
},
}
);
const data = res.data;

> Signin</Button>
</Card>
</div>
localStorage.setItem("token", data.token);
window.location = "/";
}}
>
{" "}
Signin
</Button>
</Card>
</div>
</div>
);
}

export default Signin;
export default Signin;