diff options
author | Biswakalyan Bhuyan <biswa@surgot.in> | 2024-07-31 12:16:49 +0530 |
---|---|---|
committer | Biswakalyan Bhuyan <biswa@surgot.in> | 2024-07-31 12:16:49 +0530 |
commit | 7dfbe0f363a434cfda5f9be996d194f03c36879c (patch) | |
tree | ae687ee38c31106807934fca524811eb45da0ec9 /panel/src/pages/RegisterPage.jsx | |
download | admin-panel-7dfbe0f363a434cfda5f9be996d194f03c36879c.tar.gz admin-panel-7dfbe0f363a434cfda5f9be996d194f03c36879c.tar.bz2 admin-panel-7dfbe0f363a434cfda5f9be996d194f03c36879c.zip |
new project
Diffstat (limited to 'panel/src/pages/RegisterPage.jsx')
-rw-r--r-- | panel/src/pages/RegisterPage.jsx | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/panel/src/pages/RegisterPage.jsx b/panel/src/pages/RegisterPage.jsx new file mode 100644 index 0000000..f0b2bba --- /dev/null +++ b/panel/src/pages/RegisterPage.jsx @@ -0,0 +1,47 @@ +import React, { useState } from 'react'; +import { TextField, Button, Container, Typography } from '@mui/material'; +import { createUserWithEmailAndPassword } from 'firebase/auth'; +import { auth } from '../firebase'; + +const RegisterPage = () => { + const [email, setEmail] = useState(''); + const [password, setPassword] = useState(''); + const [error, setError] = useState(''); + + const handleRegister = async () => { + if (password.length < 8) { + setError('The password should be minimum 8 digits'); + return; + } + + try { + await createUserWithEmailAndPassword(auth, email, password); + } catch (error) { + setError(error.message); + } + }; + + return ( + <Container> + <Typography variant="h4">Register</Typography> + <TextField + label="Email" + type="email" + value={email} + onChange={(e) => setEmail(e.target.value)} + fullWidth + /> + <TextField + label="Password" + type="password" + value={password} + onChange={(e) => setPassword(e.target.value)} + fullWidth + /> + {error && <Typography color="error">{error}</Typography>} + <Button onClick={handleRegister} variant="contained">Register</Button> + </Container> + ); +}; + +export default RegisterPage; |