notifications feathericons
This commit is contained in:
@ -3,12 +3,12 @@ import { Link } from "react-router-dom";
|
||||
import {upload as ApiUpload} from "../services/PhpApi";
|
||||
import PreviewUpload from "./PreviewUpload";
|
||||
import './InputForm.css';
|
||||
import { notificationError, notificationSuccess } from "../services/Notifications";
|
||||
|
||||
const FileUpload: React.FC = () =>
|
||||
{
|
||||
const [currentFile, setCurrentFile] = useState<File>();
|
||||
const [progress, setProgress] = useState(0);
|
||||
const [message, setMessage] = useState("");
|
||||
|
||||
|
||||
const selectFile = (pl: File) =>
|
||||
@ -28,7 +28,7 @@ const FileUpload: React.FC = () =>
|
||||
})
|
||||
.then((response) =>
|
||||
{
|
||||
setMessage(response.data.message);
|
||||
notificationSuccess(response.data.message);
|
||||
return;
|
||||
})
|
||||
.catch((err) =>
|
||||
@ -37,11 +37,11 @@ const FileUpload: React.FC = () =>
|
||||
|
||||
if (err.response && err.response.data && err.response.data.message)
|
||||
{
|
||||
setMessage(err.response.data.message);
|
||||
notificationError(err.response.data.message);
|
||||
}
|
||||
else
|
||||
{
|
||||
setMessage("Could not upload the File!");
|
||||
notificationError("Could not upload the File!");
|
||||
}
|
||||
|
||||
setCurrentFile(undefined);
|
||||
@ -82,11 +82,6 @@ const FileUpload: React.FC = () =>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{message && (
|
||||
<div className="alert alert-secondary mt-3" role="alert">
|
||||
{message}
|
||||
</div>
|
||||
)}
|
||||
<Link to={"/profil"}>Zurück zum Profil</Link>
|
||||
</div>
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7,8 +7,8 @@ import './Qr.css';
|
||||
import './InputForm.css';
|
||||
import useSWR from 'swr';
|
||||
import { NumberInput, Stack, Checkbox, MantineProvider } from '@mantine/core';
|
||||
import { showNotification } from '@mantine/notifications';
|
||||
import {DndList, DndListProps, TDataItem} from './DndList';
|
||||
import { notificationError, notificationSuccess } from '../services/Notifications';
|
||||
|
||||
|
||||
export default function Qr()
|
||||
@ -141,19 +141,12 @@ export default function Qr()
|
||||
{
|
||||
if(resQR.success)
|
||||
{
|
||||
showNotification(
|
||||
{
|
||||
message: 'Daten gesichert!'
|
||||
});
|
||||
notificationSuccess('Daten gesichert!');
|
||||
mutate();
|
||||
}
|
||||
else if(!resQR.success && resQR.message)
|
||||
{
|
||||
showNotification(
|
||||
{
|
||||
message: resQR.message
|
||||
|
||||
});
|
||||
notificationError(resQR.message);
|
||||
}
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
|
||||
@ -3,8 +3,7 @@ import {Link} from 'react-router-dom'
|
||||
import './InputForm.css';
|
||||
import {registerUser} from '../services/PhpApi';
|
||||
import { PasswordInput, Stack, TextInput } from '@mantine/core';
|
||||
import { CheckCircledIcon, CrossCircledIcon, ExclamationTriangleIcon } from '@radix-ui/react-icons';
|
||||
import { showNotification } from '@mantine/notifications';
|
||||
import { notificationAlert, notificationError, notificationSuccess } from '../services/Notifications';
|
||||
|
||||
const Register = () =>
|
||||
{
|
||||
@ -27,70 +26,26 @@ const Register = () =>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if(formData.password !== formData.password2)
|
||||
{
|
||||
showNotification(
|
||||
{
|
||||
icon: <div style=
|
||||
{
|
||||
{
|
||||
transform: "translate(0px, -2px) scale(1.5)"
|
||||
}
|
||||
}>
|
||||
<ExclamationTriangleIcon/></div>,
|
||||
color: 'orange',
|
||||
message: 'Bitte 2mal das gleiche Passwort eingeben!'
|
||||
});
|
||||
notificationAlert('Bitte 2mal das gleiche Passwort eingeben!');
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await registerUser(formData);
|
||||
if(data.success)
|
||||
{
|
||||
showNotification(
|
||||
{
|
||||
icon: <div style=
|
||||
{
|
||||
{
|
||||
transform: "translate(0px, -2px) scale(2.2)"
|
||||
}
|
||||
}>
|
||||
<CheckCircledIcon/></div>,
|
||||
color: 'green',
|
||||
message: 'Erfolgreich Registriert!'
|
||||
});
|
||||
notificationSuccess('Erfolgreich Registriert!');
|
||||
e.currentTarget.reset();
|
||||
}
|
||||
else if(!data.success && data.message)
|
||||
{
|
||||
showNotification(
|
||||
{
|
||||
icon: <div style=
|
||||
{
|
||||
{
|
||||
transform: "translate(0px, -2px) scale(2.2)"
|
||||
}
|
||||
}>
|
||||
<CrossCircledIcon/></div>,
|
||||
color: 'red',
|
||||
message: data.message
|
||||
});
|
||||
notificationError(data.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user