Skip to content

Commit

Permalink
organizing and improving the admin panel and workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanGrims committed Sep 15, 2024
1 parent 1c2841e commit 5a28e8c
Show file tree
Hide file tree
Showing 17 changed files with 2,187 additions and 0 deletions.
82 changes: 82 additions & 0 deletions src/admin/auth/Login.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import {
sendPasswordResetEmail,
signInWithEmailAndPassword,
} from "firebase/auth";
import { alert, prompt, snackbar } from "mdui";
import React from "react";
import { auth } from "../../firebase";

export default function Login() {
const [email, setEmail] = React.useState("");
const [password, setPassword] = React.useState("");

const handleLogin = () => {
signInWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
console.log(userCredential);
})
.catch((error) => {
snackbar({
message: error.message,
});
});
};

const handlePasswordReset = () => {
prompt({
headline: "Passwort zurücksetzen",
description: "Bitte gib deine Email-Adresse ein.",
confirmText: "Senden",
cancelText: "Abbrechen",
closeOnOverlayClick: true,
textFieldOptions: {
placeholder: "user@example.com",
type: "email",
label: "Email",
},
onConfirm: (email) => {
sendPasswordResetEmail(auth, email)
.then(() => {
alert({
headline: "Email gesendet",
description: "Bitte überprüfen Sie Ihren Posteingang.",
});
})
.catch((error) => {
console.error(error);
});
},
});
};

return (
<mdui-card variant="filled" class="card">
<div className="mdui-prose">
<h1>Login</h1>
<mdui-text-field
value={email}
onInput={(e) => setEmail(e.target.value)}
type="email"
placeholder="user@example.com"
label="Email"
/>
<p />
<mdui-text-field
value={password}
onInput={(e) => setPassword(e.target.value)}
type="password"
label="Passwort"
toggle-password
/>
<p />
<br />
<div className="button-container">
<mdui-button variant="text" onClick={handlePasswordReset}>
Passwort zurücksetzen
</mdui-button>
<mdui-button onClick={handleLogin}>Login</mdui-button>
</div>
</div>
</mdui-card>
);
}
Loading

0 comments on commit 5a28e8c

Please sign in to comment.