-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
269 additions
and
95 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,36 @@ | ||
/* eslint-disable react/display-name */ | ||
import React from 'react'; | ||
import { toast } from 'react-toastify'; | ||
// import requestApi from '<helpers>/requestApi'; | ||
import useApiData from '<hooks>/useApiData'; | ||
import 'react-toastify/dist/ReactToastify.css'; | ||
|
||
const withCheckAuth = (WrappedComponent, path) => (props) => { | ||
const handleSubmit = async (values) => { | ||
// const { data, error } = await requestApi('post', `auth/${path}`, values); | ||
const { | ||
fetchedData, | ||
loading, | ||
error, | ||
} = await useApiData('post', `auth/${path}`, values); | ||
if (loading) { | ||
toast.warn('Loading.....'); | ||
return error; | ||
} | ||
if (error) { | ||
toast.error('Error! User with the same data already exist'); | ||
return error; | ||
} | ||
toast.success('Success Notification!'); | ||
return fetchedData; | ||
}; | ||
|
||
return ( | ||
<WrappedComponent | ||
{...props} | ||
handleSubmit={handleSubmit} | ||
/> | ||
); | ||
}; | ||
|
||
export default withCheckAuth; |
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
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
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,56 @@ | ||
import React, { Fragment } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { ToastContainer } from 'react-toastify'; | ||
import 'react-toastify/dist/ReactToastify.css'; | ||
import AuthForm from '<organisms>/AuthForm/AuthForm'; | ||
import withCheckAuth from '<HOC>/withCheckAuth'; | ||
import Text from '<atoms>/Text/Text'; | ||
import { loginData, loginRules } from './loginItem'; | ||
import FlexContainer from '<atoms>/layouts/FlexContainer/FlexContainer'; | ||
import Image from '<atoms>/Image/Image'; | ||
import ImageUrl from '<image>/home.png'; | ||
|
||
const Login = (props) => { | ||
return ( | ||
<Fragment> | ||
<FlexContainer> | ||
<Text | ||
content="true" | ||
textTransform="uppercase" | ||
padding="md" | ||
fontWeight="normal" | ||
display="inline" | ||
fontSize="normal" | ||
textAlign="center" | ||
color="primary" | ||
> | ||
Welcome to Authors Haven | ||
</Text> | ||
<FlexContainer flexDirection='row'> | ||
<FlexContainer> | ||
<Image | ||
imageUrl={ImageUrl} | ||
boxShadow='none' | ||
altText='welcome' | ||
/> | ||
</FlexContainer> | ||
<FlexContainer> | ||
<AuthForm | ||
title="Sign In" | ||
dividerText="Or Sign In With" | ||
rules={loginRules} | ||
inputData={loginData} | ||
callback={props.handleSubmit} | ||
/> | ||
<ToastContainer /> | ||
</FlexContainer> | ||
</FlexContainer> | ||
</FlexContainer> | ||
</Fragment> | ||
); | ||
}; | ||
|
||
Login.propTypes = { | ||
handleSubmit: PropTypes.func.isRequired, | ||
}; | ||
export default withCheckAuth(Login, 'login'); |
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,18 @@ | ||
const passwordFormat = 'regex:/S*(S*([a-zA-Z]S*[0-9])|([0-9]S*[a-zA-Z]))S*/'; | ||
export const loginRules = { | ||
email: 'required|email', | ||
password: ['required', 'min:8', passwordFormat], | ||
}; | ||
|
||
export const loginData = [ | ||
{ | ||
label: 'Email', | ||
type: 'text', | ||
name: 'email', | ||
}, | ||
{ | ||
label: 'Password', | ||
type: 'password', | ||
name: 'password', | ||
}, | ||
]; |
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,36 @@ | ||
const passwordFormat = 'regex:/S*(S*([a-zA-Z]S*[0-9])|([0-9]S*[a-zA-Z]))S*/'; | ||
export const SignUpRules = { | ||
email: 'required|email', | ||
username: 'required|string|alpha|min:6', | ||
firstName: 'required|string|alpha|min:2', | ||
lastName: 'required|string|alpha|min:2', | ||
password: ['required', 'min:8', passwordFormat], | ||
}; | ||
|
||
export const SignUpData = [ | ||
{ | ||
label: 'First Name', | ||
type: 'text', | ||
name: 'firstName', | ||
}, | ||
{ | ||
label: 'Last Name', | ||
type: 'text', | ||
name: 'lastName', | ||
}, | ||
{ | ||
label: 'User Name', | ||
type: 'text', | ||
name: 'username', | ||
}, | ||
{ | ||
label: 'Email', | ||
type: 'text', | ||
name: 'email', | ||
}, | ||
{ | ||
label: 'Password', | ||
type: 'password', | ||
name: 'password', | ||
}, | ||
]; |
Oops, something went wrong.