Skip to content

Commit bb0348f

Browse files
authored
Settings integrate and deploy configuration (#530)
* integrated settings page and user activity modification * configure to deploy
1 parent bc3493b commit bb0348f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+594
-265
lines changed

.env.development

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#.env.development
2+
REACT_APP_API_ENDPOINT = "http://localhost:5000"

.env.production

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#.env.production
2+
REACT_APP_API_ENDPOINT = "https://codeuino-donut-development.herokuapp.com"

.env.staging

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# NODE_ENV will always be set to "production" for a build
2+
# more details at https://create-react-app.dev/docs/deployment/#customizing-environment-variables-for-arbitrary-build-environments
3+
4+
REACT_APP_CUSTOM_NODE_ENV = "staging"
5+
REACT_APP_API_ENDPOINT = "https://codeuino-donut-development.herokuapp.com"

package-lock.json

Lines changed: 52 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"antd": "^4.4.2",
1515
"axios": "^0.19.1",
1616
"boostrap": "^2.0.0",
17+
"env-cmd": "^10.1.0",
1718
"html-react-parser": "^0.13.0",
1819
"http-proxy-middleware": "^1.0.5",
1920
"jwt-decode": "^2.2.0",
@@ -43,10 +44,10 @@
4344
"showdown": "^1.9.1",
4445
"socket.io-client": "^2.3.0"
4546
},
46-
"proxy": "http://localhost:5000",
4747
"scripts": {
4848
"start": "react-scripts start",
4949
"build": "CI=false && react-scripts build && ./build.sh",
50+
"build:staging": "env-cmd -f .env.staging react-scripts build && ./build.sh",
5051
"test": "react-scripts test",
5152
"eject": "react-scripts eject"
5253
},

src/actions/adminAction.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import { SET_ADMIN, GET_ADMIN } from './types'
55
import { setAuthToken } from '../utils/setAuthToken'
66
import jwt_decode from 'jwt-decode';
77
import { setCurrentUser } from './authAction'
8+
import { BASE_URL } from './baseApi'
89

910

1011
export const createAdmin = (adminInfo) => async (dispatch) => {
1112
try {
12-
const res = await axios.post('/user/', adminInfo)
13+
const res = await axios.post(`${BASE_URL}/user/`, adminInfo)
1314
setRequestStatus(false)
1415
if (res.status === 201) {
1516
setRequestStatus(true)
@@ -25,7 +26,7 @@ export const createAdmin = (adminInfo) => async (dispatch) => {
2526

2627
export const loginAdmin = (adminInfo, history) => async (dispatch) => {
2728
try {
28-
const res = await axios.post('/auth/login/', adminInfo)
29+
const res = await axios.post(`${BASE_URL}/auth/login/`, adminInfo)
2930
dispatch(setRequestStatus(false));
3031
if (res.status === 200) {
3132

src/actions/authAction.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import { setAuthToken } from '../utils/setAuthToken';
44
import jwt_decode from 'jwt-decode';
55
import { errorHandler } from '../utils/errorHandler';
66
import { setRequestStatus } from '../utils/setRequestStatus';
7+
import { BASE_URL } from './baseApi';
78
let forgotPasswordToken = "";
89

910
// to register user
1011
export const registerUser = (userInfo, history) => async (dispatch) => {
1112
try {
12-
const res = await axios.post('/user', userInfo);
13+
const res = await axios.post(`${BASE_URL}/user`, userInfo);
1314
dispatch(setRequestStatus(false));
1415

1516
if(res.status === 201) {
@@ -31,8 +32,8 @@ export const loginUser = (userInfo, history) => async (dispatch) => {
3132
try {
3233

3334
console.log("LOGGING IN...", userInfo);
34-
35-
const res = await axios.post('/auth/login', userInfo);
35+
console.log('base url ', BASE_URL);
36+
const res = await axios.post(`${BASE_URL}/auth/login`, userInfo);
3637
dispatch(setRequestStatus(false));
3738
if(res.status === 200){
3839

@@ -68,7 +69,7 @@ export const loginUser = (userInfo, history) => async (dispatch) => {
6869
// forgot password
6970
export const forgotPassword = (email) => async (dispatch) => {
7071
try {
71-
const res = await axios.patch('/user/password_reset/request/', email);
72+
const res = await axios.patch(`${BASE_URL}/user/password_reset/request/`, email);
7273
dispatch(setRequestStatus(false));
7374

7475
if(res.status === 200){
@@ -89,7 +90,10 @@ export const forgotPassword = (email) => async (dispatch) => {
8990
// update password
9091
export const changePassword = (passObj) => async (dispatch) => {
9192
try {
92-
const res = await axios.patch(`/user/password_reset/${forgotPasswordToken}`, passObj);
93+
const res = await axios.patch(
94+
`${BASE_URL}/user/password_reset/${forgotPasswordToken}`,
95+
passObj
96+
);
9397
dispatch(setRequestStatus(false));
9498

9599
if(res.status === 200){
@@ -113,7 +117,7 @@ export const logoutUser = () => async (dispatch) => {
113117
try {
114118
console.log('Logging out!!')
115119
// clear token from backend
116-
const res = await axios.post('/user/logout')
120+
const res = await axios.post(`${BASE_URL}/user/logout`)
117121
if (res.status === 200) {
118122
// remove all keys from the localStorage except the orgId
119123
const orgId = localStorage.getItem('orgId');

src/actions/baseApi.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const BASE_URL = `${process.env.REACT_APP_API_ENDPOINT}`;

src/actions/commentAction.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import { GET_COMMENTS_OF_A_POST } from './types'
22
import { errorHandler } from '../utils/errorHandler'
33
import axios from 'axios'
44
import { setRequestStatus } from '../utils/setRequestStatus'
5+
import { BASE_URL } from './baseApi'
56

67
// CREATE COMMENT ON A PARTICULAR POST
78
export const createComment = (postId, comment) => async (dispatch) => {
89
try {
9-
const res = await axios.post(`/comment/${postId}`, comment)
10+
const res = await axios.post(`${BASE_URL}/comment/${postId}`, comment)
1011
dispatch(setRequestStatus(false));
1112
if(res.status === 201) {
1213
dispatch(setRequestStatus(true))
@@ -21,7 +22,7 @@ export const createComment = (postId, comment) => async (dispatch) => {
2122
// GET ALL COMMENTS OF A POST
2223
export const getAllCommentsOfPost = (postId) => async (dispatch) => {
2324
try {
24-
const res = await axios.get(`/comment/${postId}`)
25+
const res = await axios.get(`${BASE_URL}/comment/${postId}`)
2526
dispatch(setRequestStatus(false))
2627
if(res.status === 200) {
2728
dispatch(setRequestStatus(true));
@@ -39,7 +40,7 @@ export const getAllCommentsOfPost = (postId) => async (dispatch) => {
3940
// UPDATE COMMENT OF A POST
4041
export const updateComment = (commentId, updatedComment) => async (dispatch) => {
4142
try {
42-
const res = await axios.patch(`/comment/${commentId}`, updatedComment)
43+
const res = await axios.patch(`${BASE_URL}/comment/${commentId}`, updatedComment)
4344
dispatch(setRequestStatus(false))
4445
if(res.status === 200) {
4546
dispatch(setRequestStatus(true))
@@ -54,7 +55,7 @@ export const updateComment = (commentId, updatedComment) => async (dispatch) =>
5455
// DELETE COMMENT
5556
export const deleteComment = (commentId) => async (dispatch) => {
5657
try {
57-
const res = await axios.delete(`/comment/${commentId}`)
58+
const res = await axios.delete(`${BASE_URL}/comment/${commentId}`)
5859
dispatch(setRequestStatus(false))
5960
if(res.status === 200) {
6061
dispatch(setRequestStatus(true));

src/actions/dashboardAction.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import { GET_ALL_UPCOMING_EVENTS } from './types'
55
import { getAllEvents } from './eventAction'
66
import { getAllPosts } from './postAction'
77
import { getAllProjects } from './projectAction'
8+
import { BASE_URL } from './baseApi'
89

910
// GET UPCOMING EVENTS
1011
export const upcomingEvents = () => async (dispatch) => {
1112
try {
12-
const res = await axios.get('/event/upcoming')
13+
const res = await axios.get(`${BASE_URL}/event/upcoming`)
1314
dispatch(setRequestStatus(false))
1415
if (res.status === 200) {
1516
dispatch(setRequestStatus(true))
@@ -27,7 +28,7 @@ export const upcomingEvents = () => async (dispatch) => {
2728
// CREATE POST
2829
export const createPost = (postInfo) => async (dispatch) => {
2930
try {
30-
const res = await axios.post('/post/', postInfo)
31+
const res = await axios.post(`${BASE_URL}/post/`, postInfo)
3132
dispatch(setRequestStatus(false))
3233
if (res.status === 201) {
3334
dispatch(setRequestStatus(true))
@@ -42,7 +43,7 @@ export const createPost = (postInfo) => async (dispatch) => {
4243
// CREATE EVENT
4344
export const createEvent = (eventInfo) => async (dispatch) => {
4445
try {
45-
const res = await axios.post('/event/', eventInfo)
46+
const res = await axios.post(`${BASE_URL}/event/`, eventInfo)
4647
dispatch(setRequestStatus(false))
4748
if (res.status === 201) {
4849
dispatch(setRequestStatus(true))
@@ -58,7 +59,7 @@ export const createEvent = (eventInfo) => async (dispatch) => {
5859
export const createProject = (projectInfo) => async (dispatch) => {
5960
try {
6061
console.log('projectInfo ', projectInfo)
61-
const res = await axios.post('/project/', projectInfo)
62+
const res = await axios.post(`${BASE_URL}/project/`, projectInfo)
6263
dispatch(setRequestStatus(false))
6364
if (res.status === 201) {
6465
dispatch(setRequestStatus(true))

0 commit comments

Comments
 (0)