notifications feathericons
This commit is contained in:
@ -4,8 +4,7 @@ import './InputForm.css';
|
||||
import {getUser, loginUser} from '../services/PhpApi'
|
||||
import useSWR from 'swr';
|
||||
import { PasswordInput, Stack, TextInput } from '@mantine/core';
|
||||
import { showNotification } from '@mantine/notifications';
|
||||
import { CheckCircledIcon, CrossCircledIcon, ExclamationTriangleIcon } from '@radix-ui/react-icons';
|
||||
import { notificationAlert, notificationError, notificationSuccess } from '../services/Notifications';
|
||||
|
||||
|
||||
const Login = () =>
|
||||
@ -22,18 +21,7 @@ const Login = () =>
|
||||
|
||||
if (error)
|
||||
{
|
||||
showNotification(
|
||||
{
|
||||
icon: <div style=
|
||||
{
|
||||
{
|
||||
transform: "translate(0px, -2px) scale(2.2)"
|
||||
}
|
||||
}>
|
||||
<CrossCircledIcon/></div>,
|
||||
color: 'red',
|
||||
message: error.message
|
||||
});
|
||||
notificationError(error.message);
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -64,57 +52,19 @@ const Login = () =>
|
||||
|
||||
if(!Object.values(formData).every(val => val.trim() !== ''))
|
||||
{
|
||||
showNotification(
|
||||
{
|
||||
icon: <div style=
|
||||
{
|
||||
{
|
||||
transform: "translate(0px, -2px) scale(1.5)"
|
||||
}
|
||||
}>
|
||||
<ExclamationTriangleIcon/></div>,
|
||||
color: 'orange',
|
||||
message: 'Bitte alle Felder ausfüllen!'
|
||||
});
|
||||
notificationAlert('Bitte alle Felder ausfüllen!');
|
||||
return;
|
||||
}
|
||||
|
||||
const logResp = await loginUser(formData);
|
||||
if(logResp.success)
|
||||
{
|
||||
showNotification(
|
||||
{
|
||||
icon: <div style=
|
||||
{
|
||||
{
|
||||
transform: "translate(0px, -2px) scale(2.2)"
|
||||
}
|
||||
}>
|
||||
<CheckCircledIcon/></div>,
|
||||
color: 'green',
|
||||
message: logResp.message
|
||||
});
|
||||
notificationSuccess(logResp.message);
|
||||
mutate(); // update swr
|
||||
}
|
||||
else
|
||||
{
|
||||
// if(logResp.message === undefined)
|
||||
// {
|
||||
// toast.error(logResp);
|
||||
// }
|
||||
// else
|
||||
showNotification(
|
||||
{
|
||||
icon: <div style=
|
||||
{
|
||||
{
|
||||
transform: "translate(0px, -2px) scale(2.2)"
|
||||
}
|
||||
}>
|
||||
<CrossCircledIcon/></div>,
|
||||
color: 'red',
|
||||
message: logResp.message
|
||||
});
|
||||
notificationError(logResp.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user