mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 09:45:04 +01:00
Updated login form.
This commit is contained in:
parent
502facd426
commit
fe01574b16
2
components/declarations.d.ts
vendored
Normal file
2
components/declarations.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
declare module '*.css';
|
||||
declare module '*.svg';
|
@ -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>
|
||||
|
10
next-env.d.ts
vendored
10
next-env.d.ts
vendored
@ -1,5 +1,5 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
||||
|
@ -49,7 +49,7 @@ module.exports = {
|
||||
webpack(config) {
|
||||
config.module.rules.push({
|
||||
test: /\.svg$/,
|
||||
issuer: /\.js$/,
|
||||
issuer: /\.{js|jsx|ts|tsx}$/,
|
||||
use: ['@svgr/webpack'],
|
||||
});
|
||||
|
||||
|
@ -2,6 +2,7 @@ import Head from 'next/head';
|
||||
import { useRouter } from 'next/router';
|
||||
import { IntlProvider } from 'react-intl';
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
import { Container } from 'react-basics';
|
||||
import useLocale from 'hooks/useLocale';
|
||||
import useConfig from 'hooks/useConfig';
|
||||
import 'react-basics/dist/styles.css';
|
||||
@ -12,9 +13,8 @@ import '@fontsource/inter/600.css';
|
||||
const client = new QueryClient();
|
||||
|
||||
export default function App({ Component, pageProps }) {
|
||||
const { locale, messages } = useLocale();
|
||||
const { locale, messages, dir } = useLocale();
|
||||
const { basePath } = useRouter();
|
||||
const { dir } = useLocale();
|
||||
useConfig();
|
||||
|
||||
const Wrapper = ({ children }) => <span className={locale}>{children}</span>;
|
||||
@ -38,9 +38,9 @@ export default function App({ Component, pageProps }) {
|
||||
<meta name="theme-color" content="#2f2f2f" media="(prefers-color-scheme: dark)" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
</Head>
|
||||
<div className="container" dir={dir}>
|
||||
<Container dir={dir}>
|
||||
<Component {...pageProps} />
|
||||
</div>
|
||||
</Container>
|
||||
</IntlProvider>
|
||||
</QueryClientProvider>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user