notificationXXXX
This commit is contained in:
@ -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'>
|
||||
|
||||
Reference in New Issue
Block a user