Move login mutation

This commit is contained in:
jeffvli
2022-11-20 02:03:21 -08:00
parent 0cb2e40f2b
commit b1d06581ab
2 changed files with 5 additions and 2 deletions
@@ -2,6 +2,7 @@ import { useMutation } from '@tanstack/react-query';
import md5 from 'md5'; import md5 from 'md5';
import { nanoid } from 'nanoid'; import { nanoid } from 'nanoid';
import { api } from '@/renderer/api'; import { api } from '@/renderer/api';
import { QueryOptions } from '@/renderer/lib/react-query';
import { useAuthStore } from '@/renderer/store'; import { useAuthStore } from '@/renderer/store';
export const useLogin = ( export const useLogin = (
@@ -9,7 +10,8 @@ export const useLogin = (
body: { body: {
password: string; password: string;
username: string; username: string;
} },
options?: QueryOptions
) => { ) => {
const login = useAuthStore((state) => state.login); const login = useAuthStore((state) => state.login);
@@ -35,5 +37,6 @@ export const useLogin = (
localStorage.setItem('device_id', nanoid()); localStorage.setItem('device_id', nanoid());
} }
}, },
...options,
}); });
}; };
@@ -5,7 +5,7 @@ import { useSearchParams } from 'react-router-dom';
import styled from 'styled-components'; import styled from 'styled-components';
import { Button, PasswordInput, Text, TextInput } from '@/renderer/components'; import { Button, PasswordInput, Text, TextInput } from '@/renderer/components';
import { ErrorFallback } from '@/renderer/features/action-required'; import { ErrorFallback } from '@/renderer/features/action-required';
import { useLogin } from '@/renderer/features/auth/queries/use-login'; import { useLogin } from '@/renderer/features/auth/mutations/use-login';
import { normalizeServerUrl } from '@/renderer/utils'; import { normalizeServerUrl } from '@/renderer/utils';
const Container = styled(Box)` const Container = styled(Box)`