Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Brian Cao 2022-11-28 13:08:49 -08:00
commit 0a9089a463
5 changed files with 15 additions and 18 deletions

2
components/declarations.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
declare module '*.css';
declare module '*.svg';

View File

@ -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
View File

@ -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.

View File

@ -49,7 +49,7 @@ module.exports = {
webpack(config) {
config.module.rules.push({
test: /\.svg$/,
issuer: /\.js$/,
issuer: /\.{js|jsx|ts|tsx}$/,
use: ['@svgr/webpack'],
});

View File

@ -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>
);