icons neu, toaster weg
This commit is contained in:
@ -5,7 +5,6 @@ import {getUser, loginUser} from '../services/PhpApi'
|
|||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
import { PasswordInput, Stack, TextInput } from '@mantine/core';
|
import { PasswordInput, Stack, TextInput } from '@mantine/core';
|
||||||
import { showNotification } from '@mantine/notifications';
|
import { showNotification } from '@mantine/notifications';
|
||||||
//import {IonIcon} from '@ionic/react'
|
|
||||||
import { CheckCircledIcon, CrossCircledIcon, ExclamationTriangleIcon } from '@radix-ui/react-icons';
|
import { CheckCircledIcon, CrossCircledIcon, ExclamationTriangleIcon } from '@radix-ui/react-icons';
|
||||||
|
|
||||||
|
|
||||||
@ -25,7 +24,13 @@ const Login = () =>
|
|||||||
{
|
{
|
||||||
showNotification(
|
showNotification(
|
||||||
{
|
{
|
||||||
icon: <CrossCircledIcon />,
|
icon: <div style=
|
||||||
|
{
|
||||||
|
{
|
||||||
|
transform: "translate(0px, -2px) scale(2.2)"
|
||||||
|
}
|
||||||
|
}>
|
||||||
|
<CrossCircledIcon/></div>,
|
||||||
color: 'red',
|
color: 'red',
|
||||||
message: error.message
|
message: error.message
|
||||||
});
|
});
|
||||||
@ -61,9 +66,15 @@ const Login = () =>
|
|||||||
{
|
{
|
||||||
showNotification(
|
showNotification(
|
||||||
{
|
{
|
||||||
icon: <ExclamationTriangleIcon/>,
|
icon: <div style=
|
||||||
|
{
|
||||||
|
{
|
||||||
|
transform: "translate(0px, -2px) scale(1.5)"
|
||||||
|
}
|
||||||
|
}>
|
||||||
|
<ExclamationTriangleIcon/></div>,
|
||||||
color: 'orange',
|
color: 'orange',
|
||||||
message: 'Please Fill in all Required Fields!'
|
message: 'Bitte alle Felder ausfüllen!'
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -73,7 +84,13 @@ const Login = () =>
|
|||||||
{
|
{
|
||||||
showNotification(
|
showNotification(
|
||||||
{
|
{
|
||||||
icon: <CheckCircledIcon/>,
|
icon: <div style=
|
||||||
|
{
|
||||||
|
{
|
||||||
|
transform: "translate(0px, -2px) scale(2.2)"
|
||||||
|
}
|
||||||
|
}>
|
||||||
|
<CheckCircledIcon/></div>,
|
||||||
color: 'green',
|
color: 'green',
|
||||||
message: logResp.message
|
message: logResp.message
|
||||||
});
|
});
|
||||||
@ -88,7 +105,13 @@ const Login = () =>
|
|||||||
// else
|
// else
|
||||||
showNotification(
|
showNotification(
|
||||||
{
|
{
|
||||||
icon: <CrossCircledIcon width={30}/>,
|
icon: <div style=
|
||||||
|
{
|
||||||
|
{
|
||||||
|
transform: "translate(0px, -2px) scale(2.2)"
|
||||||
|
}
|
||||||
|
}>
|
||||||
|
<CrossCircledIcon/></div>,
|
||||||
color: 'red',
|
color: 'red',
|
||||||
message: logResp.message
|
message: logResp.message
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
import {useState} from 'react'
|
import {useState} from 'react'
|
||||||
import {Link} from 'react-router-dom'
|
import {Link} from 'react-router-dom'
|
||||||
import toast, { Toaster } from 'react-hot-toast';
|
|
||||||
import './InputForm.css';
|
import './InputForm.css';
|
||||||
import {registerUser} from '../services/PhpApi';
|
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';
|
||||||
|
|
||||||
const Register = () =>
|
const Register = () =>
|
||||||
{
|
{
|
||||||
@ -25,47 +27,106 @@ const Register = () =>
|
|||||||
|
|
||||||
if(!Object.values(formData).every(val => val.trim() !== ''))
|
if(!Object.values(formData).every(val => val.trim() !== ''))
|
||||||
{
|
{
|
||||||
toast.error('Bitte alle Felder ausfüllen!');
|
showNotification(
|
||||||
|
{
|
||||||
|
icon: <div style=
|
||||||
|
{
|
||||||
|
{
|
||||||
|
transform: "translate(0px, -2px) scale(1.5)"
|
||||||
|
}
|
||||||
|
}>
|
||||||
|
<ExclamationTriangleIcon/></div>,
|
||||||
|
color: 'orange',
|
||||||
|
message: 'Bitte alle Felder ausfüllen!'
|
||||||
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(formData.password !== formData.password2)
|
if(formData.password !== formData.password2)
|
||||||
{
|
{
|
||||||
toast.error('Bitte 2mal das gleiche Passwort eingeben!');
|
showNotification(
|
||||||
|
{
|
||||||
|
icon: <div style=
|
||||||
|
{
|
||||||
|
{
|
||||||
|
transform: "translate(0px, -2px) scale(1.5)"
|
||||||
|
}
|
||||||
|
}>
|
||||||
|
<ExclamationTriangleIcon/></div>,
|
||||||
|
color: 'orange',
|
||||||
|
message: 'Bitte 2mal das gleiche Passwort eingeben!'
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await registerUser(formData);
|
const data = await registerUser(formData);
|
||||||
if(data.success)
|
if(data.success)
|
||||||
{
|
{
|
||||||
toast.success('Erfolgreich Registriert!');
|
showNotification(
|
||||||
|
{
|
||||||
|
icon: <div style=
|
||||||
|
{
|
||||||
|
{
|
||||||
|
transform: "translate(0px, -2px) scale(2.2)"
|
||||||
|
}
|
||||||
|
}>
|
||||||
|
<CheckCircledIcon/></div>,
|
||||||
|
color: 'green',
|
||||||
|
message: 'Erfolgreich Registriert!'
|
||||||
|
});
|
||||||
e.currentTarget.reset();
|
e.currentTarget.reset();
|
||||||
}
|
}
|
||||||
else if(!data.success && data.message)
|
else if(!data.success && data.message)
|
||||||
{
|
{
|
||||||
toast.error(data.message);
|
showNotification(
|
||||||
|
{
|
||||||
|
icon: <div style=
|
||||||
|
{
|
||||||
|
{
|
||||||
|
transform: "translate(0px, -2px) scale(2.2)"
|
||||||
|
}
|
||||||
|
}>
|
||||||
|
<CrossCircledIcon/></div>,
|
||||||
|
color: 'red',
|
||||||
|
message: data.message
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='InputForm'>
|
<div className='InputForm'>
|
||||||
<Toaster toastOptions={{ position: "top-center" }} />
|
|
||||||
<h2>Register</h2>
|
<h2>Register</h2>
|
||||||
<div className='frameCenter'>
|
<div className='frameCenter'>
|
||||||
<div className='frame'>
|
<div className='frame'>
|
||||||
<form onSubmit={submitForm}>
|
<form onSubmit={submitForm}>
|
||||||
<div className='neben'>
|
<Stack align="flex-start" sx={{textAlign: 'left'}}>
|
||||||
<label htmlFor="email">Email: </label>
|
<TextInput
|
||||||
<input type="email" name="email" onChange={onChangeInput} placeholder="Deine email" id="email" value={formData.email} required />
|
label = 'Email:'
|
||||||
</div>
|
type="email"
|
||||||
<div className='neben'>
|
name="email"
|
||||||
<label htmlFor="password">Passwort: </label>
|
onChange={onChangeInput}
|
||||||
<input type="password" name="password" onChange={onChangeInput} placeholder="New password" id="password" value={formData.password} required />
|
placeholder="Deine Email"
|
||||||
</div>
|
id="email"
|
||||||
<div className='neben'>
|
value={formData.email}
|
||||||
<label htmlFor="password2">Passwort wiederholen: </label>
|
required />
|
||||||
<input type="password" name="password2" onChange={onChangeInput} placeholder="New password" id="password2" value={formData.password2} required />
|
<PasswordInput
|
||||||
</div>
|
sx = {{ maxWidth: '80vw', minWidth: '30vw', width: '300px' }}
|
||||||
|
label = 'Passwort:'
|
||||||
|
name="password"
|
||||||
|
onChange={onChangeInput}
|
||||||
|
placeholder="Passwort"
|
||||||
|
id="password" value={formData.password}
|
||||||
|
required/>
|
||||||
|
<PasswordInput
|
||||||
|
sx = {{ maxWidth: '80vw', minWidth: '30vw', width: '300px' }}
|
||||||
|
label = 'Passwort:'
|
||||||
|
name="password2"
|
||||||
|
onChange={onChangeInput}
|
||||||
|
placeholder="Passwort bestätigen"
|
||||||
|
id="password2" value={formData.password2}
|
||||||
|
required/>
|
||||||
|
</Stack>
|
||||||
<button type="submit" >Register</button>
|
<button type="submit" >Register</button>
|
||||||
<div className="bottom-link"><Link to="/login">Login</Link></div>
|
<div className="bottom-link"><Link to="/login">Login</Link></div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user