mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-03 12:41:45 +02:00
ui: fix login/signup dialogs
This commit is contained in:
@@ -8,12 +8,12 @@ import { useStore } from "../../stores/user-store";
|
||||
import PasswordInput from "../inputs/password";
|
||||
import Dropper from "../dropper";
|
||||
|
||||
const form = { error: true };
|
||||
function LoginDialog(props) {
|
||||
const { onClose } = props;
|
||||
const [error, setError] = useState();
|
||||
const isLoggingIn = useStore((store) => store.isLoggingIn);
|
||||
const login = useStore((store) => store.login);
|
||||
const form = { error: true };
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
@@ -51,6 +51,7 @@ function LoginDialog(props) {
|
||||
function submit(setError, form, login, onClose) {
|
||||
setError();
|
||||
if (form.error) return;
|
||||
|
||||
login(form)
|
||||
.then(onClose)
|
||||
.catch((e) => setError(e.message));
|
||||
|
||||
@@ -9,12 +9,12 @@ import PasswordInput from "../inputs/password";
|
||||
import Dropper from "../dropper";
|
||||
import { useStore } from "../../stores/user-store";
|
||||
|
||||
const form = { error: true };
|
||||
function SignUpDialog(props) {
|
||||
const { onClose } = props;
|
||||
const [error, setError] = useState();
|
||||
const isSigningIn = useStore((store) => store.isSigningIn);
|
||||
const signup = useStore((store) => store.signup);
|
||||
const form = { error: true };
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
@@ -49,6 +49,10 @@ function SignUpDialog(props) {
|
||||
|
||||
function submit(setError, form, signup, onClose) {
|
||||
setError();
|
||||
if (form.password !== form.confirm) {
|
||||
form.error = true;
|
||||
setError("Passwords do not match.");
|
||||
}
|
||||
if (form.error) return;
|
||||
signup(form)
|
||||
.then(onClose)
|
||||
|
||||
@@ -12,7 +12,10 @@ function PasswordInput(props) {
|
||||
title="Confirm Password"
|
||||
type="password"
|
||||
error="Passwords do not match"
|
||||
validate={(password, form) => form.password === password}
|
||||
name="confirm"
|
||||
validate={(password, form) =>
|
||||
!form.password || form.password === password
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</Dropper>
|
||||
|
||||
Reference in New Issue
Block a user