notificationXXXX

This commit is contained in:
2023-02-19 19:12:25 +01:00
parent e765fed019
commit 5329337923
6 changed files with 28 additions and 30 deletions

View File

@ -13,12 +13,12 @@ import FileUpload from './components/FileUpload';
import Profil from './components/Profil'; import Profil from './components/Profil';
import useSWR from 'swr'; import useSWR from 'swr';
import {getUser} from './services/PhpApi' import {getUser} from './services/PhpApi'
import toast, { Toaster } from 'react-hot-toast';
import { TUser } from './context/UserContext'; import { TUser } from './context/UserContext';
import PasswordReset from './components/PasswordReset'; import PasswordReset from './components/PasswordReset';
import WantNewPw from './components/WantNewPw'; import WantNewPw from './components/WantNewPw';
import { MantineProvider } from '@mantine/core'; import { MantineProvider } from '@mantine/core';
import { NotificationsProvider } from '@mantine/notifications'; import { NotificationsProvider } from '@mantine/notifications';
import { notificationError } from './services/Notifications';
const App: React.FC = () => const App: React.FC = () =>
{ {
@ -29,10 +29,9 @@ const App: React.FC = () =>
if (error) if (error)
{ {
toast.error(error.message); notificationError(error.message);
return ( return (
<> <>
<Toaster toastOptions={{ position: "top-center" }} />
<div>failed to load</div> <div>failed to load</div>
</>); </>);
} }

View File

@ -1,5 +1,5 @@
import { useState } from "react"; import { useState } from "react";
import toast, { Toaster } from "react-hot-toast"; import { notificationError, notificationSuccess } from "../services/Notifications";
import { foundMsg, logFormData } from "../services/PhpApi"; import { foundMsg, logFormData } from "../services/PhpApi";
import './ContactForm.css'; import './ContactForm.css';
@ -38,7 +38,7 @@ export default function DogContactForm(
if(!Object.values(formData).every(val => val.trim() !== '')) if(!Object.values(formData).every(val => val.trim() !== ''))
{ {
toast.error('Bitte alle Felder ausfüllen!'); notificationError('Bitte alle Felder ausfüllen!');
return; return;
} }
@ -67,12 +67,12 @@ export default function DogContactForm(
if(data.success) if(data.success)
{ {
toast.success('Eine Kopie wurde auch an ' + toEmail + ' geschickt!'); notificationSuccess('Eine Kopie wurde auch an ' + toEmail + ' geschickt!');
toast.success('Nachricht gesendet!'); notificationSuccess('Nachricht gesendet!');
} }
else if(!data.success && data.message) else if(!data.success && data.message)
{ {
toast.error(data.message); notificationError(data.message);
} }
} }
@ -80,7 +80,6 @@ export default function DogContactForm(
<> <>
<div className="flexCenter"> <div className="flexCenter">
<div className="containerForm"> <div className="containerForm">
<Toaster toastOptions={{ position: "top-center" }} />
<form className="formForm" id='idForm' onSubmit={submitForm}> <form className="formForm" id='idForm' onSubmit={submitForm}>
<div className="rowForm"> <div className="rowForm">
<div>Bitte schreib eine Email:</div><div></div> <div>Bitte schreib eine Email:</div><div></div>

View File

@ -2,7 +2,7 @@ import './Header.css';
import '../App.css'; import '../App.css';
import './InputForm.css'; import './InputForm.css';
import {logOut} from '../services/PhpApi' import {logOut} from '../services/PhpApi'
import { toast, Toaster } from 'react-hot-toast'; import { notificationSuccess } from '../services/Notifications';
function Header() function Header()
@ -10,14 +10,13 @@ function Header()
const logOutForm = () => const logOutForm = () =>
{ {
logOut(); logOut();
toast.success("logged out!"); notificationSuccess("logged out!");
window.location.href = '/dog/'; window.location.href = '/dog/';
} }
return ( return (
<div className='logout InputForm'> <div className='logout InputForm'>
<Toaster toastOptions={{ position: "top-center" }} />
<div className='noprint'>Header</div> <div className='noprint'>Header</div>
<button onClick={logOutForm}>Logout</button> <button onClick={logOutForm}>Logout</button>
</div> </div>

View File

@ -1,9 +1,9 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import toast, { Toaster } from 'react-hot-toast';
import { Link, useParams } from 'react-router-dom'; import { Link, useParams } from 'react-router-dom';
import { passwordReset, getPwToken } from '../services/PhpApi'; import { passwordReset, getPwToken } from '../services/PhpApi';
import useSWR from 'swr'; import useSWR from 'swr';
import './InputForm.css'; import './InputForm.css';
import { notificationError, notificationSuccess } from '../services/Notifications';
export default function PasswordReset() export default function PasswordReset()
{ {
@ -31,7 +31,6 @@ export default function PasswordReset()
{ {
return( return(
<div > <div >
<Toaster toastOptions={{ position: "top-center" }} />
<h2>Email nicht mehr gültig!</h2> <h2>Email nicht mehr gültig!</h2>
</div> </div>
) )
@ -43,13 +42,13 @@ export default function PasswordReset()
if(!Object.values(formData).every(val => val.trim() !== '')) if(!Object.values(formData).every(val => val.trim() !== ''))
{ {
toast.error('Bitte alle Felder ausfüllen!'); notificationError('Bitte alle Felder ausfüllen!');
return; return;
} }
if(formData.password1 !== formData.password2) if(formData.password1 !== formData.password2)
{ {
toast.error('Bitte 2mal das gleiche Passwort eingeben!'); notificationError('Bitte 2mal das gleiche Passwort eingeben!');
return; return;
} }
@ -68,18 +67,17 @@ export default function PasswordReset()
const dataRes = await passwordReset(sendData); const dataRes = await passwordReset(sendData);
if(dataRes.success) if(dataRes.success)
{ {
toast.success('Erfolgreich Passwort geändert!'); notificationSuccess('Erfolgreich Passwort geändert!');
e.currentTarget?.reset(); e.currentTarget?.reset();
} }
else if(!dataRes.success && dataRes.message) else if(!dataRes.success && dataRes.message)
{ {
toast.error(dataRes.message); notificationError(dataRes.message);
} }
} }
return ( return (
<div className='InputForm'> <div className='InputForm'>
<Toaster toastOptions={{ position: "top-center" }} />
<h2>Passwort zurücksetzten!</h2> <h2>Passwort zurücksetzten!</h2>
<div className='frameCenter'> <div className='frameCenter'>
<div className='frame'> <div className='frame'>

View File

@ -1,7 +1,6 @@
import React, { useRef, useState } from 'react'; import React, { useRef, useState } from 'react';
import useSWR from 'swr'; import useSWR from 'swr';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import toast, { Toaster } from 'react-hot-toast';
import {TUser} from '../context/UserContext'; import {TUser} from '../context/UserContext';
import {getProfilData, updateDog} from '../services/PhpApi'; import {getProfilData, updateDog} from '../services/PhpApi';
import CreateQr from '../services/CreateQr'; import CreateQr from '../services/CreateQr';
@ -9,6 +8,7 @@ import Img from './Img';
import './InputForm.css'; import './InputForm.css';
import './Profil.css'; import './Profil.css';
import { TextInput } from '@mantine/core'; import { TextInput } from '@mantine/core';
import { notificationError, notificationSuccess } from '../services/Notifications';
function Profil() function Profil()
{ {
@ -79,8 +79,9 @@ function Profil()
formData_loc = formData_loc =
{ {
...formData_loc, ...formData_loc,
[e.currentTarget.name]:e.currentTarget.value [e!.currentTarget.name]:e!.currentTarget.value
}; };
setFormData(formData_loc); setFormData(formData_loc);
edit.current = true; edit.current = true;
formDataSave.current = {...formData_loc}; formDataSave.current = {...formData_loc};
@ -90,21 +91,25 @@ function Profil()
{ {
if(data.success) if(data.success)
{ {
toast.success('Daten geändert!'); notificationSuccess('Daten geändert!');
} }
else if(!data.success && data.message) else if(!data.success && data.message)
{ {
toast.error(data.message); notificationError(data.message);
} }
} }
const submitForm = async (e: React.FormEvent<HTMLFormElement>) => const submitForm = async (e: React.FormEvent<HTMLFormElement>) =>
{ {
e.preventDefault(); e.preventDefault();
console.log(formData);
console.log(formData_loc);
console.log(formDataSave.current);
if(!Object.values(formData).every(val => val?.trim() !== '')) if(!Object.values(formData).every(val => val?.trim() !== ''))
{ {
toast.error('Bitte alle Felder ausfüllen!'); notificationError('Bitte alle Felder ausfüllen!');
return; return;
} }
setFormData(formData); setFormData(formData);
@ -143,7 +148,6 @@ function Profil()
return ( return (
<div className='InputForm'> <div className='InputForm'>
<Toaster toastOptions={{ position: "top-center" }} />
<h2>Profil</h2> <h2>Profil</h2>
<div className='frameCenter'> <div className='frameCenter'>
<div className='frame'> <div className='frame'>

View File

@ -1,6 +1,6 @@
import { TextInput } from '@mantine/core'; import { TextInput } from '@mantine/core';
import React, { useState } from 'react' import React, { useState } from 'react'
import toast, { Toaster } from 'react-hot-toast'; import { notificationError, notificationSuccess } from '../services/Notifications';
import {wantNewPw} from '../services/PhpApi' import {wantNewPw} from '../services/PhpApi'
import './InputForm.css'; import './InputForm.css';
@ -28,18 +28,17 @@ function WantNewPw()
const data = await wantNewPw({email: email}); const data = await wantNewPw({email: email});
if(data.success) if(data.success)
{ {
toast.success('Passwort angefordert! Bitte Postfach ' + email + ' checken!'); notificationSuccess('Passwort angefordert! Bitte Postfach ' + email + ' checken!');
//e.currentTarget.reset(); //e.currentTarget.reset();
} }
else if(!data.success && data.message) else if(!data.success && data.message)
{ {
toast.error(data.message); notificationError(data.message);
} }
} }
return ( return (
<div className='InputForm'> <div className='InputForm'>
<Toaster toastOptions={{ position: "top-center" }} />
<h2>Neues Passwort setzen!</h2> <h2>Neues Passwort setzen!</h2>
<div className='frameCenter'> <div className='frameCenter'>
<div className='frame'> <div className='frame'>