1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00

fixed toasts

This commit is contained in:
Fedor Katurov 2022-01-09 20:52:02 +07:00
parent 6711985d99
commit 8f0ed34790
3 changed files with 9 additions and 2 deletions

View file

@ -24,7 +24,6 @@ export const useLoginForm = (
try {
await fetcher(values.username, values.password);
onSuccess();
showToastSuccess(getRandomPhrase('WELCOME'));
} catch (error) {
showErrorToast(error);

View file

@ -1,16 +1,23 @@
import { useAuthStore } from '~/store/auth/useAuthStore';
import { useCallback } from 'react';
import { apiUserLogin } from '~/api/auth';
import { showErrorToast } from '~/utils/errors/showToast';
import { getRandomPhrase } from '~/constants/phrases';
import { showToastInfo, showToastSuccess } from '~/utils/toast';
export const useLoginLogoutRestore = () => {
const auth = useAuthStore();
const logout = useCallback(() => auth.logout(), [auth]);
const logout = useCallback(() => {
auth.logout();
showToastInfo(getRandomPhrase('GOODBYE'));
}, [auth]);
const login = useCallback(
async (username: string, password: string) => {
const result = await apiUserLogin({ username, password });
auth.setToken(result.token);
showToastInfo(getRandomPhrase('WELCOME'));
return result.user;
},
[auth]

View file

@ -2,6 +2,7 @@
.toast {
@include outer_shadow;
cursor: pointer;
font: $font_14_semibold;
user-select: none;