NotificationStore

This commit is contained in:
2023-03-06 21:45:33 +01:00
parent ccf89a1cd4
commit dfead23a53
4 changed files with 78 additions and 8 deletions

View File

@ -5,8 +5,9 @@ import {getUser, loginUser} from '../services/PhpApi'
import useSWR from 'swr';
import { PasswordInput, Stack, TextInput } from '@mantine/core';
import { notificationAlert, notificationError, notificationSuccess } from '../services/Notifications';
//import { eNotif, useNotificationStore } from "../services/NotificationStore";
const Login = () =>
{
const [formData, setFormData] = useState({
@ -15,6 +16,7 @@ const Login = () =>
});
// only for redirect
const {data, error, isLoading, mutate} = useSWR("/login", getUser);
// const { AddNotification, DeleteNotification, queue } = useNotificationStore();
//const navigate = useNavigate();
console.log('Login getUser');
console.log(data);
@ -32,8 +34,30 @@ const Login = () =>
if(data.success)
{
// AddNotification({type: eNotif.success, msg: 'Login erfolgreich!'});
window.location.href = '/dog/';
}
// if(queue.length > 0)
// {
// console.log('queue');
// console.log(queue);
// const not = queue[queue.length-1];
// switch (not.type) {
// case eNotif.success:
// notificationSuccess(not.msg);
// break;
// case eNotif.error:
// notificationError(not.msg);
// break;
// case eNotif.alert:
// default:
// notificationAlert(not.msg);
// }
// DeleteNotification();
// }
const onChangeInput = (e: React.FormEvent<HTMLInputElement>) =>
{