User Registration Completed
This commit is contained in:
parent
9731829c3a
commit
50301724f9
|
@ -2,13 +2,10 @@ import React from 'react'
|
|||
import RegStyle from './Reg.style'
|
||||
import Image from 'next/image'
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||
import {
|
||||
faUser,
|
||||
faEnvelope,
|
||||
faLock,
|
||||
} from '@fortawesome/free-solid-svg-icons'
|
||||
import { useState } from 'react'
|
||||
import { faUser, faEnvelope, faLock } from '@fortawesome/free-solid-svg-icons'
|
||||
import { useState, useContext } from 'react'
|
||||
import { Link } from '@mui/material'
|
||||
import UserAuth from 'helpers/user/usercontext'
|
||||
|
||||
function Reg() {
|
||||
const [userData, setUserData] = useState({
|
||||
|
@ -23,10 +20,15 @@ function Reg() {
|
|||
const value = event.target.value
|
||||
setUserData({ ...userData, [name]: value })
|
||||
}
|
||||
|
||||
const handleSubmit = (e) => {
|
||||
e.preventDefault()
|
||||
setUserData(userData)
|
||||
context.createAcc(userData)
|
||||
}
|
||||
const context = useContext(UserAuth);
|
||||
return (
|
||||
<RegStyle>
|
||||
<form className="form-wrapper">
|
||||
<form onSubmit={handleSubmit} className="form-wrapper">
|
||||
<p className="reg-title">Sign Up</p>
|
||||
|
||||
<div className="reg-field">
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
import UserAuth from "./usercontext"
|
||||
import { useState } from 'react'
|
||||
import axios from "axios"
|
||||
|
||||
const UserAuthProvider = ({ children }) => {
|
||||
const [user, setUser] = useState(null)
|
||||
const login = () => {
|
||||
setUser('default')
|
||||
}
|
||||
const createAcc = (data) => {
|
||||
axios.post('http://localhost:5000/user/register/', {
|
||||
email: data.email,
|
||||
password: data.password,
|
||||
})
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
}
|
||||
|
||||
const logout = () => {
|
||||
setUser(null)
|
||||
}
|
||||
const context = { user, login, logout, createAcc }
|
||||
|
||||
return <UserAuth.Provider value={context}>{children}</UserAuth.Provider>
|
||||
}
|
||||
export default UserAuthProvider;
|
|
@ -1,24 +1,5 @@
|
|||
import { createContext } from 'react'
|
||||
import { useState } from 'react'
|
||||
import { createContext } from "react";
|
||||
|
||||
const UserAuth = createContext({
|
||||
user: null,
|
||||
login: () => {},
|
||||
logout: () => {},
|
||||
})
|
||||
const UserAuth = createContext();
|
||||
|
||||
export const UserAuthProvider = ({ children }) => {
|
||||
const [user, setUser] = useState(null)
|
||||
const login = () => {
|
||||
setUser('default')
|
||||
}
|
||||
|
||||
const logout = () => {
|
||||
setUser(null)
|
||||
}
|
||||
const context = { user, login, logout }
|
||||
|
||||
return <UserAuth.Provider value={context}>{children}</UserAuth.Provider>
|
||||
}
|
||||
|
||||
export default UserAuth
|
||||
export default UserAuth;
|
|
@ -22,6 +22,7 @@
|
|||
"apexcharts": "^3.33.1",
|
||||
"axios": "^0.26.0",
|
||||
"bootstrap": "^5.1.3",
|
||||
"cors": "^2.8.5",
|
||||
"nanoid": "^3.2.0",
|
||||
"next": "12.0.9",
|
||||
"qrcode": "^1.5.0",
|
||||
|
|
|
@ -3,7 +3,7 @@ import '../styles/logostyles.css'
|
|||
import '../styles/formStyles.css'
|
||||
import '../styles/index.css'
|
||||
import '../styles/404.css'
|
||||
import { UserAuthProvider } from '../helpers/user/usercontext'
|
||||
import UserAuthProvider from 'helpers/user/userState'
|
||||
import Page from 'react-page-loading'
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
{
|
||||
"name": "url-minify",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {}
|
||||
"lockfileVersion": 1
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue