diff options
author | Biswakalyan Bhuyan <biswa@surgot.in> | 2024-08-01 17:35:27 +0530 |
---|---|---|
committer | Biswakalyan Bhuyan <biswa@surgot.in> | 2024-08-01 17:35:27 +0530 |
commit | fb04271b5288e8fb5891b7d6326f4806d12b82d5 (patch) | |
tree | e459c3e1f8bb6e168becdddd0d48779135d91a7f /panel/src/pages/RegisterPage.jsx | |
parent | 4bb13ee84f6bb51cba6544ccd0690ab2049512a9 (diff) | |
parent | b3c07fd9f1664dda4f16357aaca74dff8226401d (diff) | |
download | admin-panel-fb04271b5288e8fb5891b7d6326f4806d12b82d5.tar.gz admin-panel-fb04271b5288e8fb5891b7d6326f4806d12b82d5.tar.bz2 admin-panel-fb04271b5288e8fb5891b7d6326f4806d12b82d5.zip |
Merge remote-tracking branch 'project/master'
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; |