mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 22:27:16 +01:00
Updated login form.
This commit is contained in:
parent
502facd426
commit
fe01574b16
5 changed files with 15 additions and 18 deletions
|
|
@ -1,4 +1,3 @@
|
|||
import { useRef } from 'react';
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import {
|
||||
Form,
|
||||
|
|
@ -20,19 +19,15 @@ export default function LoginForm() {
|
|||
const router = useRouter();
|
||||
const { post } = useApi();
|
||||
const { mutate, error, isLoading } = useMutation(data => post('/auth/login', data));
|
||||
const ref = useRef();
|
||||
|
||||
const handleSubmit = async data => {
|
||||
mutate(data, {
|
||||
onSuccess: async ({ token, account }) => {
|
||||
onSuccess: async ({ token, user }) => {
|
||||
setAuthToken(token);
|
||||
setUser(account);
|
||||
setUser(user);
|
||||
|
||||
await router.push('/websites');
|
||||
},
|
||||
onError: async () => {
|
||||
ref.current.reset(undefined, { keepDirty: true, keepValues: true });
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -44,7 +39,7 @@ export default function LoginForm() {
|
|||
</Icon>
|
||||
<p>umami</p>
|
||||
</div>
|
||||
<Form ref={ref} className={styles.form} onSubmit={handleSubmit} error={error}>
|
||||
<Form className={styles.form} onSubmit={handleSubmit} error={error}>
|
||||
<FormInput name="username" label="Username" rules={{ required: 'Required' }}>
|
||||
<TextField autoComplete="off" />
|
||||
</FormInput>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue