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 {
|
try {
|
||||||
await fetcher(values.username, values.password);
|
await fetcher(values.username, values.password);
|
||||||
onSuccess();
|
onSuccess();
|
||||||
showToastSuccess(getRandomPhrase('WELCOME'));
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showErrorToast(error);
|
showErrorToast(error);
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,23 @@
|
||||||
import { useAuthStore } from '~/store/auth/useAuthStore';
|
import { useAuthStore } from '~/store/auth/useAuthStore';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { apiUserLogin } from '~/api/auth';
|
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 = () => {
|
export const useLoginLogoutRestore = () => {
|
||||||
const auth = useAuthStore();
|
const auth = useAuthStore();
|
||||||
|
|
||||||
const logout = useCallback(() => auth.logout(), [auth]);
|
const logout = useCallback(() => {
|
||||||
|
auth.logout();
|
||||||
|
showToastInfo(getRandomPhrase('GOODBYE'));
|
||||||
|
}, [auth]);
|
||||||
|
|
||||||
const login = useCallback(
|
const login = useCallback(
|
||||||
async (username: string, password: string) => {
|
async (username: string, password: string) => {
|
||||||
const result = await apiUserLogin({ username, password });
|
const result = await apiUserLogin({ username, password });
|
||||||
auth.setToken(result.token);
|
auth.setToken(result.token);
|
||||||
|
showToastInfo(getRandomPhrase('WELCOME'));
|
||||||
return result.user;
|
return result.user;
|
||||||
},
|
},
|
||||||
[auth]
|
[auth]
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
.toast {
|
.toast {
|
||||||
@include outer_shadow;
|
@include outer_shadow;
|
||||||
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font: $font_14_semibold;
|
font: $font_14_semibold;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue