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:
parent
6711985d99
commit
8f0ed34790
3 changed files with 9 additions and 2 deletions
|
@ -24,7 +24,6 @@ export const useLoginForm = (
|
|||
try {
|
||||
await fetcher(values.username, values.password);
|
||||
onSuccess();
|
||||
showToastSuccess(getRandomPhrase('WELCOME'));
|
||||
} catch (error) {
|
||||
showErrorToast(error);
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
.toast {
|
||||
@include outer_shadow;
|
||||
|
||||
cursor: pointer;
|
||||
font: $font_14_semibold;
|
||||
user-select: none;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue