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

View File

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

View File

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

View File

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

View File

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

View File

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