generated from pesto-students/PESTO_NINJA-TEMPLATE
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merged master in feature/cart
- Loading branch information
Showing
35 changed files
with
854 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"extends": ["react-app"] | ||
"extends": ["react-app"], | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1 @@ | ||
import React from 'react'; | ||
import { Footer } from '../common'; | ||
import Header from '../common/header'; | ||
import Body from './Body'; | ||
import SideBar from './SideBar'; | ||
import { Container, ProductListing } from './styledComponents'; | ||
|
||
function ProductListingPage() { | ||
return ( | ||
<> | ||
<Header /> | ||
<ProductListing> | ||
<SideBar /> | ||
<Container> | ||
<Body /> | ||
</Container> | ||
</ProductListing> | ||
<Footer /> | ||
</> | ||
); | ||
} | ||
|
||
export default ProductListingPage; | ||
export { default } from './ProductListingPage'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
import { Footer } from '../common'; | ||
import Header from '../common/header'; | ||
import Body from './Body'; | ||
import SideBar from './SideBar'; | ||
import { Container, ProductListing } from './styledComponents'; | ||
|
||
function ProductListingPage() { | ||
return ( | ||
<> | ||
<Header /> | ||
<ProductListing> | ||
<SideBar /> | ||
<Container> | ||
<Body /> | ||
</Container> | ||
</ProductListing> | ||
<Footer /> | ||
</> | ||
); | ||
} | ||
|
||
export default ProductListingPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//import signin and signup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React from 'react'; | ||
import { Input } from '../../common'; | ||
import useSigninContainer from './signinContainer'; | ||
import { SignInContainer, SignInFormContainer } from './styledComponents'; | ||
import { Button } from '../../common'; | ||
import FeatherIcon from 'feather-icons-react'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
const SignIn = (props) => { | ||
const { handleStateChange, componentState, handleSignin } = useSigninContainer(); | ||
return ( | ||
<SignInContainer> | ||
<SignInFormContainer> | ||
<h2>Login</h2> | ||
<form className="login-form"> | ||
<div className="login-inputs"> | ||
<Input | ||
style={{border:'1px solid'}} | ||
type="text" | ||
label="Email" | ||
placeholder="Enter Email" | ||
error="" | ||
name="email" | ||
onChange={(e) => handleStateChange(e.target.name, e.target.value)} | ||
value={componentState?.email} | ||
/> | ||
</div> | ||
<div className="login-inputs"> | ||
<Input | ||
style={{border:'1px solid'}} | ||
type="password" | ||
label="Password" | ||
placeholder="Enter password" | ||
error="" | ||
name="password" | ||
onChange={(e) => handleStateChange(e.target.name, e.target.value)} | ||
value={componentState?.password} | ||
/> | ||
</div> | ||
<Button onClick={(e)=>{handleSignin('self', e)}} style={{ width: '100%', margin: '10px 0' }} text="Login" /> | ||
<Button | ||
onClick={(e)=>{handleSignin('google', e)}} | ||
style={{ width: '100%', margin: '10px 0' }} | ||
text="Google Login" | ||
/> | ||
<div className="login-social-container"> | ||
<FeatherIcon | ||
className="login-social-icon-github" | ||
icon="github" | ||
size="30" | ||
/> | ||
<FeatherIcon | ||
className="login-social-icon-facebook" | ||
icon="facebook" | ||
size="30" | ||
/> | ||
</div> | ||
</form> | ||
<div> | ||
<span> | ||
{`don't have account? `} | ||
<Link to="/SignUp">SignUp</Link> | ||
</span> | ||
</div> | ||
</SignInFormContainer> | ||
</SignInContainer> | ||
); | ||
}; | ||
|
||
SignIn.propTypes = {}; | ||
|
||
export default SignIn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import firebase from 'firebase/compat/app'; | ||
import 'firebase/compat/auth'; | ||
import { useState } from 'react'; | ||
import { googleAuthProvider } from '../../../config/firebase/authProviders'; | ||
import useErrorContext from '../../../hooks/useErrorContext'; | ||
|
||
const useSigninContainer = (props) => { | ||
const errorContext = useErrorContext(); | ||
const [componentState, setComponentState] = useState({ | ||
email: '', | ||
password: '', | ||
error: null, | ||
isLoading: false, | ||
isSuccess: false, | ||
isError: false | ||
}); | ||
|
||
const handleStateChange = (name, value) => { | ||
setComponentState({ | ||
...componentState, | ||
[name]: value | ||
}); | ||
}; | ||
|
||
const handleSignin = async (providerName, event) => { | ||
event?.preventDefault(); | ||
setComponentState({ ...componentState, isLoading: true }); | ||
if (providerName === 'google') { | ||
const userCred = await firebase | ||
.auth() | ||
.signInWithPopup(googleAuthProvider); | ||
} else if (providerName === 'self') { | ||
try { | ||
const userCred = await firebase | ||
.auth() | ||
.signInWithEmailAndPassword( | ||
componentState.email, | ||
componentState.password | ||
); | ||
setComponentState({ | ||
...componentState, | ||
isLoading: false, | ||
isSuccess: true, | ||
isError: false | ||
}); | ||
} catch (err) { | ||
console.log(err.code, err.message); | ||
errorContext.showError(err.code, err.message); | ||
setComponentState({ | ||
...componentState, | ||
isLoading: false, | ||
isSuccess: false, | ||
isError: true, | ||
error: err | ||
}); | ||
} | ||
} | ||
}; | ||
|
||
return { | ||
componentState, | ||
handleStateChange, | ||
handleSignin | ||
}; | ||
}; | ||
|
||
export default useSigninContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const SignInContainer = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 100vw; | ||
height: 100vh; | ||
color: ${(props) => props.theme.colors.primary}; | ||
`; | ||
|
||
export const SignInFormContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
width: 320px; | ||
text-align: center; | ||
color: ${(props) => props.theme.colors.primary}; | ||
.login-social-container { | ||
display: flex; | ||
justify-content: space-around; | ||
width: 80%; | ||
margin: 10px auto; | ||
.login-social-icon-github { | ||
&:hover { | ||
color: #9845a5; | ||
cursor: pointer; | ||
} | ||
} | ||
.login-social-icon-facebook { | ||
&:hover { | ||
color: #3b5998; | ||
cursor: pointer; | ||
} | ||
} | ||
} | ||
.login-inputs { | ||
margin: 10px 0px; | ||
} | ||
form { | ||
box-sizing: border-box; | ||
width: 100%; | ||
padding-left: 10px; | ||
padding-right: 10px; | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import React from 'react'; | ||
import ReCAPTCHA from "react-google-recaptcha"; | ||
import { Button, Input } from '../../common'; | ||
import useSignupContainer from './signupContainer'; | ||
import { InputContainer, SignupComponentTitle, SignUpContainer } from './styledComponents'; | ||
|
||
const SignupComponent = props => { | ||
const {componentState, handleChange, handleCreateAccount} = useSignupContainer(); | ||
return ( | ||
<SignUpContainer> | ||
<SignupComponentTitle>SignUp</SignupComponentTitle> | ||
<form className='signup-form'> | ||
<InputContainer> | ||
<Input | ||
style={{marginRight: '5px'}} | ||
type='text' | ||
name='firstName' | ||
placeholder='First Name' | ||
label='First Name' | ||
value={componentState.firstName} | ||
onChange={(e)=>handleChange(e.target.name, e.target.value)} | ||
/> | ||
<Input | ||
className='signup-input' | ||
type='text' | ||
name='lastName' | ||
placeholder='Last Name' | ||
label='Last Name' | ||
value={componentState.lastName} | ||
onChange={(e)=>handleChange(e.target.name, e.target.value)} | ||
/> | ||
</InputContainer> | ||
<InputContainer > | ||
<Input | ||
style={{width: '320px'}} | ||
type='email' | ||
name='email' | ||
placeholder='Email' | ||
label='Email' | ||
value={componentState.email} | ||
onChange={(e)=>handleChange(e.target.name, e.target.value)} | ||
/> | ||
</InputContainer> | ||
<InputContainer > | ||
<Input | ||
style={{width: '320px'}} | ||
type='password' | ||
name='password' | ||
placeholder='Password' | ||
label='Password' | ||
value={componentState.password} | ||
onChange={(e)=>handleChange(e.target.name, e.target.value)} | ||
/> | ||
</InputContainer> | ||
<InputContainer > | ||
<Input | ||
style={{width: '320px'}} | ||
type='password' | ||
name='confirmPassword' | ||
placeholder='Email' | ||
label='Confirm Password' | ||
value={componentState.confirmPassword} | ||
onChange={(e)=>handleChange(e.target.name, e.target.value)} | ||
/> | ||
</InputContainer> | ||
|
||
</form> | ||
<Button | ||
onClick={handleCreateAccount} | ||
disabled={!componentState.isSuccess} | ||
style={{margin:'10px 0', width:'320px'}} text='SignUp' | ||
/> | ||
<ReCAPTCHA | ||
sitekey="6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI" | ||
onChange={(e)=>{e? handleChange('isSuccess', true): handleChange('isSuccess', false)}} | ||
/> | ||
</SignUpContainer> | ||
); | ||
}; | ||
|
||
SignupComponent.propTypes = { | ||
|
||
}; | ||
|
||
export default SignupComponent; |
Oops, something went wrong.