-
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.
- Loading branch information
Showing
33 changed files
with
19,035 additions
and
108 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 |
---|---|---|
|
@@ -21,5 +21,4 @@ npm-debug.log* | |
yarn-debug.log* | ||
yarn-error.log* | ||
#idea | ||
.idea/ | ||
package-lock.json | ||
.idea/ |
Large diffs are not rendered by default.
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
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,7 @@ | ||
export const REGISTER_USER = 'REGISTER_USER'; | ||
|
||
export const REGISTER_SUCCESS = 'REGISTER_SUCCESS'; | ||
|
||
export const REGISTER_ERROR = 'REGISTER_ERROR'; | ||
|
||
export const REGISTER_SUMBITTABLE = 'REGISTER_SUBMITTABLE'; |
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,41 @@ | ||
import axios from 'axios'; | ||
import axiosHeader from '../axios_config'; | ||
import * as actionTypes from './action_types'; | ||
|
||
export const submitStatus = submitState => (dispatch) => { | ||
return dispatch({ type: actionTypes.REGISTER_SUMBITTABLE, payload: submitState }); | ||
}; | ||
|
||
export const registerSuccess = () => (dispatch) => { | ||
return dispatch({ type: actionTypes.REGISTER_SUCCESS, payload: true }); | ||
}; | ||
|
||
export const registerUser = userdata => async (dispatch) => { | ||
const postData = JSON.stringify({ user: userdata }); | ||
await axios | ||
.post(`${process.env.REACT_APP_BASE_URL}/users/`, postData, axiosHeader) | ||
.then((result) => { | ||
dispatch({ type: actionTypes.REGISTER_USER, payload: result.data.user }); | ||
dispatch(registerSuccess()); | ||
setTimeout(() => { | ||
window.location.href = '/login'; | ||
}, 3000); | ||
}) | ||
.catch((error) => { | ||
const retData = error.response.data.errors; | ||
if (!('username' in retData)) { | ||
retData.username = []; | ||
} | ||
|
||
if (!('email' in retData)) { | ||
retData.email = []; | ||
} | ||
|
||
if (!('password' in retData)) { | ||
retData.password = []; | ||
} | ||
|
||
dispatch(submitStatus(true)); | ||
return dispatch({ type: actionTypes.REGISTER_ERROR, payload: retData }); | ||
}); | ||
}; |
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 @@ | ||
const token = localStorage.getItem('token') || ''; | ||
const axiosHeader = { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: token, | ||
}, | ||
}; | ||
|
||
export default axiosHeader; |
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,10 +1,9 @@ | ||
.App-header { | ||
background-color: #282c34; | ||
min-height: 100vh; | ||
margin-top: 200px; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: calc(10px + 2vmin); | ||
color: white; | ||
} | ||
color: white; } |
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
Oops, something went wrong.