Skip to content

Commit 3d03c8c

Browse files
authored
Fixed issues, modified project structure, check user profile (#558)
* fixing issues * fixing issues and modify project structure
1 parent 0f99b07 commit 3d03c8c

File tree

103 files changed

+549
-359
lines changed

Some content is hidden

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

103 files changed

+549
-359
lines changed

src/actions/authAction.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import jwt_decode from 'jwt-decode';
55
import { errorHandler } from '../utils/errorHandler';
66
import { setRequestStatus } from '../utils/setRequestStatus';
77
import { BASE_URL } from './baseApi';
8+
import { customErrorHandler } from '../utils/customErrorHandler'
89
let forgotPasswordToken = "";
910

1011
// to register user
@@ -23,6 +24,7 @@ export const registerUser = (userInfo, history) => async (dispatch) => {
2324
}
2425

2526
} catch(error) {
27+
console.log('register error ', error)
2628
dispatch(errorHandler(error));
2729
}
2830
}
@@ -62,7 +64,8 @@ export const loginUser = (userInfo, history) => async (dispatch) => {
6264
history.push("/dashboard");
6365
}
6466
} catch(error) {
65-
dispatch(errorHandler(error));
67+
console.log('login error ', error?.response)
68+
dispatch(customErrorHandler(error?.response?.data || ""));
6669
}
6770
}
6871

src/actions/insightAction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const getOrgOverview = () => async (dispatch) => {
2525
// GET PERSONAL OVERVIEW
2626
export const getPersonalOverview = () => async (dispatch) => {
2727
try {
28-
const res = await axios.get(`${BASE_URL}/user/overview`)
28+
const res = await axios.get(`${BASE_URL}/user/me/overview`)
2929
dispatch(setRequestStatus(false))
3030
if (res.status === 200) {
3131
dispatch(setRequestStatus(true))

src/actions/usersAction.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ import { setRequestStatus } from '../utils/setRequestStatus'
55
import { BASE_URL } from './baseApi'
66

77
// GET USER PROFILE
8-
export const getProfile = () => async (dispatch)=> {
8+
export const getProfile = (id) => async (dispatch)=> {
99
try {
10-
const res = await axios.get(`${BASE_URL}/user/me`)
11-
dispatch(setRequestStatus(false))
10+
console.log('getProfile userId ',id)
11+
const res = await axios.get(`${BASE_URL}/user/${id}`)
1212
if (res.status === 200) {
13-
setRequestStatus(true)
1413
console.log('user profile ', res.data)
1514
dispatch({
1615
type: GET_USER_PROFILE,
@@ -95,13 +94,12 @@ export const removeUser = (userId) => async (dispatch) => {
9594
}
9695

9796
// UPDATE USER PROFILE
98-
export const updateProfile = (updatedInfo) => async (dispatch) => {
97+
export const updateProfile = (userId, updatedInfo) => async (dispatch) => {
9998
try {
99+
console.log('updateProfile userId ', userId)
100100
console.log('updating ', updatedInfo)
101-
const res = await axios.patch(`${BASE_URL}/user/me`, updatedInfo)
102-
dispatch(setRequestStatus(false))
101+
const res = await axios.patch(`${BASE_URL}/user/${userId}`, updatedInfo)
103102
if(res.status === 200) {
104-
dispatch(setRequestStatus(true))
105103
console.log('user profile updated ', res.data)
106104
dispatch({
107105
type: UPDATE_USER_PROFILE,
@@ -114,9 +112,11 @@ export const updateProfile = (updatedInfo) => async (dispatch) => {
114112
}
115113

116114
// GET EVENTS CREATED BY USER
117-
export const getEventsCreatedByUser = (pagination = 10, page = 1) => async (dispatch) => {
115+
export const getEventsCreatedByUser = (userId, pagination = 10, page = 1) => async (dispatch) => {
118116
try {
119-
const res = await axios.get(`${BASE_URL}/event/me/all?pagination=${pagination}&page=${page}`);
117+
console.log('getEvents userId ', userId)
118+
const res = await axios
119+
.get(`${BASE_URL}/event/${userId}/all?pagination=${pagination}&page=${page}`);
120120
dispatch(setRequestStatus(false))
121121
if(res.status === 200) {
122122
dispatch(setRequestStatus(true))
@@ -132,9 +132,11 @@ export const getEventsCreatedByUser = (pagination = 10, page = 1) => async (disp
132132
}
133133

134134
// GET ALL PROJECT CREATED BY A USER
135-
export const getProjectCreatedByUser = (pagination = 10, page = 1) => async (dispatch) => {
135+
export const getProjectCreatedByUser = (userId, pagination = 10, page = 1) => async (dispatch) => {
136136
try {
137-
const res = await axios.get(`${BASE_URL}/project/me/all?pagination=${pagination}&page=${page}`);
137+
console.log('getProjects userId ', userId)
138+
const res = await axios
139+
.get(`${BASE_URL}/project/${userId}/all?pagination=${pagination}&page=${page}`);
138140
dispatch(setRequestStatus(false))
139141
if(res.status === 200) {
140142
dispatch(setRequestStatus(true))
@@ -150,9 +152,11 @@ export const getProjectCreatedByUser = (pagination = 10, page = 1) => async (dis
150152
}
151153

152154
// GET POSTS CREATED BY USER
153-
export const getPostsCreatedByUser = (pagination = 10, page = 1) => async (dispatch) => {
155+
export const getPostsCreatedByUser = (userId, pagination = 10, page = 1) => async (dispatch) => {
154156
try {
155-
const res = await axios.get(`${BASE_URL}/post/me/all?pagination=${pagination}&page=${page}`);
157+
console.log('getPosts userId ', userId)
158+
const res = await axios
159+
.get(`${BASE_URL}/post/${userId}/all?pagination=${pagination}&page=${page}`);
156160
dispatch(setRequestStatus(false))
157161
if(res.status === 200) {
158162
dispatch(setRequestStatus(true))
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)