Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from amirsaeed671/login-flow
login validation added
- Loading branch information
Showing
14 changed files
with
245 additions
and
28 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from "react"; | ||
import Proptypes from "prop-types"; | ||
|
||
function Button({ disabled, label }) { | ||
return ( | ||
<button | ||
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline" | ||
disabled={disabled} | ||
type="submit" | ||
> | ||
{label} | ||
</button> | ||
); | ||
} | ||
|
||
Button.propTypes = { | ||
label: Proptypes.string.isRequired, | ||
disabled: Proptypes.bool, | ||
}; | ||
|
||
Button.defaultProps = { | ||
disabled: false, | ||
}; | ||
|
||
export default Button; |
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,31 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
import PropTypes from "prop-types"; | ||
|
||
const modalRoot = document.getElementById("modal-root"); | ||
|
||
class Modal extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.el = document.createElement("div"); | ||
} | ||
|
||
componentDidMount() { | ||
modalRoot.appendChild(this.el); | ||
} | ||
|
||
componentWillUnmount() { | ||
modalRoot.removeChild(this.el); | ||
} | ||
|
||
render() { | ||
const { children } = this.props; | ||
return ReactDOM.createPortal(children, this.el); | ||
} | ||
} | ||
|
||
Modal.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
}; | ||
|
||
export default Modal; |
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,34 @@ | ||
import React from "react"; | ||
|
||
function Popup() { | ||
return ( | ||
<div className="w-screen in-animation mx-auto container flex justify-center"> | ||
<div | ||
className="bg-teal-100 border-t-4 fixed mt-6 ml-6 border-teal-500 rounded-b text-teal-900 px-4 py-3 shadow-md" | ||
role="alert" | ||
> | ||
<div className="flex"> | ||
<div className="py-1"> | ||
<svg | ||
className="fill-current h-6 w-6 text-teal-500 mr-4" | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 20 20" | ||
> | ||
<path d="M2.93 17.07A10 10 0 1 1 17.07 2.93 10 10 0 0 1 2.93 17.07zm12.73-1.41A8 8 0 1 0 4.34 4.34a8 8 0 0 0 11.32 11.32zM9 11V9h2v6H9v-4zm0-6h2v2H9V5z" /> | ||
</svg> | ||
</div> | ||
<div> | ||
<p className="font-bold"> | ||
Access token is incorrect! (Unauthorized) | ||
</p> | ||
<p className="text-sm"> | ||
Make sure you've entered the correct access token. | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default Popup; |
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 @@ | ||
import React from "react"; | ||
import Proptypes from "prop-types"; | ||
|
||
function TextArea({ label, id, value, onChange, placeholder, required }) { | ||
return ( | ||
<label className="block text-gray-700 text-sm font-bold mb-2" htmlFor={id}> | ||
{label} | ||
<textarea | ||
className="shadow h-64 resize-none appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" | ||
id={id} | ||
required={required} | ||
value={value} | ||
onChange={onChange} | ||
placeholder={placeholder} | ||
/> | ||
</label> | ||
); | ||
} | ||
|
||
TextArea.propTypes = { | ||
value: Proptypes.string.isRequired, | ||
onChange: Proptypes.string.isRequired, | ||
id: Proptypes.string, | ||
label: Proptypes.string, | ||
placeholder: Proptypes.string, | ||
required: Proptypes.bool, | ||
}; | ||
|
||
TextArea.defaultProps = { | ||
id: "", | ||
label: "", | ||
placeholder: "", | ||
required: false, | ||
}; | ||
|
||
export default TextArea; |
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,29 @@ | ||
import { useState, useEffect } from "react"; | ||
import fetchGists from "observables/fetch-gists"; | ||
|
||
function useFetch() { | ||
const [data, setData] = useState([]); | ||
const [loading, setLoading] = useState(false); | ||
const [error, setError] = useState(null); | ||
|
||
useEffect(() => { | ||
const observer = { | ||
next: (gists) => { | ||
setData(gists); | ||
setLoading(false); | ||
}, | ||
error: (err) => { | ||
setLoading(false); | ||
setError(err); | ||
}, | ||
complete: () => { | ||
setLoading(false); | ||
}, | ||
}; | ||
fetchGists().subscribe(observer); | ||
}, []); | ||
|
||
return [data, loading, error]; | ||
} | ||
|
||
export default useFetch; |
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,9 @@ | ||
import { from } from "rxjs"; | ||
import { pluck } from "rxjs/operators"; | ||
import api from "utils/api"; | ||
|
||
function fetchGists() { | ||
return from(api("gists")).pipe(pluck("data")); | ||
} | ||
|
||
export default fetchGists; |
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,29 @@ | ||
import axios from "axios"; | ||
|
||
const baseURL = "https://api.github.com/"; | ||
|
||
const api = axios.create({ | ||
baseURL, | ||
}); | ||
|
||
api.interceptors.request.use( | ||
function requestCB(config) { | ||
const token = localStorage.getItem("token"); | ||
config.headers.Authorization = `token ${token}`; | ||
return config; | ||
}, | ||
function reqErrorCB(error) { | ||
return Promise.reject(error); | ||
} | ||
); | ||
|
||
api.interceptors.response.use( | ||
function responseCB(response = {}) { | ||
return response.data; | ||
}, | ||
function resErrorCB(error) { | ||
return Promise.reject(error); | ||
} | ||
); | ||
|
||
export default api; |
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